Переглянути джерело

订单表添加油站名称和油品价格

jk-GitHub-coder 4 роки тому
батько
коміт
6a96a8c615

+ 20 - 1
YijiaRestful/src/main/java/com/platform/yijia/pojo/PayOrder.java

@@ -147,6 +147,25 @@ public class PayOrder {
      */
     private String orderType;
 
+    private String oilPirce;
+    private String stationName;
+
+    public String getOilPirce() {
+        return oilPirce;
+    }
+
+    public void setOilPirce(String oilPirce) {
+        this.oilPirce = oilPirce;
+    }
+
+    public String getStationName() {
+        return stationName;
+    }
+
+    public void setStationName(String stationName) {
+        this.stationName = stationName;
+    }
+
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column pay_order.order_id
@@ -530,4 +549,4 @@ public class PayOrder {
     public void setOrderType(String orderType) {
         this.orderType = orderType == null ? null : orderType.trim();
     }
-}
+}

+ 0 - 1
YijiaRestful/src/main/java/com/platform/yijia/service/impl/AppUserInfoServiceImpl.java

@@ -8,7 +8,6 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 

+ 21 - 8
YijiaRestful/src/main/java/com/platform/yijia/service/impl/PayOrderServiceImpl.java

@@ -59,23 +59,36 @@ public class PayOrderServiceImpl implements PayOrderService {
         params.put("oilGunId", payOrderRequest.getOilGun());
         params.put("stationId", payOrderRequest.getStationId());
         Map mapResult = payOrderMapper.selectOilGunNoAndOilPrice(params);
-        payOrder.setOilGun(mapResult.get("oliGunNo").toString());                   //存入油枪号
-        payOrder.setOilPersonnel(mapResult.get("personnelName").toString());       //加油员
-
+        if(mapResult.containsKey("oliGunNo") && mapResult.get("oliGunNo").toString() !=null){
+            payOrder.setOilGun(mapResult.get("oliGunNo").toString());                   //存入油枪号
+        }
+        if(mapResult.containsKey("personnelName") && mapResult.get("personnelName").toString() !=null){
+            payOrder.setOilPersonnel(mapResult.get("personnelName").toString());       //加油员
+        }
+        if(mapResult.containsKey("stationName") && mapResult.get("stationName").toString() !=null){
+            payOrder.setStationName(mapResult.get("stationName").toString());           //油站名称
+        }
         //根据油品名称和油站id获取当前油品调价信息
         params.put("oilName", payOrderRequest.getOilName());
         List<Map> oilPriceAdjustList = payOrderMapper.selectOilPriceAdjust(params);
         String amt = payOrderRequest.getAmt();  //订单金额
-        if(oilPriceAdjustList != null && oilPriceAdjustList.size() > 0){        //若存在油价价格调整时
+        if(oilPriceAdjustList != null && oilPriceAdjustList.size() > 0){  //若存在油价价格调整时
             for (Map m : oilPriceAdjustList){
-                if(compareEffectTime(m.get("takeEffectDate").toString())){      // 如果生效时间小于当前时间则使用生效时间 取离当前时间最近的调整价格(查询结果按生效时间降序排序故只做此判断即可)
-                    payOrder.setOrderLiters(recKonOrderLiters(amt, m.get("oilAdjustPrice").toString(), 2));       //计算加油升数且存入
+                // 如果生效时间小于当前时间则使用生效时间 取离当前时间最近的调整价格(查询结果按生效时间降序排序故只做此判断即可)
+                if(compareEffectTime(m.get("takeEffectDate").toString())){
+                    if(m.containsKey("oilAdjustPrice") && m.get("oilAdjustPrice").toString() !=null && !m.get("oilAdjustPrice").toString().equals("")){
+                        payOrder.setOrderLiters(recKonOrderLiters(amt, m.get("oilAdjustPrice").toString(), 2));       //计算加油升数且存入
+                        payOrder.setOilPirce(m.get("oilAdjustPrice").toString());
+                    }
                     break;
                 }
             }
         }else {     //若没有油价调整时则使用原始油价计算加油升数
-            String oilPrice = mapResult.get("oilPrice").toString();    //原始价格
-            payOrder.setOrderLiters(recKonOrderLiters(amt, oilPrice, 2));     //计算油价升数存放
+            if(mapResult.containsKey("oilPrice") && mapResult.get("oilPrice").toString() !=null && !mapResult.get("oilPrice").toString().equals("")){
+                String oilPrice = mapResult.get("oilPrice").toString();    //原始价格
+                payOrder.setOilPirce(oilPrice);
+                payOrder.setOrderLiters(recKonOrderLiters(amt, oilPrice, 2));     //计算油价升数存放
+            }
         }
         //数据落地
         payOrderMapper.insertSelective(payOrder);

+ 53 - 21
YijiaRestful/src/main/resources/mapper/PayOrderMapper.xml

@@ -10,6 +10,7 @@
     <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
     <result column="oil_gun" jdbcType="VARCHAR" property="oilGun" />
     <result column="oil_name" jdbcType="VARCHAR" property="oilName" />
+    <result column="oil_price" jdbcType="VARCHAR" property="oilPirce" />
     <result column="consumer_id" jdbcType="INTEGER" property="consumerId" />
     <result column="consumer" jdbcType="VARCHAR" property="consumer" />
     <result column="amt" jdbcType="VARCHAR" property="amt" />
@@ -22,6 +23,7 @@
     <result column="oil_personnel" jdbcType="VARCHAR" property="oilPersonnel" />
     <result column="created_date" jdbcType="TIMESTAMP" property="createdDate" />
     <result column="order_type" jdbcType="CHAR" property="orderType" />
+    <result column="station_name" jdbcType="CHAR" property="stationName" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -94,19 +96,21 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    order_id, order_no, oil_gun, oil_name, consumer_id, consumer, amt, station_id, status, 
-    order_liters, pay_type, pay_way, pay_date, oil_personnel, created_date, order_type
+    order_id, order_no, oil_gun, oil_name, oil_pirce, consumer_id, consumer, amt, station_id, status,
+    order_liters, pay_type, pay_way, pay_date, oil_personnel, created_date, order_type, station_name
   </sql>
 
   <!-- 根据油品名称和油站查询油枪编号和价格 -->
   <select id="selectOilGunNoAndOilPrice" parameterType="map" resultType="map">
     SELECT
-        A.oil_gun_no 	AS oliGunNo,
-        A.oil_name 	    AS oilName,
-        A.station_name  AS stationName,
-        B.oil_price	    AS oilPrice
+        A.oil_gun_no 	 AS oliGunNo,
+        A.oil_name 	     AS oilName,
+        A.station_name   AS stationName,
+        B.oil_price	     AS oilPrice,
+        C.personnel_name AS personnelName
     FROM station_oil_gun AS A
         LEFT JOIN station_oil_price AS B ON A.oil_name = B.oil_name AND A.station_id = B.station_id
+        LEFT JOIN station_personnel AS C ON A.oil_gun_no = C.gun_no AND A.station_id = C.station_id
     <where>
         <if test="oilGunId != null and oilGunId !=''">
           A.oil_gun_id = #{oilGunId}
@@ -167,7 +171,7 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    select 
+    select
     <include refid="Base_Column_List" />
     from pay_order
     where order_id = #{orderId,jdbcType=INTEGER}
@@ -195,18 +199,18 @@
       WARNING - @mbg.generated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
-    insert into pay_order (order_id, order_no, oil_gun, 
-      oil_name, consumer_id, consumer, 
-      amt, station_id, status, 
-      order_liters, pay_type, pay_way, 
-      pay_date, oil_personnel, created_date, 
-      order_type)
-    values (#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{oilGun,jdbcType=VARCHAR}, 
-      #{oilName,jdbcType=VARCHAR}, #{consumerId,jdbcType=INTEGER}, #{consumer,jdbcType=VARCHAR}, 
-      #{amt,jdbcType=VARCHAR}, #{stationId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR}, 
-      #{orderLiters,jdbcType=VARCHAR}, #{payType,jdbcType=VARCHAR}, #{payWay,jdbcType=VARCHAR}, 
-      #{payDate,jdbcType=TIMESTAMP}, #{oilPersonnel,jdbcType=VARCHAR}, #{createdDate,jdbcType=TIMESTAMP}, 
-      #{orderType,jdbcType=CHAR})
+    insert into pay_order (order_id, order_no, oil_gun,
+      oil_name, oli_price, consumer_id, consumer,
+      amt, station_id, status,
+      order_liters, pay_type, pay_way,
+      pay_date, oil_personnel, created_date,
+      order_type, station_name)
+    values (#{orderId,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{oilGun,jdbcType=VARCHAR},
+      #{oilName,jdbcType=VARCHAR}, #{oilPirce,jdbcType=VARCHAR}, #{consumerId,jdbcType=INTEGER}, #{consumer,jdbcType=VARCHAR},
+      #{amt,jdbcType=VARCHAR}, #{stationId,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR},
+      #{orderLiters,jdbcType=VARCHAR}, #{payType,jdbcType=VARCHAR}, #{payWay,jdbcType=VARCHAR},
+      #{payDate,jdbcType=TIMESTAMP}, #{oilPersonnel,jdbcType=VARCHAR}, #{createdDate,jdbcType=TIMESTAMP},
+      #{orderType,jdbcType=CHAR}, #{stationName,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" parameterType="com.platform.yijia.pojo.PayOrder">
     <!--
@@ -227,6 +231,9 @@
       <if test="oilName != null">
         oil_name,
       </if>
+      <if test="oilPirce != null">
+        oil_pirce,
+      </if>
       <if test="consumerId != null">
         consumer_id,
       </if>
@@ -263,6 +270,9 @@
       <if test="orderType != null">
         order_type,
       </if>
+      <if test="stationName != null">
+        station_name,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="orderId != null">
@@ -277,6 +287,9 @@
       <if test="oilName != null">
         #{oilName,jdbcType=VARCHAR},
       </if>
+      <if test="oilPirce != null">
+        #{oilPirce,jdbcType=VARCHAR},
+      </if>
       <if test="consumerId != null">
         #{consumerId,jdbcType=INTEGER},
       </if>
@@ -313,6 +326,9 @@
       <if test="orderType != null">
         #{orderType,jdbcType=CHAR},
       </if>
+      <if test="stationName != null">
+        #{stationName,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.platform.yijia.pojo.PayOrderExample" resultType="java.lang.Long">
@@ -344,6 +360,9 @@
       <if test="record.oilName != null">
         oil_name = #{record.oilName,jdbcType=VARCHAR},
       </if>
+      <if test="record.oilPirce != null">
+        oil_pirce = #{record.oilPirce,jdbcType=VARCHAR},
+      </if>
       <if test="record.consumerId != null">
         consumer_id = #{record.consumerId,jdbcType=INTEGER},
       </if>
@@ -380,6 +399,9 @@
       <if test="record.orderType != null">
         order_type = #{record.orderType,jdbcType=CHAR},
       </if>
+      <if test="record.stationName != null">
+        station_name = #{record.stationName,jdbcType=VARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
@@ -395,6 +417,7 @@
       order_no = #{record.orderNo,jdbcType=VARCHAR},
       oil_gun = #{record.oilGun,jdbcType=VARCHAR},
       oil_name = #{record.oilName,jdbcType=VARCHAR},
+      oil_pirce = #{record.oilPirce,jdbcType=VARCHAR},
       consumer_id = #{record.consumerId,jdbcType=INTEGER},
       consumer = #{record.consumer,jdbcType=VARCHAR},
       amt = #{record.amt,jdbcType=VARCHAR},
@@ -406,7 +429,8 @@
       pay_date = #{record.payDate,jdbcType=TIMESTAMP},
       oil_personnel = #{record.oilPersonnel,jdbcType=VARCHAR},
       created_date = #{record.createdDate,jdbcType=TIMESTAMP},
-      order_type = #{record.orderType,jdbcType=CHAR}
+      order_type = #{record.orderType,jdbcType=CHAR},
+      station_name = #{record.stationName,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -427,6 +451,9 @@
       <if test="oilName != null">
         oil_name = #{oilName,jdbcType=VARCHAR},
       </if>
+      <if test="oilPirce != null">
+        oil_pirce = #{oilPirce,jdbcType=VARCHAR},
+      </if>
       <if test="consumerId != null">
         consumer_id = #{consumerId,jdbcType=INTEGER},
       </if>
@@ -463,6 +490,9 @@
       <if test="orderType != null">
         order_type = #{orderType,jdbcType=CHAR},
       </if>
+      <if test="stationName != null">
+        station_name = #{stationName,jdbcType=CHAR},
+      </if>
     </set>
     where order_id = #{orderId,jdbcType=INTEGER}
   </update>
@@ -475,6 +505,7 @@
     set order_no = #{orderNo,jdbcType=VARCHAR},
       oil_gun = #{oilGun,jdbcType=VARCHAR},
       oil_name = #{oilName,jdbcType=VARCHAR},
+      oil_pirce = #{oilPirce,jdbcType=VARCHAR},
       consumer_id = #{consumerId,jdbcType=INTEGER},
       consumer = #{consumer,jdbcType=VARCHAR},
       amt = #{amt,jdbcType=VARCHAR},
@@ -487,6 +518,7 @@
       oil_personnel = #{oilPersonnel,jdbcType=VARCHAR},
       created_date = #{createdDate,jdbcType=TIMESTAMP},
       order_type = #{orderType,jdbcType=CHAR}
+      station_name = #{stationName,jdbcType=VARCHAR},
     where order_id = #{orderId,jdbcType=INTEGER}
   </update>
-</mapper>
+</mapper>