Browse Source

分帐BUG列表等

zhangbin 1 year ago
parent
commit
a9a00308fa

+ 8 - 8
nbjk-admin/src/main/java/com/miaxis/app/controller/wx/WxController.java

@@ -266,9 +266,9 @@ public class WxController extends BaseController {
             order.setPhoneType(wxOrderDTO.getPhoneType()); //手机类型 1:苹果 2:安卓
             order.setPhoneType(wxOrderDTO.getPhoneType()); //手机类型 1:苹果 2:安卓
             order.setForeType(wxOrderDTO.getForeType()); //前端类型 1:app 2:小程序 3:公众号
             order.setForeType(wxOrderDTO.getForeType()); //前端类型 1:app 2:小程序 3:公众号
             if("1".equals(profitSharing)) {
             if("1".equals(profitSharing)) {
-                order.setProfitSharing(1); //待分账
+                order.setIsSharing(1); //分账
             } else {
             } else {
-                order.setProfitSharing(0); //待分账
+                order.setIsSharing(0); //不分账
             }
             }
             order.setTotal(examInfo.getPrice());
             order.setTotal(examInfo.getPrice());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
@@ -298,9 +298,9 @@ public class WxController extends BaseController {
             order.setForeType(wxOrderDTO.getForeType()); //前端类型 1:app 2:小程序 3:公众号
             order.setForeType(wxOrderDTO.getForeType()); //前端类型 1:app 2:小程序 3:公众号
             order.setTotal(Integer.parseInt(baziPriceStr));
             order.setTotal(Integer.parseInt(baziPriceStr));
             if("1".equals(profitSharing)) {
             if("1".equals(profitSharing)) {
-                order.setProfitSharing(1); //待分账
+                order.setIsSharing(1); //分账
             } else {
             } else {
-                order.setProfitSharing(0); //待分账
+                order.setIsSharing(0); //不分账
             }
             }
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             wxOrderService.save(order);
             wxOrderService.save(order);
@@ -379,9 +379,9 @@ public class WxController extends BaseController {
             order.setTotal(examInfo.getPrice());
             order.setTotal(examInfo.getPrice());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             if("1".equals(profitSharing)) {
             if("1".equals(profitSharing)) {
-                order.setProfitSharing(1); //待分账
+                order.setIsSharing(1); //分账
             } else {
             } else {
-                order.setProfitSharing(0); //不分账
+                order.setIsSharing(0); //不分账
             }
             }
             wxOrderService.save(order);
             wxOrderService.save(order);
             return Response.success(placeGzhJsWxOrder(order, examInfo.getName()));
             return Response.success(placeGzhJsWxOrder(order, examInfo.getName()));
@@ -501,9 +501,9 @@ public class WxController extends BaseController {
             order.setTotal(examInfo.getPrice());
             order.setTotal(examInfo.getPrice());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             order.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());
             if("1".equals(profitSharing)) {
             if("1".equals(profitSharing)) {
-                order.setProfitSharing(1); //待分账
+                order.setIsSharing(1); //分账
             } else {
             } else {
-                order.setProfitSharing(0); //不分账
+                order.setIsSharing(0); //不分账
             }
             }
             wxOrderService.save(order);
             wxOrderService.save(order);
             return Response.success(placeH5WxOrder(order, examInfo.getName()));
             return Response.success(placeH5WxOrder(order, examInfo.getName()));

+ 6 - 21
nbjk-admin/src/main/java/com/miaxis/pc/controller/PcOrderInfoController.java

@@ -7,7 +7,6 @@ import com.miaxis.order.domain.OrderInfo;
 import com.miaxis.order.dto.OrderInfoDto;
 import com.miaxis.order.dto.OrderInfoDto;
 import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
-import com.miaxis.wx.dto.WxOrderShareProfitDTO;
 import com.miaxis.wx.service.IRefundRecordService;
 import com.miaxis.wx.service.IRefundRecordService;
 import com.miaxis.wx.service.IWxOrderService;
 import com.miaxis.wx.service.IWxOrderService;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
@@ -53,20 +52,6 @@ public class PcOrderInfoController extends BaseController {
     }
     }
 
 
 
 
-    /**
-     * 查询分帐订单列表
-     */
-    @GetMapping("/wxlist")
-    @ApiOperation("查询分帐订单列表")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
-            @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
-    })
-    public ResponsePageInfo<WxOrder> wxlist(@ModelAttribute WxOrderShareProfitDTO wxOrderShareProfitDTO) {
-        startPage();
-        List<WxOrder> list = wxOrderService.selectWxOrderProfitList(wxOrderShareProfitDTO);
-        return toResponsePageInfo(list);
-    }
 
 
     /**
     /**
      * 发起分账
      * 发起分账
@@ -76,13 +61,13 @@ public class PcOrderInfoController extends BaseController {
     public Response<OrderInfo> shareProfit(
     public Response<OrderInfo> shareProfit(
             @ApiParam(name = "outTradeNo", value = "商户订单信息", required = true)
             @ApiParam(name = "outTradeNo", value = "商户订单信息", required = true)
             @PathVariable("outTradeNo") String outTradeNo) throws Exception {
             @PathVariable("outTradeNo") String outTradeNo) throws Exception {
-        WxOrder order = wxOrderService.getByOutTradeNo(outTradeNo);
+        OrderInfo orderInfo = orderInfoService.getByOutTradeNo(outTradeNo);
 
 
-        if (!"SUCCESS".equals(order.getTradeState())) {
+        if (orderInfo.getTradeType()==1) {
             Response response = new Response(200, "非支付成功的订单,无法分账。");
             Response response = new Response(200, "非支付成功的订单,无法分账。");
             return response;
             return response;
         }
         }
-        if (order.getProfitSharing() != 1) {
+        if (orderInfo.getProfitSharing() != 1) {
             Response response = new Response(200, "非待分账订单,无法分账。");
             Response response = new Response(200, "非待分账订单,无法分账。");
             return response;
             return response;
         }
         }
@@ -93,13 +78,13 @@ public class PcOrderInfoController extends BaseController {
         long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
         long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
         Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
         Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
 
 
-        if (nowDate.compareTo(order.getSuccessTime()) < 0) {
+        if (nowDate.compareTo(orderInfo.getSuccessTime()) < 0) {
             Response response = new Response(200, "支付成功的订单,未满5分钟无法分账,请稍后操作。");
             Response response = new Response(200, "支付成功的订单,未满5分钟无法分账,请稍后操作。");
             return response;
             return response;
         }
         }
 
 
-        boolean addFlag = wxOrderService.wxAddFenZhang(order);
-        boolean flag = wxOrderService.wxProfitsharing(order);
+        boolean addFlag = wxOrderService.wxAddFenZhang(orderInfo);
+        boolean flag = wxOrderService.wxProfitsharing(orderInfo);
         if (flag && addFlag) {
         if (flag && addFlag) {
             Response response = new Response(200, "分账成功");
             Response response = new Response(200, "分账成功");
             return response;
             return response;

+ 12 - 9
nbjk-admin/src/test/java/com/miaxis/test/Test3.java

@@ -2,6 +2,8 @@ package com.miaxis.test;
 
 
 import com.miaxis.NbjkApplication;
 import com.miaxis.NbjkApplication;
 import com.miaxis.dict.service.IDictCityService;
 import com.miaxis.dict.service.IDictCityService;
+import com.miaxis.order.domain.OrderInfo;
+import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.service.IWxOrderService;
 import com.miaxis.wx.service.IWxOrderService;
 import org.junit.Test;
 import org.junit.Test;
@@ -22,24 +24,25 @@ public class Test3 {
     @Autowired
     @Autowired
     private IWxOrderService wxOrderService;
     private IWxOrderService wxOrderService;
 
 
-
+    @Autowired
+    private IOrderInfoService orderInfoService;
 
 
     @Test
     @Test
     public void test() throws Exception {
     public void test() throws Exception {
     //    WxOrder wxOrder = wxOrderService.getById(892);
     //    WxOrder wxOrder = wxOrderService.getById(892);
 
 
-        List<WxOrder> wxOrderList = wxOrderService.selectWxOrderByWaitProfit();
+        List<OrderInfo> orderInfoList = orderInfoService.selectOrderInfoByWaitProfit();
 
 
-        for (int i = 0; i < wxOrderList.size(); i++) {
-            WxOrder wxOrder = wxOrderList.get(i);
-            boolean flag = wxOrderService.wxProfitsharing(wxOrderList.get(i));
+        for (int i = 0; i < orderInfoList.size(); i++) {
+            OrderInfo orderInfo = orderInfoList.get(i);
+            boolean flag = wxOrderService.wxProfitsharing(orderInfoList.get(i));
 
 
             if(flag) {
             if(flag) {
-                wxOrder.setProfitSharing(3);
-                wxOrderService.saveOrUpdate(wxOrder);
+                orderInfo.setProfitSharing(3);
+                orderInfoService.saveOrUpdate(orderInfo);
             } else {
             } else {
-                wxOrder.setProfitSharing(2);
-                wxOrderService.saveOrUpdate(wxOrder);
+                orderInfo.setProfitSharing(2);
+                orderInfoService.saveOrUpdate(orderInfo);
             }
             }
 
 
         }
         }

+ 11 - 13
nbjk-admin/src/test/java/com/miaxis/test/WxFenZhangTest.java

@@ -1,6 +1,8 @@
 package com.miaxis.test;
 package com.miaxis.test;
 
 
 import com.miaxis.NbjkApplication;
 import com.miaxis.NbjkApplication;
+import com.miaxis.order.domain.OrderInfo;
+import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.service.IWxGzhService;
 import com.miaxis.wx.service.IWxGzhService;
 import com.miaxis.wx.service.IWxOrderService;
 import com.miaxis.wx.service.IWxOrderService;
@@ -21,23 +23,19 @@ public class WxFenZhangTest {
     @Autowired
     @Autowired
     private IWxOrderService wxOrderService;
     private IWxOrderService wxOrderService;
 
 
+    @Autowired
+    private IOrderInfoService orderInfoService;
+
+
     @Test
     @Test
     public void test1() throws Exception {
     public void test1() throws Exception {
 
 
-        List<WxOrder> wxOrderList = wxOrderService.selectWxOrderByWaitProfit();
-
-        for (int i = 0; i < wxOrderList.size(); i++) {
-            WxOrder wxOrder = wxOrderList.get(i);
-            wxOrderService.wxAddFenZhang(wxOrder); //添加
-            boolean flag = wxOrderService.wxProfitsharing(wxOrderList.get(i));
+        List<OrderInfo> orderInfoList = orderInfoService.selectOrderInfoByWaitProfit();
 
 
-            if(flag) {
-                wxOrder.setProfitSharing(3);
-                wxOrderService.saveOrUpdate(wxOrder);
-            } else {
-                wxOrder.setProfitSharing(2);
-                wxOrderService.saveOrUpdate(wxOrder);
-            }
+        for (int i = 0; i < orderInfoList.size(); i++) {
+            OrderInfo orderInfo = orderInfoList.get(i);
+            wxOrderService.wxAddFenZhang(orderInfo); //添加
+            boolean flag = wxOrderService.wxProfitsharing(orderInfoList.get(i));
 
 
         }
         }
 
 

+ 11 - 15
nbjk-service/src/main/java/com/miaxis/job/AppAdJob.java

@@ -1,6 +1,8 @@
 package com.miaxis.job;
 package com.miaxis.job;
 
 
 import com.miaxis.common.core.domain.entity.SysDictData;
 import com.miaxis.common.core.domain.entity.SysDictData;
+import com.miaxis.order.domain.OrderInfo;
+import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.system.service.ISysDictDataService;
 import com.miaxis.system.service.ISysDictDataService;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.service.IWxOrderService;
 import com.miaxis.wx.service.IWxOrderService;
@@ -20,6 +22,10 @@ public class AppAdJob {
     private ISysDictDataService dictDataService;
     private ISysDictDataService dictDataService;
     @Autowired
     @Autowired
     private IWxOrderService wxOrderService;
     private IWxOrderService wxOrderService;
+    @Autowired
+    private IOrderInfoService orderInfoService;
+
+
 
 
    // @Scheduled(cron = "0 0 19 * * ?")
    // @Scheduled(cron = "0 0 19 * * ?")
     public void openAd()  {
     public void openAd()  {
@@ -64,26 +70,16 @@ public class AppAdJob {
     public void wxProfitsharing()  {
     public void wxProfitsharing()  {
         log.info("--------现在开始执行每1分钟一次的微信分帐!~---------------");
         log.info("--------现在开始执行每1分钟一次的微信分帐!~---------------");
 
 
-        List<WxOrder> wxOrderList = wxOrderService.selectWxOrderByWaitProfit();
-        boolean flag = false;
-        for (int i = 0; i < wxOrderList.size(); i++) {
-            WxOrder wxOrder = wxOrderList.get(i);
-
+        List<OrderInfo> orderInfoList = orderInfoService.selectOrderInfoByWaitProfit();
+        for (int i = 0; i < orderInfoList.size(); i++) {
+            OrderInfo orderInfo = orderInfoList.get(i);
             try {
             try {
-                wxOrderService.wxAddFenZhang(wxOrder); //添加
-                flag = wxOrderService.wxProfitsharing(wxOrderList.get(i));
+                wxOrderService.wxAddFenZhang(orderInfo); //添加
+                wxOrderService.wxProfitsharing(orderInfo);
             } catch (Exception e) {
             } catch (Exception e) {
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
 
 
-            if(flag) {
-                wxOrder.setProfitSharing(3);
-                wxOrderService.saveOrUpdate(wxOrder);
-            } else {
-                wxOrder.setProfitSharing(2);
-                wxOrderService.saveOrUpdate(wxOrder);
-            }
-
         }
         }
 
 
 
 

+ 18 - 0
nbjk-service/src/main/java/com/miaxis/order/domain/OrderInfo.java

@@ -78,6 +78,15 @@ public class OrderInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "公众号openid")
     @ApiModelProperty(value = "公众号openid")
     private String gzhOpenid;
     private String gzhOpenid;
 
 
+
+
+    /** 微信支付系统生成的订单号 */
+    @Excel(name = "微信支付系统生成的订单号")
+    @TableField("transaction_id")
+    @ApiModelProperty(value = "微信支付系统生成的订单号")
+    private String transactionId;
+
+
     /** 订单编号 */
     /** 订单编号 */
     @Excel(name = "订单编号")
     @Excel(name = "订单编号")
     @TableField("out_trade_no")
     @TableField("out_trade_no")
