|
@@ -4,8 +4,10 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
|
|
import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
|
|
import com.ym.mec.biz.dal.dao.SysUserCashAccountDetailDao;
|
|
import com.ym.mec.biz.dal.dao.SysUserCashAccountDetailDao;
|
|
|
|
+import com.ym.mec.biz.dal.dao.SysUserCoursesAccountDetailDao;
|
|
import com.ym.mec.biz.dal.entity.SysUserCashAccount;
|
|
import com.ym.mec.biz.dal.entity.SysUserCashAccount;
|
|
import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
|
|
import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
|
|
|
|
+import com.ym.mec.biz.dal.entity.SysUserCoursesAccountDetail;
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.MessageTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
@@ -18,6 +20,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -38,6 +41,8 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
|
|
private SysUserCashAccountDetailDao sysUserCashAccountDetailDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysUserCoursesAccountDetailDao sysUserCoursesAccountDetailDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Integer, SysUserCashAccount> getDAO() {
|
|
public BaseDAO<Integer, SysUserCashAccount> getDAO() {
|
|
@@ -119,7 +124,8 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean updateCourseBalance(Integer userId, BigDecimal decimal) {
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
|
+ public boolean updateCourseBalance(Integer userId, BigDecimal decimal, BigDecimal amount, String description) {
|
|
SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
|
|
SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
|
|
if (cashAccount == null) {
|
|
if (cashAccount == null) {
|
|
throw new BizException("用户[{}]现金账户不存在", userId);
|
|
throw new BizException("用户[{}]现金账户不存在", userId);
|
|
@@ -130,11 +136,23 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
|
|
|
|
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
|
|
|
|
|
|
+ if(amount.compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
|
+ SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
|
|
|
|
+ sysUserCoursesAccountDetail.setUserId(userId);
|
|
|
|
+ sysUserCoursesAccountDetail.setAmount(amount);
|
|
|
|
+ sysUserCoursesAccountDetail.setBalance(decimal);
|
|
|
|
+ sysUserCoursesAccountDetail.setDescription(description+"-"+sysUser.getId());
|
|
|
|
+ sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
|
+ sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public boolean appendCourseBalance(Integer userId, BigDecimal decimal) {
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
|
+ public boolean appendCourseBalance(Integer userId, BigDecimal decimal, String description) {
|
|
SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
|
|
SysUserCashAccount cashAccount = sysUserCashAccountDao.getLocked(userId);
|
|
if (cashAccount == null) {
|
|
if (cashAccount == null) {
|
|
throw new BizException("用户[{}]现金账户不存在", userId);
|
|
throw new BizException("用户[{}]现金账户不存在", userId);
|
|
@@ -151,6 +169,17 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
|
|
|
|
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
|
|
|
|
|
|
+ if(decimal.compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
|
+ SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
|
|
|
|
+ sysUserCoursesAccountDetail.setUserId(userId);
|
|
|
|
+ sysUserCoursesAccountDetail.setAmount(decimal);
|
|
|
|
+ sysUserCoursesAccountDetail.setBalance(balance);
|
|
|
|
+ sysUserCoursesAccountDetail.setDescription(description+"-"+sysUser.getId());
|
|
|
|
+ sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
|
+ sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -185,6 +214,17 @@ public class SysUserCashAccountServiceImpl extends BaseServiceImpl<Integer, SysU
|
|
cashAccount.setUpdateTime(date);
|
|
cashAccount.setUpdateTime(date);
|
|
|
|
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
sysUserCashAccountDao.update(cashAccount);
|
|
|
|
+
|
|
|
|
+ if(cashAccount.getCourseBalance().compareTo(BigDecimal.ZERO)!=0){
|
|
|
|
+ SysUserCoursesAccountDetail sysUserCoursesAccountDetail=new SysUserCoursesAccountDetail();
|
|
|
|
+ sysUserCoursesAccountDetail.setUserId(userId);
|
|
|
|
+ sysUserCoursesAccountDetail.setAmount(cashAccount.getCourseBalance());
|
|
|
|
+ sysUserCoursesAccountDetail.setBalance(new BigDecimal(0));
|
|
|
|
+ sysUserCoursesAccountDetail.setDescription("课程余额转账");
|
|
|
|
+ sysUserCoursesAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
|
+ sysUserCoursesAccountDetailDao.insert(sysUserCoursesAccountDetail);
|
|
|
|
+ }
|
|
|
|
+
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|