Browse Source

修改分润逻辑

周箭河 5 years ago
parent
commit
b34c73e042

+ 4 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1578,9 +1578,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
-            paymentDetail.setAmount(amount);
+            paymentDetail.setAmount(amount.negate());
             paymentDetail.setBalance(cashAccount.getBalance());
-            paymentDetail.setComment("费");
+            paymentDetail.setComment("费");
             paymentDetail.setCreateTime(date);
             paymentDetail.setStatus(DealStatusEnum.SUCCESS);
             paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
@@ -1588,8 +1588,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             paymentDetail.setUpdateTime(date);
             paymentDetail.setUserId(userId);
             rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount());
-            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             sysUserCashAccountDetailService.insert(paymentDetail);
 
             // 发送续费结果通知

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -761,7 +761,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
             //缴费
             SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
-            paymentDetail.setAmount(BigDecimal.ZERO.subtract(amount));
+            paymentDetail.setAmount(amount.negate());
             paymentDetail.setBalance(cashAccount.getBalance());
             paymentDetail.setComment("报名缴费");
             paymentDetail.setCreateTime(nowDate);
@@ -771,8 +771,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             paymentDetail.setUpdateTime(nowDate);
             paymentDetail.setUserId(studentRegistration.getUserId());
             rechargeDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-            rechargeDetail.setComAmount(BigDecimal.ZERO.subtract(studentPaymentOrder.getComAmount()));
-            rechargeDetail.setPerAmount(BigDecimal.ZERO.subtract(studentPaymentOrder.getPerAmount()));
+            rechargeDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+            rechargeDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
             sysUserCashAccountDetailService.insert(paymentDetail);
 
             //发送缴费成功通知(短信 + push)

+ 2 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1169,8 +1169,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
 		sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
 		sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
-		sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
-		sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
+		sysUserExpendCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
+		sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
 
 		sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
 		sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);