@@ -109,6 +118,13 @@ public class OrderInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "分账金额")
     @ApiModelProperty(value = "分账金额")
     private Integer splitPrice;
     private Integer splitPrice;
 
 
+
+    /** 分账状态 0 不分帐 1待分账  2分账失败  3分账完成 */
+    @Excel(name = "分账状态")
+    @TableField("profit_sharing")
+    @ApiModelProperty(value = "分账状态 0 不分帐 1待分账  2分账失败  3分账完成")
+    private Integer profitSharing;
+
     /** 交易状态 1、支付成功2、支付失败*/
     /** 交易状态 1、支付成功2、支付失败*/
     @Excel(name = "交易状态 1、支付成功2、支付失败")
     @Excel(name = "交易状态 1、支付成功2、支付失败")
     @TableField("trade_type")
     @TableField("trade_type")
@@ -152,4 +168,6 @@ public class OrderInfo extends BaseBusinessEntity{
 
 
 
 
 
 
+
+
 }
 }

+ 2 - 0
nbjk-service/src/main/java/com/miaxis/order/mapper/OrderInfoMapper.java

@@ -25,4 +25,6 @@ public interface OrderInfoMapper extends BaseMapper<OrderInfo> {
 
 
 
 
     OrderInfo getByOutTradeNo(String outTradeNo);
     OrderInfo getByOutTradeNo(String outTradeNo);
+
+    List<OrderInfo> selectOrderInfoByWaitProfit(String nowDateStr);
 }
 }

