zhangbin 1 год назад
Родитель
Сommit
f02004ea92

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

@@ -75,11 +75,11 @@ public class PcOrderInfoController extends BaseController {
         // 获取当前时间
         Date currentDate = new Date();
         // 添加5分钟
-        long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
+        long fiveMinutesInMillis = 1 * 60 * 1000; // 1分钟的毫秒数
         Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
 
         if (nowDate.compareTo(orderInfo.getSuccessTime()) < 0) {
-            Response response = new Response(200, "支付成功的订单,未满5分钟无法分账,请稍后操作。");
+            Response response = new Response(200, "支付成功的订单,未满1分钟无法分账,请稍后操作。");
             return response;
         }
 

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

@@ -66,7 +66,7 @@ public class AppAdJob {
     }
 
 
-    //@Scheduled(cron = "0 0/5 * * * ?")
+    @Scheduled(cron = "0 0/5 * * * ?")
     public void wxProfitsharing()  {
         log.info("--------现在开始执行每1分钟一次的微信分帐!~---------------");
 

+ 2 - 8
nbjk-service/src/main/java/com/miaxis/order/domain/OrderInfo.java

@@ -106,17 +106,11 @@ public class OrderInfo extends BaseBusinessEntity{
     @ApiModelProperty(value = "总金额")
     private Integer total;
 
-    /** 分账金额 */
-    @Excel(name = "分账金额")
-    @TableField("split_price")
-    @ApiModelProperty(value = "分账金额")
-    private Integer splitPrice;
 
-
-    /** 分账状态 0 不分帐 1待分账  2分账失败  3分账完成 */
+    /** 分账状态 0 不分帐 1待分账  2分账成功  3分账失败 */
     @Excel(name = "分账状态")
     @TableField("profit_sharing")
-    @ApiModelProperty(value = "分账状态 0 不分帐 1待分账  2分账失败  3分账完成")
+    @ApiModelProperty(value = "分账状态 0 不分帐 1待分账  2分账成功  3分账失败")
     private Integer profitSharing;
 
     /** 交易状态 1、支付成功2、支付失败*/

+ 2 - 2
nbjk-service/src/main/java/com/miaxis/wx/dto/WxOrderProfitDTO.java → nbjk-service/src/main/java/com/miaxis/order/dto/OrderInfoProfitDto.java

@@ -1,4 +1,4 @@
-package com.miaxis.wx.dto;
+package com.miaxis.order.dto;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -6,7 +6,7 @@ import lombok.Data;
 import java.util.Date;
 
 @Data
-public class WxOrderProfitDTO {
+public class OrderInfoProfitDto {
     private static final long serialVersionUID = 1L;
 
 

+ 3 - 4
nbjk-service/src/main/java/com/miaxis/order/service/impl/OrderInfoServiceImpl.java

@@ -14,8 +14,7 @@ import com.miaxis.vip.domain.VipUserExam;
 import com.miaxis.vip.service.IVipExamVideoService;
 import com.miaxis.vip.service.IVipUserExamService;
 import com.miaxis.wx.domain.WxOrder;
-import com.miaxis.wx.dto.WxOrderProfitDTO;
-import org.springframework.beans.BeanUtils;
+import com.miaxis.order.dto.OrderInfoProfitDto;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.cache.annotation.CacheConfig;
 import org.springframework.stereotype.Service;
@@ -143,10 +142,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
         // 获取当前时间
         Date currentDate = new Date();
         // 添加5分钟
-        long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
+        long fiveMinutesInMillis = 1 * 60 * 1000; // 1分钟的毫秒数
         Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
 
-        WxOrderProfitDTO wxOrderProfitDTO = new WxOrderProfitDTO();
+        OrderInfoProfitDto wxOrderProfitDTO = new OrderInfoProfitDto();
 
         String nowDateStr = DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", nowDate);
 

+ 5 - 8
nbjk-service/src/main/java/com/miaxis/order/service/impl/OrderSplitServiceImpl.java

@@ -1,16 +1,13 @@
 package com.miaxis.order.service.impl;
 
-import java.util.List;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.miaxis.common.utils.DateUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.apache.commons.lang3.StringUtils;
-import com.miaxis.order.mapper.OrderSplitMapper;
 import com.miaxis.order.domain.OrderSplit;
+import com.miaxis.order.mapper.OrderSplitMapper;
 import com.miaxis.order.service.IOrderSplitService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
 
 /**
  * 分账记录Service业务层处理

+ 41 - 31
nbjk-service/src/main/java/com/miaxis/wx/service/impl/WxOrderServiceImpl.java

@@ -89,6 +89,12 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
     @Value("${xcx.appId}")
     private String xcxAppid;
 
+    @Value("${gzh.appId}")
+    private String gzhAppid;
+
+    @Value("${app.appId}")
+    private String appid;
+
     @Value("${xcx.mchId}")
     private String mchId;
 
@@ -97,26 +103,31 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
     @Transactional
     public boolean wxAddFenZhang(OrderInfo orderInfo) throws Exception {
         //查询上级
-        Map<String, Object> accountMap = getAccount(orderInfo);
         String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver";
 
         String nonceStr = RandomStringUtils.randomAlphanumeric(32);
         //用于签名
         Map<String, String> sortMap = new TreeMap<String, String>();
         sortMap.put("mch_id", mchId);
-        sortMap.put("appid", xcxAppid);
+
+        int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
+        if (foreType == 1) {
+            sortMap.put("appid", appid);
+        } else if (foreType == 2) {
+            sortMap.put("appid", xcxAppid);
+        } else if (foreType == 3) {
+            sortMap.put("appid", gzhAppid);
+        }
         sortMap.put("nonce_str", nonceStr);
         sortMap.put("sign_type", "HMAC-SHA256");
         Map<String, String> receiverMap = new TreeMap<String, String>();
         receiverMap.put("type", "PERSONAL_OPENID");
 
-        if (accountMap != null) {
-            String account = (String) accountMap.get("account");
-            if (StringUtils.isNotEmpty(account)) {  //如果存在上级,分给上给
-                receiverMap.put("account", account);
-            } else {                               //如果不存在上级,分给固定的
-                receiverMap.put("account", "o7N3j5XxUrgOKE4ulP-HseFpBCiM");
-            }
+        String account = getAccount(orderInfo);
+        if (StringUtils.isNotEmpty(account)) {  //如果存在上级,分给上给
+            receiverMap.put("account", account);
+        } else {                               //如果不存在上级,分给固定的
+            receiverMap.put("account", "o7N3j5XxUrgOKE4ulP-HseFpBCiM");
         }
 
         receiverMap.put("relation_type", "SERVICE_PROVIDER");  //合作合伙
@@ -156,7 +167,14 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
         //用于签名
         Map<String, String> sortMap = new TreeMap<String, String>();
         sortMap.put("mch_id", mchId);
-        sortMap.put("appid", xcxAppid);
+        int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
+        if (foreType == 1) {
+            sortMap.put("appid", appid);
+        } else if (foreType == 2) {
+            sortMap.put("appid", xcxAppid);
+        } else if (foreType == 3) {
+            sortMap.put("appid", gzhAppid);
+        }
         sortMap.put("nonce_str", nonceStr);
         sortMap.put("sign_type", "HMAC-SHA256");
         sortMap.put("transaction_id", orderInfo.getTransactionId());
@@ -171,13 +189,7 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
         receiverMap.put("type", "PERSONAL_OPENID");
 
         //获取上级
-        Map<String, Object> accountMap = getAccount(orderInfo);
-        String account = null;
-        Integer openIdType = null;
-        if (accountMap != null) {
-            account = (String) accountMap.get("account");
-            openIdType = (Integer) accountMap.get("openIdType");
-        }
+        String account = getAccount(orderInfo);
         if (StringUtils.isNotEmpty(account)) {  //如果存在上级,分给上给
             receiverMap.put("account", account);
         } else {                               //如果不存在上级,分给固定的
@@ -214,8 +226,8 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
         orderSplit.setOutTradeNo(orderInfo.getOutTradeNo());
         orderSplit.setAmount(amount);
         orderSplit.setOpenId(account);
-        if (openIdType!=null) {
-            orderSplit.setOpenIdType(openIdType);
+        if(account!=null) {
+            orderSplit.setOpenIdType(orderInfo.getForeType());
         } else {
             orderSplit.setOpenIdType(2);
         }
@@ -346,8 +358,8 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
      * @param orderInfo
      * @return
      */
-    private Map<String, Object> getAccount(OrderInfo orderInfo) {
-        Map<String, Object> resultMap = new HashMap<String, Object>();
+    private String getAccount(OrderInfo orderInfo) {
+        int foreType = orderInfo.getForeType(); //前端类型 1:app 2:小程序 3:公众号
 
         String account = null;
         UserInfo userInfo = sysUserService.getStudentByUnionId(orderInfo.getUnionId());
@@ -356,23 +368,21 @@ public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> impl
             pUserInfo = sysUserService.getStudentByUnionId(userInfo.getPUnionId());
         }
         if (pUserInfo != null) {
-            if (StringUtils.isNotEmpty(pUserInfo.getXcxOpenid())) {
+
+            if (foreType == 2 && StringUtils.isNotEmpty(pUserInfo.getXcxOpenid())) {
                 account = pUserInfo.getXcxOpenid();
-                resultMap.put("account", account);
-                resultMap.put("openIdType", 2);
-            } else if (StringUtils.isNotEmpty(pUserInfo.getGzhOpenid())) {
+                return account;
+            } else if (foreType == 3 && StringUtils.isNotEmpty(pUserInfo.getGzhOpenid())) {
                 account = pUserInfo.getGzhOpenid();
-                resultMap.put("account", account);
-                resultMap.put("openIdType", 3);
-            } else if (StringUtils.isNotEmpty(pUserInfo.getAppOpenid())) {
+                return account;
+            } else if (foreType == 1 && StringUtils.isNotEmpty(pUserInfo.getAppOpenid())) {
                 account = pUserInfo.getAppOpenid();
-                resultMap.put("account", account);
-                resultMap.put("openIdType", 1);
+                return account;
             } else {
                 return null;
             }
         }
-        return resultMap;
+        return null;
     }