zoujiajian 2 rokov pred
rodič
commit
3d107ab5e9

+ 18 - 0
netflix-dao/src/main/java/com/cyksj/model/request/ChannelPayReq.java

@@ -0,0 +1,18 @@
+package com.cyksj.model.request;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj2
+ * 文件名: ChannelPayReq
+ * 创建者: JavaZou
+ * 创建时间:2024/5/31 13:57
+ */
+@Getter
+@Setter
+public class ChannelPayReq {
+	private String wxShopId;
+
+	private String zfbShopId;
+}

+ 4 - 4
netflix-dao/src/main/resources/mapper/StatisticsExportMapper.xml

@@ -72,7 +72,7 @@
     </select>
 
     <select id="getMonthAiExNumOfUser" resultType="java.lang.Integer">
-        select count(distinct buyer_id)
+        select count(distinct user_id)
         from `order_don` od
         where status not in ('close','noPayment')
         and (refund_money is null or refund_money != money)
@@ -84,7 +84,7 @@
     </select>
 
     <select id="getMonthAiExNumOfUserByType" resultType="java.lang.Integer">
-        select count(distinct buyer_id) from (select buyer_id
+        select count(distinct user_id) from (select user_id
         from `order_don` od
         where status not in ('close','noPayment')
         and (refund_money is null or refund_money != money)
@@ -98,7 +98,7 @@
         and (refund_money is null or refund_money != money)
         and created_time between #{thisMonth} and #{nextMonth}
         and order_type = #{type}
-        and buyer_id = s.buyer_id
+        and user_id = s.user_id
         and sku_id in
         <foreach collection="skuIds" item="item" open="(" separator="," close=")">
             #{item}
@@ -107,7 +107,7 @@
     </select>
 
     <select id="getMonthAiRenewNumOfUser" resultType="java.lang.Integer">
-        select count(distinct buyer_id)
+        select count(distinct user_id)
         from `order_don` od
         where status not in ('close','noPayment')
         and (refund_money is null or refund_money != money)

+ 7 - 3
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -1078,7 +1078,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		String transactionId = params.get("trade_no");
 		String payTimeStr = params.get("gmt_payment");
 		//买家支付宝账号
-		String buyerId = params.get("buyer_id");
+		String buyerId = Optional.ofNullable(params.get("buyer_id")).orElse(params.get("buyer_open_id"));
 		log.info("支付宝回调信息:{}", Jsons.toJson(params));
 		if (!orderDon.getStatus().equals(OrderDon.Status.noPayment) && !orderDon.getStatus().equals(OrderDon.Status.close)) {
 			log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());
@@ -1102,7 +1102,6 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		orderDon.setPayTime(payTime);
 		orderDon.setShopId(appId);
 		orderDon.setType(OrderDon.Type.ALI_PAY);
-
 		orderDon.setBuyerId(buyerId);
 		//该支付账号id 是否被后台拉黑
 		Integer count1 = userPayOrderBlockMapper.selectCount(Wrappers.lambdaQuery(UserPayOrderBlock.class)
@@ -1968,6 +1967,11 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 					if ("TRADE_SUCCESS".equals(tradeStatus)) {
 						orderDon.setStatus(goodsDon.getType() == 1 && goodsDon.getSecondType() == 2 ? OrderDon.Status.complete : OrderDon.Status.hasPayment);
 						orderDon.setTransactionId(zfbOrderDetail.getTradeNo());
+						Date sendPayDate = zfbOrderDetail.getSendPayDate();
+						orderDon.setPayTime(sendPayDate);
+						//买家支付宝账号
+						String buyerId = Optional.ofNullable(zfbOrderDetail.getBuyerUserId()).orElse(zfbOrderDetail.getBuyerOpenId());
+						orderDon.setBuyerId(buyerId);
 						return updateNoPayment(orderDon, goodsDon);
 					}
 				}
@@ -3311,7 +3315,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		String transactionId = params.get("trade_no");
 		String payTimeStr = params.get("gmt_payment");
 		//买家支付宝账号
-		String buyerId = params.get("buyer_id");
+		String buyerId = Optional.ofNullable(params.get("buyer_id")).orElse(params.get("buyer_open_id"));
 		log.info("支付宝回调信息:{}", Jsons.toJson(params));
 		if (!orderDon.getStatus().equals(UpgradeOrderDon.Status.noPayment) && !orderDon.getStatus().equals(UpgradeOrderDon.Status.close)) {
 			log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());

+ 4 - 1
netflix-service/src/main/java/com/cyksj/service/pay/impl/TransferFuncServiceImpl.java

@@ -36,6 +36,7 @@ import com.cyksj.model.request.TransferAccountsReq;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.pay.TransferFuncService;
+import com.cyksj.service.sys.SysConfigService;
 import com.cyksj.service.user.UserBenefitsService;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -77,6 +78,8 @@ public class TransferFuncServiceImpl implements TransferFuncService {
 
 	private final RedisService redisService;
 
+	private final SysConfigService sysConfigService;
+
 	@Override
 	public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
 		applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
@@ -128,7 +131,7 @@ public class TransferFuncServiceImpl implements TransferFuncService {
 			name += "xx";
 		}
 		Integer scope = transferAccountsReq.getScope();
-		AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(ShopConfig.DISTRIBUTE_ZFB_DEFAULT_APP_ID);
+		AlipayClient alipayClient = AliPayClientFactory.getAlipayClient(sysConfigService.getDefaultShopConfigByType("zfb"));
 
 		AlipayRequest alipayRequest = aliPayTransferAccountsRequest(donNo, account, name, money, remark);
 

+ 2 - 1
netflix-service/src/main/java/com/cyksj/service/user/impl/UserPayOrderBlockServiceImpl.java

@@ -17,6 +17,7 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Optional;
 
 /**
  * 项目名: yhlxj
@@ -57,7 +58,7 @@ public class UserPayOrderBlockServiceImpl extends ServiceImpl<UserPayOrderBlockM
 				if (orderDon.getType() == OrderDon.Type.ALI_PAY) {
 					AlipayTradeQueryResponse zfbOrderDetail = orderDonService.getZfbOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
 					if (zfbOrderDetail != null) {
-						buyerId = zfbOrderDetail.getBuyerUserId();
+						buyerId = Optional.ofNullable(zfbOrderDetail.getBuyerUserId()).orElse(zfbOrderDetail.getBuyerOpenId());
 					}
 				}
 			}

+ 19 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/shop/ShopConfigController.java

@@ -1,11 +1,13 @@
 package com.cyksj.web.controller.manage.shop;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.dto.Result;
 import com.cyksj.enums.GatewayResponse;
 import com.cyksj.model.entity.Channel;
 import com.cyksj.model.entity.ShopConfig;
+import com.cyksj.model.request.ChannelPayReq;
 import com.cyksj.service.mange.channel.ChannelService;
 import com.cyksj.service.mange.shop.ShopConfigService;
 import com.ejlchina.searcher.BeanSearcher;
@@ -62,4 +64,21 @@ public class ShopConfigController {
         shopConfigService.removeById(id);
        return GatewayResponse.SUCCESS.newBuilder().toResult();
     }
+
+    /**
+     * 更换渠道支付方式
+     */
+    @PutMapping("/update/channel/pay")
+    @SaCheckPermission("merchant:updateChannelShop")
+    public Result<String> updateChannelPay(@RequestBody ChannelPayReq req) {
+        String wxShopId = req.getWxShopId();
+        String zfbShopId = req.getZfbShopId();
+        if (StrUtil.isAllEmpty(wxShopId, zfbShopId)) {
+            return GatewayResponse.SUCCESS.newBuilder().toResult();
+        }
+        channelService.update(Wrappers.lambdaUpdate(Channel.class)
+                .eq(StrUtil.isNotBlank(wxShopId), Channel::getWxShopId, wxShopId)
+                .eq(StrUtil.isNotBlank(zfbShopId), Channel::getZfbShopId, zfbShopId));
+        return GatewayResponse.SUCCESS.newBuilder().toResult();
+    }
 }