+ 2 - 0
nbjk-service/src/main/java/com/miaxis/order/service/IOrderInfoService.java

@@ -31,4 +31,6 @@ public interface IOrderInfoService extends IService<OrderInfo> {
     OrderInfo getByOutTradeNo(String outTradeNo);
     OrderInfo getByOutTradeNo(String outTradeNo);
 
 
     void refundOrder(WxOrder order);
     void refundOrder(WxOrder order);
+
+    List<OrderInfo> selectOrderInfoByWaitProfit();
 }
 }

+ 23 - 0
nbjk-service/src/main/java/com/miaxis/order/service/impl/OrderInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.miaxis.order.service.impl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.miaxis.birthday.domain.BirthdayLog;
 import com.miaxis.birthday.domain.BirthdayLog;
 import com.miaxis.birthday.service.IBirthdayLogService;
 import com.miaxis.birthday.service.IBirthdayLogService;
+import com.miaxis.common.utils.DateUtils;
 import com.miaxis.exam.domain.ExamInfo;
 import com.miaxis.exam.domain.ExamInfo;
 import com.miaxis.exam.service.IExamInfoService;
 import com.miaxis.exam.service.IExamInfoService;
 import com.miaxis.order.domain.OrderInfo;
 import com.miaxis.order.domain.OrderInfo;
