فهرست منبع

Merge remote-tracking branch 'origin/master'

秦国才 4 سال پیش
والد
کامیت
8fcb093228

+ 4 - 0
common/fire-common/src/main/java/com/fire/common/constants/RocketTags.java

@@ -30,6 +30,10 @@ public class RocketTags {
      * 失败订单 修改 order状态 失败
      */
     public static final String FAIL_TAG = "fail";
+    /**
+     * 订单回调 修改 order回调状态 失败
+     */
+    public static final String CALLBACK_TAG = "callback";
     /**
      * 成功订单 修改 order状态 成功
      */

+ 2 - 0
common/fire-dto/src/main/java/com/fire/dto/CustomerInfo.java

@@ -76,6 +76,8 @@ public class CustomerInfo {
     @ApiModelProperty(value = "修改时间")
     private String updateTime;
 
+    @ApiModelProperty(value = "代理商提成比例(按照面额计算)")
+    private BigDecimal partnerCommission;
 
     @ApiModelProperty(value = "跟用户关联,客户登录使用")
     private Long userId;

+ 8 - 0
common/fire-dto/src/main/java/com/fire/dto/FlowOrderInfo.java

@@ -3,15 +3,23 @@ package com.fire.dto;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.util.Date;
 
 @ApiModel(value = "订单记录表实体")
 @Data
 @TableName("flow_order_info")
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
 public class FlowOrderInfo {
 
     @ApiModelProperty(value = "接入ID号")

+ 0 - 2
common/fire-dto/src/main/java/com/fire/dto/PartnerUserInfo.java

@@ -31,7 +31,5 @@ public class PartnerUserInfo {
     @NotNull(message = "用户名称为空")
     private String partnerName;
 
-    @ApiModelProperty(value = "代理商提成比例(按照面额计算)")
-    private BigDecimal partnerCommission;
 
 }

+ 26 - 0
common/fire-dto/src/main/java/com/fire/dto/enums/DeleteStatus.java

@@ -0,0 +1,26 @@
+package com.fire.dto.enums;
+
+public enum DeleteStatus {
+
+    //系统
+    NOT_DELETE(0, "未删除"),
+    IS_DELETE(1, "删除");
+
+    private final Integer status;
+
+    private final String message;
+
+    DeleteStatus(Integer status, String message) {
+        this.status = status;
+        this.message = message;
+    }
+
+    public Integer status() {
+        return status;
+    }
+
+    public String message() {
+        return message;
+    }
+
+}

+ 3 - 0
modules/admin/src/main/java/com/fire/admin/dto/CustomerDto.java

@@ -87,4 +87,7 @@ public class CustomerDto {
     @ApiModelProperty("中间人集合")
     private List<PartnerUserInfo> partnerUsers;
 
+    @ApiModelProperty(value = "代理商提成比例(按照面额计算)")
+    private BigDecimal partnerCommission;
+
 }

+ 6 - 3
modules/admin/src/main/java/com/fire/admin/service/impl/AdditionalPaymentServiceImpl.java

@@ -79,7 +79,7 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
         // TODO 获取当前操作的人的用户名
         String username = SecurityUtil.getUser().getUsername();
 
-        if (additionalPaymentDto.getType().equals("customer")) {
+        if (additionalPaymentDto.getType().equals("customer") && additionalPaymentDto.getAmount().longValue() > 0) {
             additionalPaymentDto.setId(jedisCluster.incr(GLOBAL_ID_INCR.key()));
             additionalPaymentDto.setDistinguish(2);
 
@@ -101,7 +101,7 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
             Long amount = redisAmountScript.changeAmount(CUSTOMER_AMOUNT.key(), Long.parseLong(additionalPaymentDto.getRelationId()), "add", additionalPaymentDto.getAmount().multiply(new BigDecimal(10000)).longValue(), 0L);
 
             if (count > 0 && ObjectUtil.isNotEmpty(amount)) {
-                log.info("客户加款成功,客户编号为:【{}】,客户名称为:【{}】,加款金额为:【{}】", additionalPaymentDto.getRelationId(),param.get("name"), additionalPaymentDto.getAmount());
+                log.info("客户加款成功,客户编号为:【{}】,客户名称为:【{}】,加款金额为:【{}】", additionalPaymentDto.getRelationId(), param.get("name"), additionalPaymentDto.getAmount());
                 log.info("加款入流水队列,加款之前的金额为:【{}】,操作金额为:【{}】,加款之后的金额为:【{}】,详情为:【{}】", new BigDecimal(param.get("beforeAmount").toString()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), additionalPaymentDto.getAmount(), new BigDecimal(param.get("afterAmount").toString()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), param);
                 rocketMQTemplate.syncSend(TRANSACTION_TOPIC, MessageBuilder.withPayload(param).build());
             } else {
@@ -123,6 +123,9 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
                 log.info("供应商加款失败,编号为:【{}】的加款记录将被删除,供应商编号为:【{}】,加款金额为:【{}】", additionalPaymentDto.getId(), additionalPaymentDto.getRelationId(), additionalPaymentDto.getAmount());
                 baseMapper.deleteById(additionalPaymentDto.getId());
             }
+        }else {
+            log.info("加款金额参数不合符");
+            throw new BaseException("577","加款金额参数不合法");
         }
 
     }
@@ -303,7 +306,7 @@ public class AdditionalPaymentServiceImpl extends ServiceImpl<AdditionalPaymentM
                     // TODO 获取撤销的具体金额
                     BigDecimal canceprice = additionalPaymentDto.getAmount().divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN);
                     log.info("客户款项撤销入流水队列,撤销之前的金额为:【{}】,操作金额为:【{}】,撤销之后的金额为:【{}】,详情为:【{}】", new BigDecimal(param.get("beforeAmount").toString()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), canceprice, new BigDecimal(param.get("afterAmount").toString()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), param);
-                    log.info("客户款项撤销。 客户编号为:【{}】,客户名称为:【{}】 撤销金额为:【{}】 ,授信额度为:【{}】 剩余额度为:【{}】", payment.getRelationId(),param.get("name"), canceprice, new BigDecimal(customerInfo.getCreditAmount()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), new BigDecimal(amount).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN));
+                    log.info("客户款项撤销。 客户编号为:【{}】,客户名称为:【{}】 撤销金额为:【{}】 ,授信额度为:【{}】 剩余额度为:【{}】", payment.getRelationId(), param.get("name"), canceprice, new BigDecimal(customerInfo.getCreditAmount()).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN), new BigDecimal(amount).divide(new BigDecimal(10000)).setScale(4, RoundingMode.DOWN));
                     rocketMQTemplate.syncSend(TRANSACTION_TOPIC, MessageBuilder.withPayload(param).build());
                     return payment.getRelationId().concat("_").concat(amount.toString());
                 } else {

+ 3 - 0
modules/admin/src/main/java/com/fire/admin/vo/CustomerInfoVo.java

@@ -115,6 +115,9 @@ public class CustomerInfoVo {
     @ApiModelProperty(value = "客户登录名称")
     private String loginName;
 
+    @ApiModelProperty(value = "代理商提成比例(按照面额计算)")
+    private BigDecimal partnerCommission;
+
     @ApiModelProperty("银行卡列表")
     private List<BankCard> bankCards;
 

+ 3 - 0
modules/admin/src/main/resources/mapper/CustomerMapper.xml

@@ -23,6 +23,7 @@
         <result column="update_time" property="updateTime"/>
         <result column="user_id" property="userId"/>
         <result column="price_check" property="priceCheck"/>
+        <result column="partner_commission" property="partnerCommission"/>
     </resultMap>
 
 
@@ -55,6 +56,7 @@
         <result column="channel_id" property="channelId"/>
         <result column="price_check" property="priceCheck"/>
         <result column="user_id" property="userId"/>
+        <result column="partner_commission" property="partnerCommission"/>
         <!-- 获取客户登录用户姓名 -->
         <collection property="loginName" ofType="java.lang.String"
                     select="com.fire.admin.mapper.SysUserMapper.getCustomerUserName"
@@ -83,6 +85,7 @@
         c.updator,
         c.update_time,
         c.price_check,
+        c.partner_commission,
         c.user_id,
         app.flow_app_id,
         app.app_id,

+ 2 - 5
modules/admin/src/main/resources/mapper/PartnerUserMapper.xml

@@ -7,25 +7,22 @@
         <result column="customer_id" property="customerId"/>
         <result column="user_id" property="userId"/>
         <result column="partner_name" property="partnerName"/>
-        <result column="partner_commission" property="partnerCommission"/>
     </resultMap>
 
 
 <insert id="insertUpdateBeatchPartnerUserInfo" parameterType="java.util.List">
     INSERT  INTO
     partner_user_info
-    (customer_id,user_id,partner_name,partner_commission)
+    (customer_id,user_id,partner_name)
     VALUE
     <foreach collection="list" item="item" index="index" separator=",">
         (
             #{item.customerId},
             #{item.userId},
-            #{item.partnerName},
-            #{item.partnerCommission}
+            #{item.partnerName}
         )
     </foreach>
     ON DUPLICATE KEY UPDATE
-    partner_commission=VALUES(partner_commission);
 
 </insert>
 

+ 19 - 0
modules/callback-customer/src/main/java/com/fire/customer/callback/service/OrderUpdateService.java

@@ -0,0 +1,19 @@
+package com.fire.customer.callback.service;
+
+
+import com.fire.dto.FlowOrderInfo;
+import com.fire.dto.MobileFlowDispatchRec;
+
+/**
+ * 客户服务层
+ *
+ * @author ZJQ 2021年6月17日15:51:14
+ */
+public interface OrderUpdateService {
+
+    /**
+     * 订单更新redis 和发送更新消息
+     */
+    void updateOrder(FlowOrderInfo orderInfo, String tag);
+
+}

+ 21 - 1
modules/callback-customer/src/main/java/com/fire/customer/callback/service/impl/CallbackCustomerServiceImpl.java

@@ -1,11 +1,13 @@
 package com.fire.customer.callback.service.impl;
 
 
+import com.fire.common.exception.BaseException;
 import com.fire.customer.callback.data.DataPool;
 import com.fire.customer.callback.dto.CallbackRequestContent;
 import com.fire.customer.callback.dto.CallbackRequestMsgBody;
 import com.fire.customer.callback.dto.CallbackRequestParam;
 import com.fire.customer.callback.service.CallbackCustomerService;
+import com.fire.customer.callback.service.OrderUpdateService;
 import com.fire.dto.FlowAppInfo;
 import com.fire.dto.FlowOrderInfo;
 import com.fire.param.HeaderDto;
@@ -17,6 +19,11 @@ import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import java.nio.charset.StandardCharsets;
+import java.util.Date;
+
+import static com.fire.common.constants.RocketTags.CALLBACK_TAG;
+import static com.fire.dto.enums.OrderStatus.ORDER_FAIL;
+import static com.fire.dto.enums.OrderStatus.ORDER_SUCCESS;
 
 /**
  * 向客户回调
@@ -29,6 +36,8 @@ public class CallbackCustomerServiceImpl implements CallbackCustomerService {
 
     @Resource
     private RestTemplate restTemplate;
+    @Resource
+    private OrderUpdateService orderUpdateService;
 
     @Override
     public void callbackCustomer(FlowOrderInfo orderInfo) {
@@ -65,7 +74,18 @@ public class CallbackCustomerServiceImpl implements CallbackCustomerService {
         String secretKey = DigestUtils.md5DigestAsHex(secretStr.getBytes(StandardCharsets.UTF_8));
         header.setSecretKey(secretKey);
 
-        restTemplate.postForObject(flowAppInfo.getCallbackUrl(), requestParam, String.class);
+        orderInfo.setCallbackTime(new Date());
+        try {
+            restTemplate.postForObject(flowAppInfo.getCallbackUrl(), requestParam, String.class);
+            orderInfo.setCallbackStatus(ORDER_SUCCESS.status());
+            orderUpdateService.updateOrder(orderInfo,CALLBACK_TAG);
+        } catch (Exception e) {
+            orderInfo.setCallbackStatus(ORDER_FAIL.status());
+            orderUpdateService.updateOrder(orderInfo,CALLBACK_TAG);
+            log.error("回调客户失败:", e);
+            throw new BaseException("回调失败");
+        }
+
 
     }
 }

+ 62 - 0
modules/callback-customer/src/main/java/com/fire/customer/callback/service/impl/OrderUpdateServiceImpl.java

@@ -0,0 +1,62 @@
+package com.fire.customer.callback.service.impl;
+
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fire.customer.callback.service.OrderUpdateService;
+import com.fire.dto.FlowOrderInfo;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
+import org.springframework.messaging.MessagingException;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Service;
+import redis.clients.jedis.JedisCluster;
+
+import javax.annotation.Resource;
+
+import static com.fire.common.constants.RocketTopic.ORDER_TOPIC;
+import static com.fire.dto.enums.RedisKey.ORDER_INFO;
+
+/**
+ * 订单更新实现层
+ *
+ * @author ZJQ 2021年6月16日17:13:54
+ */
+@Service
+@Slf4j
+public class OrderUpdateServiceImpl implements OrderUpdateService {
+
+    @Resource
+    private JedisCluster jedisCluster;
+    @Resource
+    private RocketMQTemplate rocketMQTemplate;
+
+    /**
+     * 订单更新
+     *
+     * @param orderInfo 订单详情
+     * @param tag       mq的tag
+     */
+    @Override
+    public void updateOrder(FlowOrderInfo orderInfo, String tag) {
+        Long orderId = orderInfo.getOrderId();
+        //如果订单失败 客户退款
+
+        String orderStr;
+        ObjectMapper om = new ObjectMapper();
+        try {
+            orderStr = om.writeValueAsString(orderInfo);
+            //订单转换为json更新入redis
+            long hKey = orderId / 10000000;
+            jedisCluster.hset(ORDER_INFO.key() + hKey, String.valueOf(orderId), orderStr);
+            //订单入队列
+            rocketMQTemplate.syncSendOrderly(ORDER_TOPIC + ":" + tag, MessageBuilder.withPayload(orderStr).build(), String.valueOf(orderId));
+        } catch (JsonProcessingException e) {
+            //订单转换的其他异常 如果执行到这里说明系统有bug
+            log.error("订单在更新回调状态的时候转换成json失败:", e);
+        } catch (MessagingException e1) {
+            log.error("订单在更新回调的时候发送失败:", e1);
+        }
+    }
+
+}

+ 2 - 0
modules/distribution/src/main/resources/mapper/ChannelInfoMapper.xml

@@ -37,6 +37,8 @@
                b.weight
         from access_channel_info a
                  left join distribute_group_channel b on a.channel_id = b.channel_id
+                 left join channel_supplier c on a.supplier_id = c.supplier_id
+        where c.is_valid = 1
     </select>
 
     <sql id="baseSql">

+ 29 - 20
modules/make-order/src/main/java/com/fire/order/service/impl/MakeOrderServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.util.DigestUtils;
 import redis.clients.jedis.JedisCluster;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Date;
@@ -308,27 +309,35 @@ public class MakeOrderServiceImpl implements MakeOrderService {
             return responseDto;
         }
 
+        long partnerBalancePrice = 0L;
+        if (customerInfo.getPartnerCommission() != null) {
+            partnerBalancePrice = customerInfo.getPartnerCommission().multiply(new BigDecimal(product.getFacePrice())).longValue();
+        }
+
         //初始化订单详情
-        FlowOrderInfo order = new FlowOrderInfo();
-        order.setFlowAppId(flowAppInfo.getFlowAppId());
-        order.setOrderId(orderId);
-        order.setPackageId(product.getPackageId());
-        order.setCustomerId(flowAppInfo.getCustomerId());
-        order.setOrderType(product.getType());
-        order.setCustomerName(customerInfo.getCustomerName());
-        order.setPhoneNo(phoneNo);
-        order.setExtorderId(content.getExtOrder());
-        order.setApplyDate(new Date());
-        order.setStatus(ORDER_IN_QUEUE.status());
-        order.setFlowAmount(product.getFacePrice());
-        order.setAreaCode(product.getAreaNum());
-        order.setPrice(product.getPrice());
-        order.setProductId(product.getProductId());
-        order.setCustomerProductId(product.getCustomerProductId());
-        order.setPhoneOperator(product.getOperator());
-        order.setPhoneCity(phoneZone.getAreaCode());
-        order.setAppId(appId);
-        order.setPhoneHome(phoneZone.getProvince() + "-" + phoneZone.getCity());
+        FlowOrderInfo order = FlowOrderInfo.builder()
+                .flowAppId(flowAppInfo.getFlowAppId())
+                .orderId(orderId)
+                .packageId(product.getPackageId())
+                .customerId(flowAppInfo.getCustomerId())
+                .orderType(product.getType())
+                .customerName(customerInfo.getCustomerName())
+                .phoneNo(phoneNo)
+                .extorderId(content.getExtOrder())
+                .applyDate(new Date())
+                .status(ORDER_IN_QUEUE.status())
+                .flowAmount(product.getFacePrice())
+                .areaCode(product.getAreaNum())
+                .price(product.getPrice())
+                .productId(product.getProductId())
+                .customerProductId(product.getCustomerProductId())
+                .phoneOperator(product.getOperator())
+                .phoneCity(phoneZone.getAreaCode())
+                .appId(appId)
+                .phoneHome(phoneZone.getProvince() + "-" + phoneZone.getCity())
+                .partnerBalancePrice(partnerBalancePrice)
+                .build();
+
 
         //订单转换为json入redis
         String orderStr;

+ 1 - 0
modules/make-order/src/main/resources/mapper/CustomerInfoMapper.xml

@@ -22,6 +22,7 @@
         <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
         <result property="userId" column="user_id" jdbcType="BIGINT"/>
         <result property="priceCheck" column="price_check" jdbcType="INTEGER"/>
+        <result property="partnerCommission" column="partner_commission"/>
     </resultMap>
 
     <!--查询全部-->