Procházet zdrojové kódy

客户积分记录

jk-GitHub-coder před 4 roky
rodič
revize
0e72cc78b1

+ 60 - 9
YijiaRestful/src/main/java/com/platform/yijia/controller/IntegralShoppingMallController.java

@@ -21,12 +21,12 @@ import java.util.Random;
 
 /*
  * <Title> IntegralShoppingMallController </Title>
- * <Description> 油站积分商城 </Description>
+ * <Description> 油站积分商城控制层 </Description>
  * @Author JK
  * @Date 2021年2月24日
  */
 @Controller
-@RequestMapping("/api")
+@RequestMapping("/demo")
 public class IntegralShoppingMallController {
     private static Logger logger =(Logger) LoggerFactory.getLogger(IntegralShoppingMallController.class);
     @Resource
@@ -37,6 +37,8 @@ public class IntegralShoppingMallController {
     private CustomerPointsService customerPointsService;
     @Resource
     private StationService stationService;
+    @Resource
+    private CustomerPointsRecordService customerPointsRecordService;
 
     //获取油站积分商品信息
     @RequestMapping(value = "/getIntegralWaresInfoList", method = RequestMethod.GET)
@@ -64,9 +66,14 @@ public class IntegralShoppingMallController {
         Gson gson =new Gson();
         //返回结果集
         ResultData resultData = null;
-        IntegralOrder integralOrder = new IntegralOrder();
+        IntegralOrder integralOrder = new IntegralOrder();      //积分订单
+        IntegralWares integralWares = new IntegralWares();      //积分商品表
+        CustomerPoints customerPoints = new CustomerPoints();       //客户积分表
+        CustomerPointsRecord customerPointsRecord = new CustomerPointsRecord();     //客户积分记录
+
         if(StringUtils.isNotBlank(request.getCustomerName())){
             integralOrder.setCustomerName(request.getCustomerName());
+            customerPointsRecord.setCustomerName(request.getCustomerName());
         }
         if(StringUtils.isNotBlank(request.getWaresName())){
             integralOrder.setWaresName(request.getWaresName());
@@ -76,15 +83,20 @@ public class IntegralShoppingMallController {
         }
         if(request.getStationId() != null){
             integralOrder.setStationId(request.getStationId());
+            customerPointsRecord.setStationId(request.getStationId());
         }
         if(request.getWaresId() !=null){
             integralOrder.setWaresId(request.getWaresId());
+            integralWares.setId(request.getWaresId());
         }
         if(StringUtils.isNotBlank(request.getUnionId())){
             integralOrder.setUnionId(request.getUnionId());
+            customerPoints.setUnionId(request.getUnionId());
+            customerPointsRecord.setUnionId(request.getUnionId());
         }
         if(request.getIntegral() !=null){
             integralOrder.setIntegral(request.getIntegral());
+            customerPointsRecord.setIntegral(request.getIntegral());
         }
 
         integralOrder.setStatus("1");   //订单状态
@@ -99,8 +111,6 @@ public class IntegralShoppingMallController {
         integralOrder.setExchangeTime(new Date());
 
         //更新用户积分
-        CustomerPoints customerPoints = new CustomerPoints();
-        customerPoints.setUnionId(request.getUnionId());
         CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
         if(customerPointsInfo !=null){
             //用户剩余积分
@@ -116,10 +126,9 @@ public class IntegralShoppingMallController {
         Map<String, String> m = stationService.getStationAppIdAndAppSecret(request.getStationId());
         if(m !=null && m.containsKey("stationName")){
             integralOrder.setStationName(m.get("stationName"));
+            customerPointsRecord.setStationName(m.get("stationName"));
         }
 
-        IntegralWares integralWares = new IntegralWares();
-        integralWares.setId(request.getWaresId());
         List<IntegralWares> integralWaresInfoList = integralWaresService.getIntegralWaresInfoList(integralWares);
         if(integralWaresInfoList !=null && integralWaresInfoList.size() ==1){
             //更新商品已售数量
@@ -127,6 +136,12 @@ public class IntegralShoppingMallController {
             integralWaresService.updateIntegralWaresInfo(integralWares);
         }
 
+        //插入客户记录表
+        customerPointsRecord.setRecordType("-");    //客户积分表记录
+        customerPointsRecord.setCreateTime(new Date());
+        customerPointsRecordService.insertCustomerPointsInfo(customerPointsRecord);
+
+
         boolean b = integralOrderService.insertIntegralOrder(integralOrder);
         if (b){
             resultData=ResultData.success(CodeMsg.SUCCESS);
@@ -136,7 +151,7 @@ public class IntegralShoppingMallController {
         return gson.toJson(resultData);
     }
 
-    //获取用户订单列表
+    //获取用户积分订单列表
     @RequestMapping(value = "/getUserIntegralOrderList", method = RequestMethod.GET)
     @ResponseBody
     public String getUserIntegralOrderList(@RequestParam String unionId){
@@ -146,6 +161,7 @@ public class IntegralShoppingMallController {
         if(unionId !=null){
             IntegralOrder integralOrder = new IntegralOrder();
             integralOrder.setUnionId(unionId);
+            //integralOrder.setStationId(stationId);
             List<IntegralOrder> integralOrderList = integralOrderService.getUserIntegralOrderList(integralOrder);
             resultData=ResultData.success(integralOrderList);
         }else {
@@ -154,6 +170,41 @@ public class IntegralShoppingMallController {
         return gson.toJson(resultData);
     }
 
-    //获取客户积分
+    //获取客户积分信息
+    @RequestMapping(value = "/getCustomerPointsInfo", method = RequestMethod.GET)
+    @ResponseBody
+    public String getCustomerPointsInfo(@RequestParam("unionId") String unionId){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(unionId !=null){
+            CustomerPoints customerPoints  =new CustomerPoints();
+            customerPoints.setUnionId(unionId);
+            //customerPoints.setStationId(stationId);
+            CustomerPoints customerPointsInfo = customerPointsService.getCustomerPointsInfo(customerPoints);
+            resultData=ResultData.success(customerPointsInfo);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
 
+    //获取客户积分记录信息
+    @RequestMapping(value = "/getCustomerPointsRecordList", method = RequestMethod.GET)
+    @ResponseBody
+    public String getCustomerPointsRecordList(@RequestParam("unionId") String unionId){
+        Gson gson =new Gson();
+        //返回结果集
+        ResultData resultData = null;
+        if(unionId !=null){
+            CustomerPointsRecord customerPointsRecord  =new CustomerPointsRecord();
+            customerPointsRecord.setUnionId(unionId);
+            //customerPointsRecord.setStationId(stationId);
+            List<CustomerPointsRecord> customerPointsRecordList = customerPointsRecordService.getCustomerPointsRecordList(customerPointsRecord);
+            resultData=ResultData.success(customerPointsRecordList);
+        }else {
+            resultData=ResultData.success(CodeMsg.REQUEST_FAIL);
+        }
+        return gson.toJson(resultData);
+    }
 }

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

@@ -201,8 +201,8 @@ public class PayController {
 
                     //reqData.put("outFrontUrl", ""); //js 支付,前台 成功通知地址
                     //reqData.put("outFrontFailUrl", ""); //js 支付,前台 事变通知地址
-                    //reqData.put("notifyUrl", "https://www.huijy.net/api/getCallback"); //回调地址
-                    reqData.put("notifyUrl", "https://www.huijy.net/demo/getCallback"); //回调地址
+                    reqData.put("notifyUrl", "https://www.huijy.net/api/getCallback"); //回调地址
+                    //reqData.put("notifyUrl", "https://www.huijy.net/demo/getCallback"); //回调地址
                     //reqData.put("needReceipt", "00"); //电子发票功能 微信开具电子 发票使用
                     //reqData.put("ledgerAccountFlag", "00"); //是否做分账 分账交易使 用;00:做; 01:不做;不传默认为不做分账
                     //reqData.put("ledgerAccountEffectTime", "00"); //分账有效时间 单位为天;是 否做分账选择 00 时该字段必传

+ 14 - 0
YijiaRestful/src/main/java/com/platform/yijia/dao/CustomerPointsRecordMapper.java

@@ -0,0 +1,14 @@
+package com.platform.yijia.dao;
+
+
+import com.platform.yijia.pojo.CustomerPointsRecord;
+
+import java.util.List;
+
+public interface CustomerPointsRecordMapper {
+    //获取用户积分信息
+    List<CustomerPointsRecord> getCustomerPointsRecordList(CustomerPointsRecord customerPointsRecord);
+
+    //插入用户积分信息
+    void insertCustomerPointsInfo(CustomerPointsRecord customerPointsRecord);
+}

+ 22 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerPointsRecord.java

@@ -0,0 +1,22 @@
+package com.platform.yijia.pojo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 客户积分记录实体类
+ */
+@Data
+public class CustomerPointsRecord {
+    private Integer id;             //主键
+    private String unionId;         //微信用户唯一标识
+    private String customerName;    //用户名称
+    private String recordType;      //积分记录类型:-,消耗; +,增加;
+    private Integer integral;       //积分
+    //@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;        //创建时间
+    private Integer stationId;      //油站ID
+    private String stationName;     //油站名称
+}

+ 15 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/CustomerPointsRecordService.java

@@ -0,0 +1,15 @@
+package com.platform.yijia.service;
+
+
+import com.platform.yijia.pojo.CustomerPointsRecord;
+
+import java.util.List;
+
+public interface CustomerPointsRecordService {
+
+    //获取用户积分信息
+    List<CustomerPointsRecord> getCustomerPointsRecordList(CustomerPointsRecord customerPointsRecord);
+
+    //插入用户积分信息
+    void insertCustomerPointsInfo(CustomerPointsRecord customerPointsRecord);
+}

+ 26 - 0
YijiaRestful/src/main/java/com/platform/yijia/service/impl/CustomerPointsRecordServiceImpl.java

@@ -0,0 +1,26 @@
+package com.platform.yijia.service.impl;
+import com.platform.yijia.dao.CustomerPointsRecordMapper;
+import com.platform.yijia.pojo.CustomerPointsRecord;
+import com.platform.yijia.service.CustomerPointsRecordService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@Service("customerPointsRecordService")
+public class CustomerPointsRecordServiceImpl implements CustomerPointsRecordService {
+    @Resource
+    private CustomerPointsRecordMapper customerPointsRecordMapper;
+
+    //查询客户在该油站积分记录
+    @Override
+    public List<CustomerPointsRecord> getCustomerPointsRecordList(CustomerPointsRecord customerPointsRecord) {
+        return customerPointsRecordMapper.getCustomerPointsRecordList(customerPointsRecord);
+    }
+
+    //新增客户积分记录
+    @Override
+    public void insertCustomerPointsInfo(CustomerPointsRecord customerPointsRecord) {
+        customerPointsRecordMapper.insertCustomerPointsInfo(customerPointsRecord);
+    }
+}

+ 87 - 0
YijiaRestful/src/main/resources/mapper/CustomerPointsRecordMapper.xml

@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.platform.yijia.dao.CustomerPointsRecordMapper">
+  <!--返回结果-->
+  <resultMap id="BaseResultMap" type="com.platform.yijia.pojo.CustomerPointsRecord">
+    <id     column="id"              jdbcType="INTEGER"    property="id" />
+    <result column="union_id"        jdbcType="VARCHAR"    property="unionId" />
+    <result column="customer_name"   jdbcType="VARCHAR"    property="customerName" />
+    <result column="record_type"     jdbcType="VARCHAR"    property="recordType" />
+    <result column="integral"        jdbcType="INTEGER"    property="integral" />
+    <result column="station_id"      jdbcType="INTEGER"    property="stationId" />
+    <result column="station_name"    jdbcType="VARCHAR"    property="stationName" />
+    <result column="create_time"     jdbcType="TIMESTAMP"  property="createTime" />
+  </resultMap>
+
+  <!--查询列-->
+  <sql id="Base_Column_List">
+    id, union_id, customer_name, record_type, integral, station_id, station_name, create_time
+  </sql>
+
+  <!--查询客户积分信息-->
+  <select id="getCustomerPointsRecordList" resultMap="BaseResultMap" parameterType="com.platform.yijia.pojo.CustomerPointsRecord">
+    SELECT
+        <include refid="Base_Column_List" />
+    FROM customer_points_record
+    <where>
+        <if test="unionId !=null and unionId !=''">
+          union_id = #{unionId}
+        </if>
+      <if test="stationId !=null and stationId !=''">
+        AND station_id = #{stationId}
+      </if>
+    </where>
+  </select>
+
+  <!--插入客户积分表-->
+  <insert id="insertCustomerPointsInfo" parameterType="com.platform.yijia.pojo.CustomerPoints">
+    INSERT INTO customer_points_record
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="unionId !=null">
+        union_id,
+      </if>
+      <if test="customerName !=null">
+        customer_name,
+      </if>
+      <if test="recordType !=null">
+        record_type,
+      </if>
+      <if test="integral !=null">
+        integral,
+      </if>
+      <if test="stationId !=null">
+        station_id,
+      </if>
+      <if test="stationName !=null">
+        station_name,
+      </if>
+      <if test="createTime !=null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="unionId !=null">
+        #{unionId},
+      </if>
+      <if test="customerName !=null">
+        #{customerName},
+      </if>
+      <if test="recordType !=null">
+        #{recordType},
+      </if>
+      <if test="integral !=null">
+        #{integral},
+      </if>
+      <if test="stationId !=null">
+        #{stationId},
+      </if>
+      <if test="stationName !=null">
+        #{stationName},
+      </if>
+      <if test="createTime !=null">
+        #{createTime},
+      </if>
+    </trim>
+  </insert>
+
+</mapper>