+ 3 - 132
mec-student/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -50,10 +50,6 @@ public class StudentOrderController extends BaseController {
     @Autowired
     private MusicGroupService musicGroupService;
     @Autowired
-    private SporadicChargeInfoService sporadicChargeInfoService;
-    @Autowired
-    private YqPayFeignService yqQueryService;
-    @Autowired
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 
     @PostMapping("/notify")
@@ -79,7 +75,7 @@ public class StudentOrderController extends BaseController {
             notifyMap.put("totalMoney", notifyMap.get("payAmount"));
             notifyMap.put("merOrderNo", notifyMap.get("merMerOrderNo"));
             notifyMap.put("channelType", channelType);
-            updateOrder(notifyMap);
+            studentPaymentOrderService.updateOrder(notifyMap);
             msg.setCode("000000");
             msg.setMsg("success");
         }
@@ -154,131 +150,6 @@ public class StudentOrderController extends BaseController {
         return succeed(payment);
     }
 
-
-    //@Scheduled(cron = "0 */1 * * * ?")
-    public void getOrderStatus() throws Exception {
-        List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "YQPAY");
-
-        if(payingOrders.size() ==0){
-            return;
-        }
-        List<String> orderNoList = payingOrders.stream().map(StudentPaymentOrder::getOrderNo).collect(Collectors.toList());
-        String merOrderNos = payingOrders.stream().map(StudentPaymentOrder::getOrderNo).collect(Collectors.joining(","));
-
-        String notifyUrl = ""; //回调地址
-        Map<String, Object> resultMap = new LinkedHashMap<>();
-        resultMap.put("merOrderNoList", merOrderNos);
-        Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
-
-        RsqMsg rsqMsg = new RsqMsg(requestMap);
-
-        Msg queryRs = yqQueryService.orderQuery(rsqMsg);
-
-        if (queryRs.getCode().equals("88")) {
-            //更新订单状态
-            String[] statusArr = {"0", "1", "7"};
-            String responseParameters = queryRs.getResponseParameters();
-            List<Map<String, String>> responseList = JSON.parseObject(responseParameters, List.class);
-            for (Map<String, String> response : responseList) {
-                Map<String, String> rpMap = response;
-                String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
-                rpMap.put("channelType", channelType);
-
-                if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
-                    updateOrder(rpMap); //更新订单
-                }
-                if (orderNoList.contains(rpMap.get("merOrderNo"))) {
-                    orderNoList.remove(rpMap.get("merOrderNo"));
-                }
-            }
-            closeOrders(orderNoList); //关闭订单
-        }
-    }
-
-    public void updateOrder(Map<String, String> rpMap) throws Exception {
-        DealStatusEnum status = rpMap.get("tradeState").equals("1") ? DealStatusEnum.SUCCESS : DealStatusEnum.FAILED;
-        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(rpMap.get("merOrderNo"));
-        if (order == null || !order.getStatus().equals(DealStatusEnum.ING)) {
-            return;
-        }
-
-        if (status.equals(DealStatusEnum.SUCCESS)) {
-            order.setPayTime(new Date());
-        } else {
-            order.setMemo(rpMap.get("remarks"));
-        }
-        order.setStatus(status);
-        order.setTransNo(rpMap.get("orderNo"));
-        order.setPaymentBusinessChannel(rpMap.get("channelType"));
-
-        if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
-            studentRegistrationService.updateApplyOrder(order);
-        } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
-            vipGroupService.orderCallback(order);
-        } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
-            musicGroupService.renewForCallback(order);
-        } else if (order.getType().equals(OrderTypeEnum.SPORADIC)) {
-            sporadicChargeInfoService.renewForCallback(order);
-        }
-    }
-
-    public void closeOrders(List<String> orderNoList) throws Exception {
-        if (orderNoList.size() == 0) {
-            return;
-        }
-
-        Calendar beforeTime = Calendar.getInstance();
-        beforeTime.add(Calendar.MINUTE, -30);// 30分钟之前的时间
-        Date beforeDate = beforeTime.getTime();
-
-        List<StudentPaymentOrder> ordersOverTime = studentPaymentOrderService.findOrdersOverTime(orderNoList, DealStatusEnum.ING, beforeDate);
-        for (StudentPaymentOrder order : ordersOverTime) {
-            order.setStatus(DealStatusEnum.FAILED);
-            order.setMemo("超时未支付关闭");
-            if (order.getType().equals(OrderTypeEnum.APPLY)) { //报名订单
-                studentRegistrationService.updateApplyOrder(order);
-            } else if (order.getType().equals(OrderTypeEnum.SMALL_CLASS_TO_BUY)) {
-                vipGroupService.orderCallback(order);
-            } else if (order.getType().equals(OrderTypeEnum.RENEW)) {
-                musicGroupService.renewForCallback(order);
-            } else if (order.getType().equals(OrderTypeEnum.SPORADIC)) {
-                sporadicChargeInfoService.renewForCallback(order);
-            }
-        }
-
-    }
-
-    // @Scheduled(cron = "0/5 * * * * ?")
-    public void adaPayQuery() throws Exception {
-        List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "ADAPAY");
-
-        List<String> orderNoList = new ArrayList<String>();
-
-        for (StudentPaymentOrder payingOrder : payingOrders) {
-            if (payingOrder.getTransNo() == null) {
-                orderNoList.add(payingOrder.getOrderNo());
-                continue;
-            }
-            Payment payment = new Pay().queryPayment(payingOrder.getTransNo());
-            Map<String, String> rpMap = new HashMap<>();
-            rpMap.put("merOrderNo", payingOrder.getOrderNo());
-            rpMap.put("remarks", payment.getReason());
-            rpMap.put("orderNo", payment.getId());
-            rpMap.put("channelType", payment.getPayChannel());
-            if (payment.getStatus().equals("succeeded")) {
-                rpMap.put("tradeState", "1");
-            }
-            if (payment.getStatus().equals("failed")) {
-                rpMap.put("tradeState", "0");
-            }
-            if (payment.getStatus().equals("pending")) {
-                orderNoList.add(payingOrder.getOrderNo());
-            }
-        }
-        closeOrders(orderNoList);
-    }
-
-
     @PostMapping("/adaNotify")
     public void adaNotify(@ModelAttribute NotifyEvent notifyEvent) throws Exception {
         logger.info(notifyEvent.toString());
@@ -296,7 +167,7 @@ public class StudentOrderController extends BaseController {
             notifyMap.put("merOrderNo", notifyMap.get("order_no"));
             notifyMap.put("merOrderNo", notifyMap.get("order_no"));
             notifyMap.put("remarks", notifyMap.get("description"));
-            updateOrder(notifyMap);
+            studentPaymentOrderService.updateOrder(notifyMap);
         }
     }
 