@@ -13,6 +14,7 @@ import com.miaxis.vip.domain.VipUserExam;
 import com.miaxis.vip.service.IVipExamVideoService;
 import com.miaxis.vip.service.IVipExamVideoService;
 import com.miaxis.vip.service.IVipUserExamService;
 import com.miaxis.vip.service.IVipUserExamService;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
+import com.miaxis.wx.dto.WxOrderProfitDTO;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.cache.annotation.CacheConfig;
@@ -100,10 +102,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         orderInfo.setOutTradeNo(order.getOutTradeNo());
         orderInfo.setOutTradeNo(order.getOutTradeNo());
         orderInfo.setTotal(order.getTotal());
         orderInfo.setTotal(order.getTotal());
         orderInfo.setTradeType(1);
         orderInfo.setTradeType(1);
+        orderInfo.setTransactionId(order.getTransactionId());
         orderInfo.setSuccessTime(order.getSuccessTime());
         orderInfo.setSuccessTime(order.getSuccessTime());
         orderInfo.setPayType(payType);
         orderInfo.setPayType(payType);
         orderInfo.setForeType(order.getForeType());
         orderInfo.setForeType(order.getForeType());
         orderInfo.setPhoneType(order.getPhoneType());
         orderInfo.setPhoneType(order.getPhoneType());
