| 
					
				 | 
			
			
				@@ -1,7 +1,6 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.zanxiang.sdk.service.Impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.common.enums.CpStatusEnum; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -12,7 +11,7 @@ import com.zanxiang.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.common.utils.URIUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.module.util.JsonUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.mybatis.entity.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import com.zanxiang.sdk.domain.dto.GamePayWayDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.zanxiang.sdk.domain.dto.PayMerchantDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.sdk.domain.dto.PlatformOrderDTO; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.sdk.domain.result.PushCpResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.zanxiang.sdk.service.*; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,7 +25,6 @@ import org.springframework.web.client.RestTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Date; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Objects; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,9 +55,6 @@ public class PerformOrderServiceImpl implements PerformOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private UserService userService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private GamePayWayService gamePayWayService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private PayMerchantService payMerchantService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -150,25 +145,24 @@ public class PerformOrderServiceImpl implements PerformOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Boolean checkIsFirstRecharge(PlatformOrderDTO orderInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("订单:{} 检查更新用户是否为首充 ----------start---------", orderInfo.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean checkIsFirstRecharge(PlatformOrderDTO platformOrderDTO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("订单:{} 检查更新用户是否为首充 ----------start---------", platformOrderDTO.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Order one = orderService.getOne(new QueryWrapper<Order>().lambda() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(Order::getUserId, orderInfo.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            int count = orderService.count(new LambdaQueryWrapper<Order>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(Order::getUserId, platformOrderDTO.getUserId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .eq(Order::getStatus, OrderStateEnum.SUCCESS.getCode()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .ne(Order::getOrderId, orderInfo.getOrderId()).last("limit 1")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (Objects.isNull(one)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Order order = new Order(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order.setOrderId(order.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order.setIsFirstRecharge(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                orderService.updateById(order); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.info("订单:{} 验证订单是否为首充成功", orderInfo.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .ne(Order::getOrderId, platformOrderDTO.getOrderId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (count <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                orderService.update(new LambdaUpdateWrapper<Order>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .set(Order::getIsFirstRecharge, 1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .eq(Order::getOrderId, platformOrderDTO.getOrderId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("订单:{} 验证订单是否为首充成功", platformOrderDTO.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return Boolean.TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.error("订单:{} 验证订单是否为首充失败 e:{}", orderInfo.getOrderId(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("订单:{} 验证订单是否为首充失败 e:{}", platformOrderDTO.getOrderId(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return Boolean.FALSE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -229,43 +223,22 @@ public class PerformOrderServiceImpl implements PerformOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public Boolean payMerchantTotal(PlatformOrderDTO orderInfo) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        log.info("订单:{} 更新商户号统计 ----------start---------", orderInfo.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public Boolean payMerchantTotal(PlatformOrderDTO platformOrderDTO) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        log.info("订单:{} 更新商户号统计 ----------start---------", platformOrderDTO.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (orderInfo.getGamePaywayId() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.error("订单:{} 更新商户号统计时,该订单GamePaywayId为空", orderInfo.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            GamePayWay gamePayWayInfo = gamePayWayService.getInfo(String.valueOf(orderInfo.getGamePaywayId())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            GamePayWayDTO gamePayWayDTO = gamePayWayService.getById(orderInfo.getGamePaywayId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (Objects.isNull(gamePayWayDTO)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                log.error("订单:{} 更新商户号统计时,获取GamePayway表id:{}信息为空", orderInfo.getOrderId(), orderInfo.getGamePaywayId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //todo : 商户统计要修改 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            if (gamePayWayInfo.getPayMerchantId() <= 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                log.error("订单:{} 更新商户号统计时,获取GamePayway表id:{}信息中PayMerchantId为空", orderInfo.getOrderId(), orderInfo.getGamePaywayId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            PayMerchant payMerchantInfo = payMerchantService.getById(gamePayWayInfo.getPayMerchantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            if (Objects.isNull(payMerchantInfo)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                log.error("订单:{} 更新商户号统计时,获取PayMerchant表id:{}信息为空", orderInfo.getOrderId(), gamePayWayInfo.getPayMerchantId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//                return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            PayMerchant payMerchantInfo = payMerchantService.getOne(new LambdaQueryWrapper<PayMerchant>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .eq(PayMerchant::getMerchantNo, gamePayWayDTO.getMerchantNo())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal amount = orderInfo.getAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //根据订单中的商户id获取商户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            PayMerchantDTO payMerchantInfo = payMerchantService.getByMerchantNo(platformOrderDTO.getMerchantNo()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //商户额度数据统计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal amount = platformOrderDTO.getAmount(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             LocalDateTime updateTime = payMerchantInfo.getDayUpdateDate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Date date = new Date(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            LocalDateTime dateTime = LocalDateTime.now(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             String totalPayAmount, mouthPayAmount, weakerPayAmount, dayPayAmount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //累计 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             totalPayAmount = " total_pay_amount = total_pay_amount + " + amount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mouthPayAmount = " mouth_pay_amount = mouth_pay_amount + " + amount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             weakerPayAmount = " weaker_pay_amount = weaker_pay_amount + " + amount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             dayPayAmount = " day_pay_amount = day_pay_amount + " + amount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //统计过期限, 重新赋值 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (updateTime != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 if (!DateUtils.isThisMonth(payMerchantInfo.getMouthUpdateDate())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     mouthPayAmount = " mouth_pay_amount = " + amount; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -277,21 +250,22 @@ public class PerformOrderServiceImpl implements PerformOrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     dayPayAmount = " day_pay_amount = " + amount; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            payMerchantService.update(new UpdateWrapper<PayMerchant>().lambda() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .set(PayMerchant::getMouthUpdateDate, date) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .set(PayMerchant::getWeakerUpdateDate, date) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .set(PayMerchant::getDayUpdateDate, date) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //更新商户表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            payMerchantService.update(new LambdaUpdateWrapper<PayMerchant>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .set(PayMerchant::getMouthUpdateDate, dateTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .set(PayMerchant::getWeakerUpdateDate, dateTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .set(PayMerchant::getDayUpdateDate, dateTime) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setSql(totalPayAmount) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setSql(mouthPayAmount) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setSql(weakerPayAmount) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     .setSql(dayPayAmount) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    .setEntity(payMerchantInfo) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    .eq(PayMerchant::getMerchantNo, platformOrderDTO.getMerchantNo()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.info("订单:{} 更新商户号统计 ----------end---------", orderInfo.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.info("订单:{} 更新商户号统计 ----------end---------", platformOrderDTO.getOrderId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return Boolean.TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            log.error("订单:{} 更新商户号统计失败 e:{}", orderInfo.getOrderId(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("订单:{} 更新商户号统计异常 e:{}", platformOrderDTO.getOrderId(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return Boolean.FALSE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |