jk-GitHub-coder 3 år sedan
förälder
incheckning
195f245b6b

+ 13 - 1
YijiaRestful/src/main/java/com/platform/yijia/controller/PayController.java

@@ -588,10 +588,22 @@ public class PayController {
                         logger.info("根据订单查询用户手机号等订单信息"+ infoMap.toString());
                         //手机号必须有
                         if(infoMap != null && infoMap.containsKey("mobilePhone") && infoMap.get("mobilePhone") !=null ){
-                            CustomerManage customerManage = this.insertCustomerManage(infoMap);                              //插入客户积分返回要插入客户的信息
+
                             StationInfo stationInfo = new StationInfo();
                             stationInfo.setStationId(Integer.valueOf(infoMap.get("stationId").toString()));
                             StationInfo stationInfos = stationService.selectStationInfo(stationInfo);
+                            //插入油站余额记录
+                            if(stationInfos.getIsLngFlagGroup() !=null && stationInfos.getIsLngFlagGroup().equals("1")){
+                                StationBalanceChange stationBalanceChange = new StationBalanceChange();
+                                stationBalanceChange.setStationId(stationInfos.getStationId());
+                                stationBalanceChange.setAmt(Double.valueOf(infoMap.get("driverAmt").toString()));
+                                stationBalanceChange.setCreateTime(new SimpleDateFormat("yyyy-MM-dd hh-mm-ss").parse(infoMap.get("payDate").toString()));
+                                stationBalanceChange.setType("-");
+                                stationBalanceChange.setOrderNo(ordNo);
+                                payOrderService.insertStationBalanceExchange(stationBalanceChange);
+                            }
+
+                            CustomerManage customerManage = this.insertCustomerManage(infoMap);                              //插入客户积分返回要插入客户的信息
                             int integral =0;
                             CalculateIntegral calculateIntegral = new CalculateIntegral();
                             calculateIntegral.setOrderNo(ordNo);

+ 101 - 14
YijiaRestful/src/main/java/com/platform/yijia/controller/PayOrderController.java

@@ -86,6 +86,8 @@ public class PayOrderController {
                     payOrderRequest.setCustomerName(appUserInfos.getBlogNickName());                        //昵称
                     payOrderRequest.setGroupId(stationInfos.getGroupId());                                  //集团ID
                     payOrderRequest.setLabelFlag(stationInfos.getLabelFlag());                              //油站是否开启标签功能
+                    payOrderRequest.setIsLngFlagGroup(stationInfos.getIsLngFlagGroup());                    //该集团是否为LNG第三方平台商:0,否;1,是;
+
 
                     payOrder.setConsumer(appUserInfos.getBlogNickName());             //昵称
                     payOrder.setConsumerId(appUserInfos.getUserId());                 //用户id
@@ -169,6 +171,11 @@ public class PayOrderController {
                         resultMap.put("oilsCardFlag", payOrderResultInfo.getOilsCardFlag());
                         resultMap.put("discountAmt", payOrderResultInfo.getDiscountAmt());                                          //优惠价格
                         resultMap.put("amt", payOrderResultInfo.getAmt());                   //实收价格
+                        if(payOrderRequest.getIsLngFlagGroup() !=null && payOrderRequest.getIsLngFlagGroup().equals("1")){
+                            payOrder.setDriverAmt(Double.valueOf(payOrderResultInfo.getDriverAmt()));
+                            //此处amt赋值司机价支付金额原因:前端使用amt作为实际支付金额,返给前端司机价实收金额
+                            resultMap.put("amt", payOrderResultInfo.getDriverAmt());
+                        }
                         resultMap.put("receivableAmt", payOrderResultInfo.getReceivableAmt());         //应收价格
                         resultMap.put("oilLiters", payOrderResultInfo.getOilLiters());
                         resultMap.put("discountPrice", payOrderResultInfo.getDiscountPrice());
@@ -228,20 +235,26 @@ public class PayOrderController {
         params.put("cardOilsType", payOrderRequest.getCardOilsType());
         params.put("customerName", customerName);
         params.put("userPhone", userPhone);
-//      integralRuleFlagGroup;   //集团积分规则是否共享
-//      integralFlagGroup;       //集团是否开启积分功能
-//      cardRuleFlagGroup;       //集团是否共享电子卡充值规则
-//      cardEnabledFlagGroup;    //集团是否开启电子卡
-        params.put("integralRuleFlagGroup", payOrderRequest.getIntegralRuleFlagGroup());
-        params.put("integralFlagGroup", payOrderRequest.getIntegralFlagGroup());
-        params.put("cardRuleFlagGroup", payOrderRequest.getCardRuleFlagGroup());
-        params.put("cardEnabledFlagGroup", payOrderRequest.getCardEnabledFlagGroup());
+        params.put("integralRuleFlagGroup", payOrderRequest.getIntegralRuleFlagGroup());    //      integralRuleFlagGroup;   //集团积分规则是否共享
+        params.put("integralFlagGroup", payOrderRequest.getIntegralFlagGroup());            //      integralFlagGroup;       //集团是否开启积分功能
+        params.put("cardRuleFlagGroup", payOrderRequest.getCardRuleFlagGroup());            //      cardRuleFlagGroup;       //集团是否共享电子卡充值规则
+        params.put("cardEnabledFlagGroup", payOrderRequest.getCardEnabledFlagGroup());      //      cardEnabledFlagGroup;    //集团是否开启电子卡
+
+        if(payOrderRequest.getIsLngFlagGroup() !=null && payOrderRequest.getIsLngFlagGroup().equals("1")){
+            // isLngFlagGroup 表示该集团是否为LNG平台加气:0,否;1,是;
+           // settlementType:结算价类型(1.直降,2.折扣);  settlementPrice:结算价;  driverPrice:司机价;
+            if(result.containsKey("settlementType") && result.get("settlementType") !=null && result.get("settlementType").toString() !=""){
+                params.put("settlementType", result.get("settlementType").toString());
+            }
+            if(result.containsKey("settlementPrice") && result.get("settlementPrice") !=null && result.get("settlementPrice").toString() !=""){
+                params.put("settlementPrice", result.get("settlementPrice").toString());
+            }
+            if(result.containsKey("driverPrice") && result.get("driverPrice") !=null && result.get("driverPrice").toString() !=""){
+                params.put("driverPrice", result.get("driverPrice").toString());
+            }
+            payOrderResultInfo = this.calculateLngGroupStaDiscount(params);
 
-//        if(payOrderRequest.getLabelFlag() !=null && payOrderRequest.getLabelFlag().equals("1") && payOrderRequest.getLabelId() !=null && payOrderRequest.getLabelId() !=""){
-//            //如果前端传来labelId 表示使用一码一标签:标签支付码
-//            params.put("labelId", payOrderRequest.getLabelId());
-//            payOrderResultInfo = this.calculateLabelDiscount(params);
-//        }else {
+        }else {
             //按照正常优惠计算
             CustomerLabel customerLabel = new CustomerLabel();
             customerLabel.setPhone(payOrderRequest.getCustomerPhone());
@@ -271,10 +284,84 @@ public class PayOrderController {
                         break;
                 }
             }
-        //}
+        }
         return  payOrderResultInfo;
     }
 
+    //计算集团下站点LNG平台加气
+    public PayOrderResultInfo calculateLngGroupStaDiscount(Map<String ,Object> params){
+
+        PayOrderResultInfo payOrderResultInfo = new PayOrderResultInfo();
+        BigDecimal oilPrice = new BigDecimal(params.get("oilPrice").toString());    //油品价格
+        BigDecimal receivableAmt = new BigDecimal(params.get("receivableAmt").toString());   //应收金额
+        BigDecimal oilLiters = new BigDecimal("0.00");  //加油升数
+        BigDecimal discountAmt = new BigDecimal(0);     //油站销售价后优惠金额
+        BigDecimal driverDiscountAmt = new BigDecimal(0);     //油站司机价后优惠金额
+        BigDecimal dzkDiscountAmt = new BigDecimal(0);  //电子卡优惠金额
+        BigDecimal amt = new BigDecimal(0);             //油站结算价支付金额
+        BigDecimal driverAmt = new BigDecimal(0);       //司机价后支付金额
+        BigDecimal discountPrice = oilPrice;                //油站销售价
+        BigDecimal driverPrice = discountPrice;             //司机销售价
+        //加油升数
+        oilLiters = receivableAmt.divide(oilPrice,2, BigDecimal.ROUND_HALF_UP);
+        if(!oilLiters.toString().substring(oilLiters.toString().indexOf(".") + 1).equals("00")){
+            oilLiters = receivableAmt.divide(oilPrice,2, BigDecimal.ROUND_UP);
+        }
+        // settlementType:结算价类型(1.直降,2.折扣);  settlementPrice:结算价;  driverPrice:司机价;
+        String settlementType = params.get("settlementType").toString();
+        if(params.containsKey("settlementType") && params.get("settlementType") !=null && params.get("settlementType").toString() !=""){
+            switch (settlementType){
+                case "1":
+                    //优惠价(销售价)
+                    if(params.containsKey("settlementPrice") && params.get("settlementPrice").toString() !=null && params.get("settlementPrice").toString() !=""){
+                        discountPrice = oilPrice.subtract(new BigDecimal(params.get("settlementPrice").toString()));
+                        discountAmt = discountPrice.multiply(oilLiters);
+                    }
+                    break;
+                case "2":
+                    //优惠价(销售价)
+                    if(params.containsKey("settlementPrice") && params.get("settlementPrice").toString() !=null && params.get("settlementPrice").toString() !=""){
+                        discountPrice = oilPrice.multiply(new BigDecimal(params.get("settlementPrice").toString()));
+                        discountAmt = discountPrice.multiply(oilLiters);
+                    }
+                    break;
+            }
+        }
+
+        if(params.containsKey("driverPrice") && params.get("driverPrice").toString() !=null && params.get("driverPrice").toString() !=""){
+            //司机价
+            driverPrice = discountPrice.multiply(new BigDecimal(params.get("driverPrice").toString()));
+            driverDiscountAmt = driverPrice.multiply(oilLiters);
+        }
+        driverAmt = receivableAmt.subtract(driverDiscountAmt);  //司机价实收金额
+        driverAmt =driverAmt.signum() == -1 ? new BigDecimal("0.01"): driverAmt;
+        amt = receivableAmt.subtract(discountAmt);  //销售价实收金额
+        amt =amt.signum() == -1 ? new BigDecimal("0.01"): amt;
+        //销售价
+        discountPrice = oilLiters.equals(new BigDecimal("0.00")) ? discountPrice : amt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+        //司机价
+        driverPrice = oilLiters.equals(new BigDecimal("0.00")) ? driverPrice : driverAmt.divide(oilLiters, 2, BigDecimal.ROUND_HALF_UP);
+        payOrderResultInfo.setReceivableAmt(receivableAmt.toString());  //应收金额
+        payOrderResultInfo.setOilPrice(oilPrice.toString());            //油机价
+        payOrderResultInfo.setAmt(amt.toString());                      //销售价后时候金额
+        payOrderResultInfo.setDiscountPrice(discountPrice.toString());  //销售价
+        payOrderResultInfo.setDiscountAmt(discountAmt.toString());      //销售价后优惠金额
+
+        payOrderResultInfo.setDriverAmt(driverAmt.toString());                      //司机价后支付金额
+        payOrderResultInfo.setDriverPrice(driverPrice.toString());                  //司机价
+        payOrderResultInfo.setDriverDiscountAmt(driverDiscountAmt.toString());      //司机价后优惠金额
+
+        payOrderResultInfo.setOilLiters(oilLiters.toString());          //加油升数
+
+        payOrderResultInfo.setDzkAmt(amt.toString());                   //电子卡支付金额
+        payOrderResultInfo.setDzkDiscountAmt(dzkDiscountAmt.toString());    //电子卡优惠金额
+
+        payOrderResultInfo.setOilsCardFlag("0");
+        payOrderResultInfo.setCardEnabledFlag("0");
+
+        return payOrderResultInfo;
+    }
+
     //计算标签用户优惠
     public PayOrderResultInfo calculateLabelDiscount(Map<String ,Object> params){
         BigDecimal oilPrice = new BigDecimal(params.get("oilPrice").toString());    //油品价格

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/PayOrderMapper.java

@@ -9,6 +9,9 @@ import org.apache.ibatis.annotations.Param;
 
 public interface PayOrderMapper {
 
+    //LNG 平台第三方订单消费余额记录
+    void insertStationBalanceExchange(StationBalanceChange stationBalanceChange);
+
     //根据订单号查询订单
     PayOrder selectOrderInfoByOrdNo(String orderNo);
 

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/param/request/PayOrderRequest.java

@@ -53,6 +53,7 @@ public class PayOrderRequest {
     private String cardRuleFlagGroup;       //集团是否共享电子卡充值规则
     private String cardEnabledFlagGroup;    //集团是否开启电子卡
     private String labelFlag;               //油站是否开启标签功能
+    private String isLngFlagGroup;          //该集团是否为LNG第三方平台商:0,否;1,是;
 
     //一码一标签时所需参数:如果有则走标签优惠,没有则走正常优惠
     private String labelId;

+ 3 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/PayOrder.java

@@ -87,4 +87,7 @@ public class PayOrder implements Serializable {
     private String posQueue;
     private String deviceNo;
 
+    //
+    private Double driverAmt;
+
 }

+ 5 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/PayOrderResultInfo.java

@@ -21,4 +21,9 @@ public class PayOrderResultInfo {
     private String balance;         //电子卡余额
     private String cardOilsType;    //电子卡类型
     private String oilsCardFlag;      //该用户是否有改电子卡
+
+    //集团为LNG平台加气 时所需司机价
+    private String driverPrice;             //司机价
+    private String driverAmt;               //司机价后实收金额
+    private String driverDiscountAmt;     //司机价后优惠金额
 }

+ 19 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/StationBalanceChange.java

@@ -0,0 +1,19 @@
+package com.platform.yijia.pojo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * LNG油站余额变化记录表
+ */
+@Data
+public class StationBalanceChange {
+    private Integer id;
+    private Integer stationId;  //油站ID;
+    private String orderNo;     //订单号
+    private String type;        //记录类型
+    private Double amt;         //金额
+    private Date createTime;    //时间
+
+}

+ 19 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/StationInfo.java

@@ -143,6 +143,25 @@ public class StationInfo {
     private String cardRuleFlagGroup;       //集团是否共享电子卡充值规则
     private String cardEnabledFlagGroup;    //集团是否开启电子卡
 
+    private String isLngFlag;               //该油站是否为LNG第三方平台商:0,否;1,是;
+    private String isLngFlagGroup;          //该集团是否为LNG第三方平台商:0,否;1,是;
+
+    public String getIsLngFlag() {
+        return isLngFlag;
+    }
+
+    public void setIsLngFlag(String isLngFlag) {
+        this.isLngFlag = isLngFlag;
+    }
+
+    public String getIsLngFlagGroup() {
+        return isLngFlagGroup;
+    }
+
+    public void setIsLngFlagGroup(String isLngFlagGroup) {
+        this.isLngFlagGroup = isLngFlagGroup;
+    }
+
     public String getLabelFlag() {
         return labelFlag;
     }

+ 4 - 4
YijiaRestful/src/main/java/com/platform/yijia/service/PayOrderService.java

@@ -1,16 +1,16 @@
 package com.platform.yijia.service;
 
 import com.platform.yijia.param.request.PayOrderRequest;
-import com.platform.yijia.pojo.AppUserInfo;
-import com.platform.yijia.pojo.CustomerManage;
-import com.platform.yijia.pojo.PayOrder;
-import com.platform.yijia.pojo.PayType;
+import com.platform.yijia.pojo.*;
 
 import java.util.List;
 import java.util.Map;
 
 public interface PayOrderService {
 
+    //LNG 平台第三方订单消费余额记录
+    void insertStationBalanceExchange(StationBalanceChange stationBalanceChange);
+
     //根据订单号查询订单
     PayOrder selectOrderInfoByOrdNo(String orderNo);
 

+ 6 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/PayOrderServiceImpl.java

@@ -72,6 +72,12 @@ public class PayOrderServiceImpl implements PayOrderService {
         return payOrderMapper.getPayOrderInfoMin(payOrder);
     }
 
+    //LNG 平台第三方订单消费余额记录
+    @Override
+    public void insertStationBalanceExchange(StationBalanceChange stationBalanceChange){
+        payOrderMapper.insertStationBalanceExchange(stationBalanceChange);
+    }
+
     /**
      * 修改订单信息
      * @param payOrder

+ 1 - 1
YijiaRestful/src/main/resources/application.yml

@@ -28,7 +28,7 @@ yijia:
 
 # swagger2
 swagger2:
-    swagger-ui-open: true
+    swagger-ui-open: false
 
 # swagger2 UI登录密码
 #security:

+ 46 - 0
YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

@@ -596,6 +596,9 @@
       <if test="amt != null">
         amt,
       </if>
+      <if test="driverAmt != null">
+        driver_amt,
+      </if>
       <if test="stationId != null">
         station_id,
       </if>
@@ -721,6 +724,9 @@
       <if test="amt != null">
         #{amt,jdbcType=DOUBLE},
       </if>
+      <if test="driverAmt != null">
+        #{driverAmt,jdbcType=DOUBLE},
+      </if>
       <if test="stationId != null">
         #{stationId,jdbcType=INTEGER},
       </if>
@@ -985,6 +991,7 @@
         A.oil_type              AS oilType,
         A.order_liters 			AS orderLiters,
         A.amt 					AS amt,
+        A.driver_amt            AS driverAmt,
         A.dzk_amt               AS dzkAmt,
         A.order_type 			AS orderType,
         A.oil_pirce             AS oilPirce,
@@ -1009,6 +1016,45 @@
         A.order_no = #{orderNo}
   </select>
 
+ <!-- 插入油站余额记录 -->
+ <insert id="insertStationBalanceExchange" parameterType="com.platform.yijia.pojo.StationBalanceChange">
+     INSERT INTO station_balance_change
+     <trim prefix="(" suffix=")" suffixOverrides=",">
+         <if test="stationId !=null ">
+             station_id,
+         </if>
+         <if test="orderNo !=null ">
+             order_no,
+         </if>
+         <if test="type !=null ">
+             type,
+         </if>
+         <if test="amt !=null ">
+             amt,
+         </if>
+         <if test="createTime !=null ">
+             create_time,
+         </if>
+     </trim>
+     <trim prefix="values (" suffix=")" suffixOverrides=",">
+         <if test="stationId !=null ">
+             #{stationId},
+         </if>
+         <if test="orderNo !=null ">
+             #{orderNo},
+         </if>
+         <if test="type !=null ">
+             #{type},
+         </if>
+         <if test="amt !=null ">
+             #{amt},
+         </if>
+         <if test="createTime !=null ">
+             #{createTime},
+         </if>
+     </trim>
+ </insert>
+
 
   <!-- 更新订单-->
   <update id="updateOrderStatus" parameterType="com.platform.yijia.pojo.PayOrder">

+ 13 - 6
YijiaRestful/src/main/resources/mapper/StationInfoMapper.xml

@@ -34,7 +34,8 @@
     <result column="card_enabled_flag_group"    jdbcType="VARCHAR" property="cardEnabledFlagGroup" />
     <result column="integral_flag_group"        jdbcType="VARCHAR" property="integralFlagGroup" />
     <result column="integral_rule_flag_group"   jdbcType="VARCHAR" property="integralRuleFlagGroup" />
-
+    <result column="is_lng_flag"                jdbcType="VARCHAR" property="isLngFlag" />
+    <result column="is_lng_flag_group"          jdbcType="VARCHAR" property="isLngFlagGroup" />
 
     <result column="single_station_flag"  jdbcType="VARCHAR" property="singleStationFlag" />
     <result column="card_rule_flag"       jdbcType="VARCHAR" property="cardRuleFlag" />
@@ -84,10 +85,14 @@
         T1.discount_setting          AS discountSetting,
         T1.card_enabled_flag         AS cardEnabledFlag,
         T3.card_rule_flag            AS cardRuleFlag,
-        T2.oil_price                 AS oilPrice
-    FROM            sys_dept             AS T1
-        LEFT JOIN   station_oil_price    AS T2 ON T1.dept_id = T2.station_id
-        LEFT JOIN   sys_dept             AS T3 ON T1.parent_id = T3.dept_id
+        T2.oil_price                 AS oilPrice,
+        T4.settlement_type           AS settlementType,
+        T4.settlement_price          AS settlementPrice,
+        T4.driver_price              AS driverPrice
+    FROM            sys_dept                AS T1
+        LEFT JOIN   station_oil_price       AS T2 ON T1.dept_id = T2.station_id
+        LEFT JOIN   sys_dept                AS T3 ON T1.parent_id = T3.dept_id
+        LEFT JOIN station_settlement_price  AS T4 ON T2.oil_price_id = T4.station_oil_price_id
     <where>
       <if test="stationId !='' and stationId != null" >
         T1.dept_id = #{stationId}
@@ -143,10 +148,12 @@
         T1.card_enabled_flag,
         T1.integral_flag,
         T1.label_flag,
+        T1.is_lng_flag,
         T2.card_enabled_flag    AS card_enabled_flag_group,
         T2.card_rule_flag       AS card_rule_flag_group,
         T2.integral_flag        AS integral_flag_group,
-        T2.integral_rule_flag   AS integral_rule_flag_group
+        T2.integral_rule_flag   AS integral_rule_flag_group,
+        T2.is_lng_flag          AS is_lng_flag_group
     FROM          sys_dept      AS T1
         LEFT JOIN sys_dept      AS T2 ON T1.parent_id = T2.dept_id
     <where>