+        orderInfo.setProfitSharing(order.getIsSharing());  //是否分账
+
 
 
         if(order.getGoodsType()==1) { //考场
         if(order.getGoodsType()==1) { //考场
             //添加会员信息
             //添加会员信息
@@ -132,6 +137,24 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
     }
     }
 
 
 
 
+    @Override
+    public List<OrderInfo> selectOrderInfoByWaitProfit() {
+
+        // 获取当前时间
+        Date currentDate = new Date();
+        // 添加5分钟
+        long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
+        Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
+
+        WxOrderProfitDTO wxOrderProfitDTO = new WxOrderProfitDTO();
+
+        String nowDateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", nowDate);
+
+        wxOrderProfitDTO.setNowDate(nowDateStr);
+        List<OrderInfo> orderList = orderInfoMapper.selectOrderInfoByWaitProfit(nowDateStr);
+        return orderList;
+    }
+
 
 
 }
 }
 
 

+ 5 - 5
nbjk-service/src/main/java/com/miaxis/wx/domain/WxOrder.java

@@ -193,11 +193,11 @@ public class WxOrder extends BaseBusinessEntity{
     private Integer foreType;
     private Integer foreType;
 
 
 
 
-    /** 是否分账 0不分账 1分账 3分账完成 */
-    @Excel(name = "是否分账 0不分账 1分账 3分账完成")
-    @TableField("profit_sharing")
-    @ApiModelProperty(value = "是否分账 0不分账 1分账 3分账完成")
-    private Integer profitSharing;
+    /** 是否分账 0不分账 1分账 */
+    @Excel(name = "是否分账 0不分账 1分账")
+    @TableField("is_sharing")
+    @ApiModelProperty(value = "是否分账 0不分账 1分账")
+    private Integer isSharing;
 
 
 
 
 
 

+ 0 - 26
nbjk-service/src/main/java/com/miaxis/wx/dto/WxOrderShareProfitDTO.java

@@ -1,26 +0,0 @@
-package com.miaxis.wx.dto;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-
-@Data
-public class WxOrderShareProfitDTO {
-    private static final long serialVersionUID = 1L;
-
-
-
-    @ApiModelProperty(value = "是否分账 0不分帐 1待分账  2分账失败  3分账完成",required = true)
-    private Integer profitSharing;
-
-    @ApiModelProperty(value = "商户订单号")
-    private String outTradeNo;
-
-    /** 开始时间 */
-    @ApiModelProperty(value = "开始时间 格式yyyy-MM-dd HH:mm:ss")
-    private String startTime;
-    /** 结束时间 */
-    @ApiModelProperty(value = "结束时间 格式yyyy-MM-dd HH:mm:ss")
-    private String endTime;
-
-
-}

+ 0 - 1
nbjk-service/src/main/java/com/miaxis/wx/mapper/WxOrderMapper.java

@@ -32,5 +32,4 @@ public interface WxOrderMapper extends BaseMapper<WxOrder> {
 
 
     List<WxOrder> selectWxOrderByWaitProfit(String nowDate);
     List<WxOrder> selectWxOrderByWaitProfit(String nowDate);
 
 
-    List<WxOrder> selectWxOrderProfitList(WxOrderShareProfitDTO orderShareProfitDTO);
 }
 }

+ 3 - 6
nbjk-service/src/main/java/com/miaxis/wx/service/IWxOrderService.java

@@ -1,9 +1,9 @@
 package com.miaxis.wx.service;
 package com.miaxis.wx.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.miaxis.order.domain.OrderInfo;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.dto.WxExtractBankDTO;
 import com.miaxis.wx.dto.WxExtractBankDTO;
-import com.miaxis.wx.dto.WxOrderShareProfitDTO;
 
 
 import java.util.List;
 import java.util.List;
 
 
