jk-GitHub-coder 4 tahun lalu
induk
melakukan
33da3948f0

+ 3 - 3
YijiaRestful/src/main/java/com/platform/yijia/controller/ElectronicMembershipCardController.java

@@ -212,7 +212,7 @@ public class ElectronicMembershipCardController {
                 }
                 String orderNo = System.nanoTime()+str;
                 customerCardUseRecord.setOrderNo(orderNo);
-                electronicMembershipCardService.insetCardUseRecord(customerCardUseRecord);      //插入电子会员卡的使用记录
+                electronicMembershipCardService.insetCardUseRecordRecharge(customerCardUseRecord);      //插入电子会员卡的使用记录
                 resultData = ResultData.success(orderNo);
             }
         }
@@ -529,7 +529,7 @@ public class ElectronicMembershipCardController {
         ResultData resultData = null;
         if(stationId !=null && unionId !=null){
             CustomerCardUseRecord customerCardUseRecord = new CustomerCardUseRecord();
-            customerCardUseRecord.setUsageType("+"); // '+' 代表充值
+            customerCardUseRecord.setUsageType("recharge"); // 'recharge' 代表充值
             customerCardUseRecord.setStationId(stationId);
             customerCardUseRecord.setUnionId(unionId);
             List<CustomerCardUseRecord> cardUseRecordList = electronicMembershipCardService.getCardUseRecordList(customerCardUseRecord);
@@ -551,7 +551,7 @@ public class ElectronicMembershipCardController {
             CustomerCardUseRecord customerCardUseRecord = new CustomerCardUseRecord();
             customerCardUseRecord.setUnionId(unionId);
             customerCardUseRecord.setStationId(stationId);
-            customerCardUseRecord.setUsageType("-"); // '-' 代表消费
+            customerCardUseRecord.setUsageType("consumption"); // 'consumption' 代表消费
             List<CustomerCardUseRecord> cardUseRecordList = electronicMembershipCardService.getCardUseRecordList(customerCardUseRecord);
             resultData = ResultData.success(cardUseRecordList);
         }else {

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

@@ -131,7 +131,7 @@ public class PayController {
                 }
                 //判断订单金额是否小于电子会员卡的余额
                 if(balance !=null && customerCardUseRecord.getAmt().compareTo(balance) == -1){
-                    electronicMembershipCardService.insetCardUseRecord(customerCardUseRecord);
+                    electronicMembershipCardService.insetCardUseRecordConsumption(customerCardUseRecord);
                     //更新电子会员卡余额
                     CustomerElectronicCard c = new CustomerElectronicCard();
                     c.setAmt(balance.subtract(customerCardUseRecord.getAmt()));

+ 5 - 2
YijiaRestful/src/main/java/com/platform/yijia/dao/ElectronicMembershipCardMapper.java

@@ -21,8 +21,11 @@ public interface ElectronicMembershipCardMapper {
     //获取用户储蓄卡的使用记录
     List<CustomerCardUseRecord> getCardUseRecordList(CustomerCardUseRecord customerCardUseRecord);
 
-    //新增电子会员卡使用记录
-    void insetCardUseRecord(CustomerCardUseRecord customerCardUseRecord);
+    //新增电子会员卡充值使用记录
+    void insetCardUseRecordRecharge(CustomerCardUseRecord customerCardUseRecord);
+
+    //新增电子会员卡消费使用记录
+    void insetCardUseRecordConsumption(CustomerCardUseRecord customerCardUseRecord);
 
     //根据订单号查询电子会员卡的充值记录信息
     CustomerCardUseRecord getCardRecordByOrderNo(CustomerCardUseRecord customerCardUseRecord);

+ 6 - 3
YijiaRestful/src/main/java/com/platform/yijia/service/ElectronicMembershipCardService.java

@@ -17,12 +17,15 @@ public interface ElectronicMembershipCardService {
     //更新电子会员卡信息
     void updateElectronicCardInfo(CustomerElectronicCard customerElectronicCard);
 
+    //新增电子会员卡充值使用记录
+    void insetCardUseRecordRecharge(CustomerCardUseRecord customerCardUseRecord);
+
+    //新增电子会员卡消费使用记录
+    void insetCardUseRecordConsumption(CustomerCardUseRecord customerCardUseRecord);
+
     //获取用户储蓄卡的使用记录
     List<CustomerCardUseRecord> getCardUseRecordList(CustomerCardUseRecord customerCardUseRecord);
 
-    //新增电子会员卡使用记录
-    void insetCardUseRecord(CustomerCardUseRecord customerCardUseRecord);
-
     //根据订单号查询电子会员卡的充值记录信息
     CustomerCardUseRecord getCardRecordByOrderNo(CustomerCardUseRecord customerCardUseRecord);
 

+ 9 - 3
YijiaRestful/src/main/java/com/platform/yijia/service/impl/ElectronicMembershipCardServiceImpl.java

@@ -84,10 +84,16 @@ public class ElectronicMembershipCardServiceImpl implements ElectronicMembership
         electronicMembershipCardMapper.updateElectronicCardInfo(customerElectronicCard);
     }
 
-    //新增电子会员卡的使用记录
+    //新增电子会员卡的充值使用记录
     @Override
-    public void insetCardUseRecord(CustomerCardUseRecord customerCardUseRecord) {
-        electronicMembershipCardMapper.insetCardUseRecord(customerCardUseRecord);
+    public void insetCardUseRecordRecharge(CustomerCardUseRecord customerCardUseRecord) {
+        electronicMembershipCardMapper.insetCardUseRecordRecharge(customerCardUseRecord);
+    }
+
+    //新增电子会员卡的消费使用记录
+    @Override
+    public void insetCardUseRecordConsumption(CustomerCardUseRecord customerCardUseRecord) {
+        electronicMembershipCardMapper.insetCardUseRecordConsumption(customerCardUseRecord);
     }
 
     //获取活用要充值电子会员卡的信息

+ 136 - 12
YijiaRestful/src/main/resources/mapper/ElectronicMembershipCardMapper.xml

@@ -121,7 +121,7 @@
             station_name,
             status
         FROM
-            customer_card_use_record
+            customer_card_record_recharge
         <where>
             <if test=" orderNo !=null and orderNo !=''">
                 order_no = #{orderNo}
@@ -132,7 +132,7 @@
     <!--根据订单号更新用户充值记录的状态-->
     <update id="updateCardRecordStatusByOrderNo" parameterType="com.platform.yijia.pojo.CustomerElectronicCard">
         UPDATE
-            customer_card_use_record
+            customer_card_record_recharge
         <set>
             <if test="status !=null">
                 status = #{status}
@@ -145,10 +145,10 @@
         </where>
     </update>
 
-    <!--插入用户电子会员卡的使用记录-->
-    <insert id="insetCardUseRecord" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
+    <!--插入用户电子会员卡的充值使用记录-->
+    <insert id="insetCardUseRecordRecharge" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
         INSERT INTO
-            customer_card_use_record
+            customer_card_record_recharge
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="orderNo !=null">
                 order_no,
@@ -239,9 +239,98 @@
         </trim>
     </insert>
 
-    <!--查询客户电子会员卡的使用记录-->
-    <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
-         SELECT
+    <!--插入用户电子会员卡的消费使用记录-->
+    <insert id="insetCardUseRecordConsumption" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
+        INSERT INTO
+        customer_card_record_consumption
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="orderNo !=null">
+                order_no,
+            </if>
+            <if test="unionId !=null">
+                union_id,
+            </if>
+            <if test="customerNo !=null">
+                customer_no,
+            </if>
+            <if test="customerName !=null">
+                customer_name,
+            </if>
+            <if test="usageType !=null">
+                usage_type,
+            </if>
+            <if test="payType !=null">
+                pay_type,
+            </if>
+            <if test="cardOilsType !=null">
+                card_oils_type,
+            </if>
+            <if test="amt !=null">
+                amt,
+            </if>
+            <if test="balance !=null">
+                balance,
+            </if>
+            <if test="createTime !=null">
+                create_time,
+            </if>
+            <if test="stationId !=null">
+                station_id,
+            </if>
+            <if test="stationName !=null">
+                station_name,
+            </if>
+            <if test="status !=null">
+                status,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="orderNo !=null">
+                #{orderNo},
+            </if>
+            <if test="unionId !=null">
+                #{unionId},
+            </if>
+            <if test="customerNo !=null">
+                #{customerNo},
+            </if>
+            <if test="customerName !=null">
+                #{customerName},
+            </if>
+            <if test="usageType !=null">
+                #{usageType},
+            </if>
+            <if test="payType !=null">
+                #{payType},
+            </if>
+            <if test="cardOilsType !=null">
+                #{cardOilsType},
+            </if>
+            <if test="amt !=null">
+                #{amt},
+            </if>
+            <if test="balance !=null">
+                #{balance},
+            </if>
+            <if test="createTime !=null">
+                #{createTime},
+            </if>
+            <if test="stationId !=null">
+                #{stationId},
+            </if>
+            <if test="stationName !=null">
+                #{stationName},
+            </if>
+            <if test="status !=null">
+                #{status},
+            </if>
+        </trim>
+    </insert>
+
+
+    <!--充值-->
+    <sql id="Base_Column_List_recharge">
+        SELECT
             id,
             order_no,
             union_id,
@@ -258,12 +347,37 @@
             station_name,
             status
          FROM
-            customer_card_use_record
+            customer_card_record_recharge
         <where>
-                status ="1"
-            <if test=" usageType !=null and usageType !=''">
-                AND usage_type = #{usageType}
+            status ="1"
+            <if test="stationId !=null and stationId !=''">
+                AND station_id = #{stationId}
+            </if>
+            <if test="unionId !=null and unionId !=''">
+                AND union_id = #{unionId}
             </if>
+        </where>
+        ORDER BY create_time DESC
+    </sql>
+    <!--消费-->
+    <sql id="Base_Column_List_consumption">
+        SELECT
+            id,
+            order_no,
+            union_id,
+            customer_no,
+            customer_name,
+            usage_type,
+            pay_type,
+            card_oils_type,
+            amt,
+            create_time,
+            station_id,
+            station_name,
+            status
+         FROM
+            customer_card_record_consumption
+        <where>
             <if test="stationId !=null and stationId !=''">
                 AND station_id = #{stationId}
             </if>
@@ -272,6 +386,16 @@
             </if>
         </where>
         ORDER BY create_time DESC
+    </sql>
+
+    <!--查询客户电子会员卡的使用记录-->
+    <select id="getCardUseRecordList" resultMap="CardRecordBaseResultMap" parameterType="com.platform.yijia.pojo.CustomerCardUseRecord">
+        <if test="usageType !=null and usageType =='consumption'">
+            <include refid="Base_Column_List_consumption"/>
+        </if>
+        <if test="usageType !=null and usageType =='recharge'">
+            <include refid="Base_Column_List_recharge"/>
+        </if>
     </select>