|
@@ -7,10 +7,7 @@ import com.ym.mec.biz.dal.dao.SysConfigDao;
|
|
|
import com.ym.mec.biz.dal.dto.BasicUserDto;
|
|
|
import com.ym.mec.biz.dal.dto.StudentManageListDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
-import com.ym.mec.biz.dal.enums.OrderTypeEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
@@ -18,11 +15,13 @@ import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.IdGeneratorService;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
+import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
@@ -46,6 +45,10 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
@Autowired
|
|
|
private SysUserCashAccountService sysUserCashAccountService;
|
|
|
+ @Autowired
|
|
|
+ private SysUserCashAccountDetailService sysUserCashAccountDetailService;
|
|
|
+ @Autowired
|
|
|
+ private SysMessageService sysMessageService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, StudentRepair> getDAO() {
|
|
@@ -314,4 +317,98 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
|
|
|
return repairer;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
+ public Boolean orderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
+ Date noDate = new Date();
|
|
|
+ //更新订单信息
|
|
|
+ studentPaymentOrder.setUpdateTime(noDate);
|
|
|
+ int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ if (updateCount <= 0) {
|
|
|
+ throw new BizException("订单更新失败");
|
|
|
+ }
|
|
|
+ //更新维修单信息
|
|
|
+ StudentRepair repairInfo = getRepairInfo(Integer.parseInt(studentPaymentOrder.getMusicGroupId()));
|
|
|
+
|
|
|
+ Integer userId = studentPaymentOrder.getUserId();
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(userId);
|
|
|
+
|
|
|
+
|
|
|
+ Map<Integer, String> map = new HashMap();
|
|
|
+ map.put(userId, sysUser.getPhone());
|
|
|
+ Map<Integer, String> yimei = new HashMap();
|
|
|
+ map.put(userId, userId.toString());
|
|
|
+
|
|
|
+ if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
|
|
|
+ repairInfo.setPayStatus(2);
|
|
|
+ repairInfo.setUpdateTime(noDate);
|
|
|
+ if(this.update(repairInfo) <= 0){
|
|
|
+ throw new BizException("维修单更新失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //插入交易明细
|
|
|
+ BigDecimal amount = studentPaymentOrder.getActualAmount();
|
|
|
+ Date nowDate = new Date();
|
|
|
+ SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
|
|
|
+ //充值
|
|
|
+ SysUserCashAccountDetail rechargeDetail = new SysUserCashAccountDetail();
|
|
|
+ rechargeDetail.setAmount(amount);
|
|
|
+ rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
|
|
|
+ rechargeDetail.setComment("缴费前充值");
|
|
|
+ rechargeDetail.setCreateTime(nowDate);
|
|
|
+ rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
|
|
|
+ rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
|
|
|
+ rechargeDetail.setUpdateTime(nowDate);
|
|
|
+ rechargeDetail.setUserId(userId);
|
|
|
+ rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
+ rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
|
|
|
+ rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
|
|
|
+ sysUserCashAccountDetailService.insert(rechargeDetail);
|
|
|
+
|
|
|
+ //缴费
|
|
|
+ SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
|
|
|
+ paymentDetail.setAmount(amount.negate());
|
|
|
+ paymentDetail.setBalance(cashAccount.getBalance());
|
|
|
+ paymentDetail.setComment("乐器维修");
|
|
|
+ paymentDetail.setCreateTime(nowDate);
|
|
|
+ paymentDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
|
|
|
+ paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
|
|
|
+ paymentDetail.setUpdateTime(nowDate);
|
|
|
+ paymentDetail.setUserId(userId);
|
|
|
+ rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
+ if (studentPaymentOrder.getComAmount() != null) {
|
|
|
+ rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
|
|
|
+ rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
|
+ }
|
|
|
+ sysUserCashAccountDetailService.insert(paymentDetail);
|
|
|
+
|
|
|
+ if(repairInfo.getType().equals(0)) {
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SMS_REPAIR_OFFLINE_PAYMENT_SUCCESS, map, null, 0, "1", "STUDENT",
|
|
|
+ sysUser.getUsername());
|
|
|
+ }else {
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SMS_REPAIR_OFFLINE_PAYMENT_SUCCESS, map, null, 0, "1", "STUDENT",
|
|
|
+ sysUser.getUsername(),repairInfo.getContactName(),repairInfo.getContactMobile(),repairInfo.getAddress());
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAILED) {
|
|
|
+ repairInfo.setPayStatus(0);
|
|
|
+ repairInfo.setUpdateTime(noDate);
|
|
|
+ if(this.update(repairInfo) <= 0){
|
|
|
+ throw new BizException("维修单更新失败");
|
|
|
+ }
|
|
|
+ if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "乐器维修支付失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.SMS_SPORADIC_PAYMENT_FAILED, map, null, 0, "", "STUDENT",
|
|
|
+ studentPaymentOrder.getActualAmount(), "乐器维修");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
}
|