@@ -12,9 +12,9 @@ import java.util.List;
 public interface IWxOrderService extends IService<WxOrder>{
 public interface IWxOrderService extends IService<WxOrder>{
 
 
 
 
-    boolean wxAddFenZhang(WxOrder wxOrder) throws Exception;
+    boolean wxAddFenZhang(OrderInfo orderInfo) throws Exception;
 
 
-    boolean wxProfitsharing(WxOrder wxOrder) throws  Exception;
+    boolean wxProfitsharing(OrderInfo orderInfo) throws  Exception;
 
 
     WxOrder getByOutTradeNo(String outTradeNo);
     WxOrder getByOutTradeNo(String outTradeNo);
 
 
@@ -22,7 +22,4 @@ public interface IWxOrderService extends IService<WxOrder>{
 
 
     String wxwithbankdrawal(WxExtractBankDTO amount) throws Exception;
     String wxwithbankdrawal(WxExtractBankDTO amount) throws Exception;
 
 
-    List<WxOrder> selectWxOrderByWaitProfit();
-
-    List<WxOrder> selectWxOrderProfitList(WxOrderShareProfitDTO orderShareProfitDTO);
 }
 }

+ 17 - 39
nbjk-service/src/main/java/com/miaxis/wx/service/impl/WxOrderServiceImpl.java

@@ -9,7 +9,6 @@ import com.github.wxpay.sdk.WXPayConstants;
 import com.github.wxpay.sdk.WXPayUtil;
 import com.github.wxpay.sdk.WXPayUtil;
 import com.miaxis.common.config.WxPayXcxConfigImpl;
 import com.miaxis.common.config.WxPayXcxConfigImpl;
 import com.miaxis.common.config.WxpayConfig;
 import com.miaxis.common.config.WxpayConfig;
-import com.miaxis.common.core.domain.entity.SysUser;
 import com.miaxis.common.core.domain.entity.UserInfo;
 import com.miaxis.common.core.domain.entity.UserInfo;
 import com.miaxis.common.exception.CustomException;
 import com.miaxis.common.exception.CustomException;
 import com.miaxis.common.utils.*;
 import com.miaxis.common.utils.*;
@@ -25,7 +24,6 @@ import com.miaxis.wx.domain.WxExtractBank;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.domain.WxOrder;
 import com.miaxis.wx.dto.WxExtractBankDTO;
 import com.miaxis.wx.dto.WxExtractBankDTO;
 import com.miaxis.wx.dto.WxOrderProfitDTO;
 import com.miaxis.wx.dto.WxOrderProfitDTO;
-import com.miaxis.wx.dto.WxOrderShareProfitDTO;
 import com.miaxis.wx.mapper.WxOrderMapper;
 import com.miaxis.wx.mapper.WxOrderMapper;
 import com.miaxis.wx.service.IWxExtractBankService;
 import com.miaxis.wx.service.IWxExtractBankService;
 import com.miaxis.wx.service.IWxExtractService;
 import com.miaxis.wx.service.IWxExtractService;
@@ -95,9 +93,9 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
 
 
     @Override
     @Override
     @Transactional
     @Transactional
-    public boolean wxAddFenZhang(WxOrder wxOrder) throws Exception {
+    public boolean wxAddFenZhang(OrderInfo orderInfo) throws Exception {
         //查询上级
         //查询上级
-        String account = getAccount(wxOrder);
+        String account = getAccount(orderInfo);
         String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
         String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
 
 
         String nonceStr = RandomStringUtils.randomAlphanumeric(32);
         String nonceStr = RandomStringUtils.randomAlphanumeric(32);
@@ -147,9 +145,9 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
      */
      */
     @Override
     @Override
     @Transactional
     @Transactional
-    public boolean wxProfitsharing(WxOrder wxOrder) throws Exception {
+    public boolean wxProfitsharing(OrderInfo orderInfo) throws Exception {
         //查询上级
         //查询上级
-        String account = getAccount(wxOrder);
+        String account = getAccount(orderInfo);
         String url = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
         String url = "https://api.mch.weixin.qq.com/secapi/pay/profitsharing";
         String nonceStr = RandomStringUtils.randomAlphanumeric(32);
         String nonceStr = RandomStringUtils.randomAlphanumeric(32);
         //用于签名
         //用于签名
@@ -158,14 +156,14 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
         sortMap.put("appid", xcxAppid);
         sortMap.put("appid", xcxAppid);
         sortMap.put("nonce_str", nonceStr);
         sortMap.put("nonce_str", nonceStr);
         sortMap.put("sign_type", "HMAC-SHA256");
         sortMap.put("sign_type", "HMAC-SHA256");
-        sortMap.put("transaction_id", wxOrder.getTransactionId());
-        String orderCode = getOrderCode(wxOrder.getUserId()); //商户分账单号
+        sortMap.put("transaction_id", orderInfo.getTransactionId());
+        String orderCode = getOrderCode(orderInfo.getUserId()); //商户分账单号
         sortMap.put("out_order_no", orderCode);
         sortMap.put("out_order_no", orderCode);
 
 
 
 
         //扣除手续费后
         //扣除手续费后
-        double commission = wxOrder.getTotal() * 0.01;
-        double total = wxOrder.getTotal() - commission;
+        double commission = orderInfo.getTotal() * 0.01;
+        double total = orderInfo.getTotal() - commission;
         int amount = (int) Math.floor(total * 0.3);
         int amount = (int) Math.floor(total * 0.3);
 
 
         Map<String, Object> receiverMap = new TreeMap<String, Object>();
         Map<String, Object> receiverMap = new TreeMap<String, Object>();
@@ -194,17 +192,20 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
             //throw new CustomException("微信分账出错");
             //throw new CustomException("微信分账出错");
             log.info("微信分账出错");
             log.info("微信分账出错");
             log.info(resMap.toString());
             log.info(resMap.toString());
+            orderInfo.setProfitSharing(3);
+            orderInfoService.updateById(orderInfo);
             return false;
             return false;
         }
         }
         //更新成交订单表
         //更新成交订单表
-        OrderInfo orderInfo = orderInfoService.getByOutTradeNo(wxOrder.getOutTradeNo());
+       // OrderInfo orderInfo = orderInfoService.getByOutTradeNo(wxOrder.getOutTradeNo());
         orderInfo.setOutSplitNo(orderCode);
         orderInfo.setOutSplitNo(orderCode);
+        orderInfo.setProfitSharing(2);
         orderInfoService.updateById(orderInfo);
         orderInfoService.updateById(orderInfo);
         OrderSplit orderSplit = new OrderSplit();
         OrderSplit orderSplit = new OrderSplit();
         orderSplit.setOutSplitNo(orderCode);
         orderSplit.setOutSplitNo(orderCode);
         orderSplit.setAmount(amount);
         orderSplit.setAmount(amount);
-        //  orderSplit.setOpenId("o7N3j5XxUrgOKE4ulP-HseFpBCiM");
-        orderSplit.setOpenId("obYLX6C7ln62silx-KP73Nd9jUB0");
+
+        orderSplit.setOpenId(account);
         orderSplit.setDescription("分到个人");
         orderSplit.setDescription("分到个人");
         return orderSplitService.save(orderSplit);
         return orderSplitService.save(orderSplit);
     }
     }
@@ -325,40 +326,17 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
         return resMap.get("return_msg");
         return resMap.get("return_msg");
     }
     }
 
 