@@ -349,7 +220,7 @@ public class StudentOrderController extends BaseController {
             rpMap.put("channelType", channelType);
             if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
                 try {
-                    updateOrder(rpMap); //更新订单
+                    studentPaymentOrderService.updateOrder(rpMap); //更新订单
                 }catch (Exception e){
                     e.printStackTrace();
                     continue;

+ 18 - 9
mec-web/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

@@ -3,11 +3,14 @@ package com.ym.mec.web.controller;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -20,6 +23,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
 
@@ -28,12 +32,6 @@ import java.util.List;
 @RestController
 public class StudentPaymentOrderController extends BaseController {
 
-    @Value("${payment.hiddenMode}")
-    private Boolean hiddenMode;
-
-    @Value("${payment.channel}")
-    private String channel;
-
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
     @Autowired
@@ -42,6 +40,8 @@ public class StudentPaymentOrderController extends BaseController {
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private EmployeeDao employeeDao;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @ApiOperation(value = "获取订单列表")
     @GetMapping("/queryPage")
@@ -64,10 +64,19 @@ public class StudentPaymentOrderController extends BaseController {
                 }
             }
         }
-        if(hiddenMode){
-            queryInfo.setPaymentChannel(channel);
+
+        PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.queryPage(queryInfo);
+
+        int openHideMode = Integer.parseInt(sysConfigDao.findConfigValue("open_hide_mode"));
+        if(openHideMode == 1){
+            for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
+                BigDecimal balancePaymentAmount = row.getBalancePaymentAmount() == null ? BigDecimal.ZERO : row.getBalancePaymentAmount();
+                BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+                row.setExpectAmount(comAmount.add(balancePaymentAmount));
+                row.setActualAmount(comAmount.add(balancePaymentAmount));
+            }
         }
-        return succeed(studentPaymentOrderService.queryPage(queryInfo));
+        return succeed(studentPaymentOrderPageInfo);
     }
 
     @ApiOperation(value = "获取乐器采购清单")

+ 17 - 12
mec-web/src/main/java/com/ym/mec/web/controller/SysUserCashAccountDetailController.java

@@ -2,11 +2,14 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.CashAccountDetail;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
 import com.ym.mec.biz.service.SysUserCashAccountDetailService;
 import com.ym.mec.common.controller.BaseController;
 
+import com.ym.mec.common.page.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 
@@ -18,22 +21,18 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
+
 @RequestMapping("userCashAccountDetail")
 @Api(tags = "用户交易明细服务")
 @RestController
 public class SysUserCashAccountDetailController extends BaseController {
-
-    @Value("${payment.hiddenMode}")
-    private Boolean hiddenMode;
-
-    @Value("${payment.channel}")
-    private String channel;
-
-
     @Autowired
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
 
     @ApiOperation(value = "新增用户交易明细")
     @PostMapping("/add")
@@ -51,11 +50,17 @@ public class SysUserCashAccountDetailController extends BaseController {
         if (user == null && user.getId() != null) {
             return failed("请重新登录");
         }
-        if (hiddenMode){
-            queryInfo.setChannel(channel);
-        }
         queryInfo.setUserId(user.getId());
-        return succeed(sysUserCashAccountDetailService.queryPage(queryInfo));
+        PageInfo<SysUserCashAccountDetail> sysUserCashAccountDetailPageInfo = sysUserCashAccountDetailService.queryPage(queryInfo);
+
+        int openHideMode = Integer.parseInt(sysConfigDao.findConfigValue("open_hide_mode"));
+        if(openHideMode == 1){
+            for (SysUserCashAccountDetail row : sysUserCashAccountDetailPageInfo.getRows()) {
+                BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
+                row.setAmount(comAmount.add(comAmount));
+            }
+        }
+        return succeed(sysUserCashAccountDetailPageInfo);
     }
 
 }