-    @Override
-    public List<WxOrder> selectWxOrderByWaitProfit() {
-
-        // 获取当前时间
-        Date currentDate = new Date();
-        // 添加5分钟
-        long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
-        Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
-
-        WxOrderProfitDTO wxOrderProfitDTO = new WxOrderProfitDTO();
-
-        String nowDateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", nowDate);
-
-        wxOrderProfitDTO.setNowDate(nowDateStr);
-        List<WxOrder> wxOrderList = wxOrderMapper.selectWxOrderByWaitProfit(nowDateStr);
-        return wxOrderList;
-    }
-
 
 
-    @Override
-    public List<WxOrder> selectWxOrderProfitList(WxOrderShareProfitDTO orderShareProfitDTO) {
-        List<WxOrder> wxOrderList = wxOrderMapper.selectWxOrderProfitList(orderShareProfitDTO);
-        return wxOrderList;
-    }
 
 
 
 
     /**
     /**
      * 查询出上级unionId
      * 查询出上级unionId
-     * @param wxOrder
+     * @param orderInfo
      * @return
      * @return
      */
      */
-    private String getAccount(WxOrder wxOrder) {
+    private String getAccount(OrderInfo orderInfo) {
         String account = null;
         String account = null;
-        UserInfo userInfo = sysUserService.getStudentByUnionId(wxOrder.getUnionId());
+        UserInfo userInfo = sysUserService.getStudentByUnionId(orderInfo.getUnionId());
         UserInfo pUserInfo = null;
         UserInfo pUserInfo = null;
         if (userInfo.getPUnionId() != null) {
         if (userInfo.getPUnionId() != null) {
             pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());
             pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());

+ 21 - 5
nbjk-service/src/main/resources/mapper/order/OrderInfoMapper.xml

@@ -13,10 +13,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="appOpenid"    column="app_openid"    />
         <result property="appOpenid"    column="app_openid"    />
         <result property="xcxOpenid"    column="xcx_openid"    />
         <result property="xcxOpenid"    column="xcx_openid"    />
         <result property="gzhOpenid"    column="gzh_openid"    />
         <result property="gzhOpenid"    column="gzh_openid"    />
+        <result property="transactionId"    column="transaction_id"    />
         <result property="outTradeNo"    column="out_trade_no"    />
         <result property="outTradeNo"    column="out_trade_no"    />
         <result property="outSplitNo"    column="out_split_no"    />
         <result property="outSplitNo"    column="out_split_no"    />
         <result property="outRefundNo"    column="out_refund_no"    />
         <result property="outRefundNo"    column="out_refund_no"    />
         <result property="total"    column="total"    />
         <result property="total"    column="total"    />
+        <result property="splitPrice"    column="split_price"    />
+        <result property="profitSharing"    column="profit_sharing"    />
         <result property="tradeType"    column="trade_type"    />
         <result property="tradeType"    column="trade_type"    />
         <result property="successTime"    column="success_time"    />
         <result property="successTime"    column="success_time"    />
         <result property="payType"    column="pay_type"    />
         <result property="payType"    column="pay_type"    />
@@ -31,24 +34,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select * from order_info
         select * from order_info
     </sql>
     </sql>
 
 
-    <select id="selectOrderInfoList" parameterType="OrderInfoDto" resultMap="OrderInfoResult">
+    <select id="selectOrderInfoList" parameterType="com.miaxis.order.dto.OrderInfoDto" resultMap="OrderInfoResult">
         <include refid="selectOrderInfoVo"/>
         <include refid="selectOrderInfoVo"/>
         <where>
         <where>
             <if test="goodsId != null "> and goods_id = #{goodsId}</if>
             <if test="goodsId != null "> and goods_id = #{goodsId}</if>
             <if test="goodsName != null  and goodsName != ''"> and goods_name = #{goodsName}</if>
             <if test="goodsName != null  and goodsName != ''"> and goods_name = #{goodsName}</if>
             <if test="outTradeNo != null  and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
             <if test="outTradeNo != null  and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
-            <if test="outRefundNo != null and outRefundNo != '' "> and status = #{status}</if>
+            <if test="outRefundNo != null and outRefundNo != '' "> and out_refund_no = #{out_refund_no}</if>
+            <if test="outSplitNo != null and outSplitNo != '' "> and out_split_no = #{outSplitNo}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="total != null "> and total = #{total}</if>
             <if test="tradeType != null and tradeType != ''  "> and trade_type = #{tradeType}</if>
             <if test="tradeType != null and tradeType != ''  "> and trade_type = #{tradeType}</if>
             <if test="unionId != null and unionId != ''  "> and union_id = #{unionId}</if>
             <if test="unionId != null and unionId != ''  "> and union_id = #{unionId}</if>
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="userId != null "> and user_id = #{userId}</if>
-
+            <if test="profitSharing != null">
+                and profit_sharing = #{profitSharing }
+            </if>
 
 
             <if test="startTime != null and startTime != '' ">
             <if test="startTime != null and startTime != '' ">
-                and DATE_FORMAT(success_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{startTime}
+                and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ >= ]]> #{startTime}
             </if>
             </if>
             <if test="endTime != null and endTime != '' ">
             <if test="endTime != null and endTime != '' ">
-                and DATE_FORMAT(success_time, '%Y-%m-%d') <![CDATA[ <= ]]> #{endTime}
+                and DATE_FORMAT(success_time, '%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{endTime}
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>
@@ -58,5 +64,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
     </select>
 
 
 
 
+    <select id="selectOrderInfoByWaitProfit" resultType="com.miaxis.order.domain.OrderInfo">
+        select * from order_info where trade_type = 1 and profit_sharing = 1
+        <if test="nowDate != null"><!-- 开始时间检索 -->
+            and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ <= ]]> #{nowDate}
+        </if>
+        order by success_time
+    </select>
+
+
+
 
 
 </mapper>
 </mapper>

+ 0 - 16
nbjk-service/src/main/resources/mapper/wx/WxOrderMapper.xml

@@ -139,22 +139,6 @@
     </select>
     </select>
 
 
 
 
-    <select id="selectWxOrderProfitList" resultType="com.miaxis.wx.domain.WxOrder">
-        select * from wx_order where trade_state = 'SUCCESS'
-        <if test="profitSharing != null">
-            and profit_sharing = #{profitSharing }
-        </if>
-        <if test="outTradeNo != null  and outTradeNo != ''">
-            and out_trade_no = #{outTradeNo }
-        </if>
-        <if test="startTime != null and startTime != '' " >
-            and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S')<![CDATA[ >= ]]> #{startTime}
-        </if>
-        <if test="endTime != null and endTime != '' ">
-            and DATE_FORMAT(success_time,'%Y-%m-%d %H:%i:%S') <![CDATA[ < ]]> #{endTime}
-        </if>
 
 
-        order by success_time desc
-    </select>
 
 
 </mapper>
 </mapper>