Procházet zdrojové kódy

1.用户登录插入积分表2.添加unionId

jk-GitHub-coder před 4 roky
rodič
revize
24e707b046

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

@@ -5,7 +5,9 @@ import com.google.gson.Gson;
 import com.platform.yijia.param.request.AppUserInfoRequest;
 import com.platform.yijia.pojo.AppUserInfo;
 import com.platform.yijia.pojo.CustomerManage;
+import com.platform.yijia.pojo.CustomerPoints;
 import com.platform.yijia.service.AppUserInfoService;
+import com.platform.yijia.service.CustomerPointsService;
 import com.platform.yijia.service.PayOrderService;
 import com.platform.yijia.service.StationService;
 import com.platform.yijia.utils.CodeMsg;
@@ -20,7 +22,6 @@ import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -35,6 +36,8 @@ public class AppUserInfoController {
     private AppUserInfoService appUserInfoService;
     @Resource
     private StationService stationService;
+    @Resource
+    private CustomerPointsService customerPointsService;
 //    String appId = "wxe1135cd390b38a54";        //微信小程序appID
 //    String appSecret = "0532c7d9ae876c4ad636df0b1e3b9ddb";      //微信小程序密钥
 
@@ -85,6 +88,7 @@ public class AppUserInfoController {
         ResultData resultData=null;
         try{
             AppUserInfo appUserInfo =new AppUserInfo();
+            CustomerPoints customerPoints =  new CustomerPoints();
             String openId = "";     //此参数用于查询该用户是否已注册过
             if(request.getUserType()!=null){
                 //1-微信公众号
@@ -93,19 +97,23 @@ public class AppUserInfoController {
                     appUserInfo.setBlogToken(request.getBlogToken());
                     openId = request.getBlogOpenid();
                     appUserInfo.setBlogOpenid(openId);
+                    customerPoints.setBlogOpenId(openId);
                  //2-微信小程序
                 }else if(request.getUserType().equals("2") &&StringUtils.isNotBlank(request.getMinaOpenid())){
                     appUserInfo.setUserType(request.getUserType());
                     appUserInfo.setMinaToken(request.getMinaToken());
                     openId = request.getMinaOpenid();
                     appUserInfo.setMinaOpenid(openId);
+                    customerPoints.setMinaOpenId(openId);
                 }
             }
             if(StringUtils.isNotBlank(request.getBlogNickName())){
                 appUserInfo.setBlogNickName(request.getBlogNickName());
+                customerPoints.setCustomerName(request.getBlogNickName());
             }
             if(StringUtils.isNotBlank(request.getMobilePhone())){
                 appUserInfo.setMobilePhone(request.getMobilePhone());
+                customerPoints.setMobilePhone(request.getMobilePhone());
             }
             if(StringUtils.isNotBlank(request.getBlogProfilePhoto())){
                 appUserInfo.setBlogProfilePhoto(request.getBlogProfilePhoto());
@@ -113,6 +121,14 @@ public class AppUserInfoController {
 
             appUserInfo.setRegisteDate(new Date());
             appUserInfo.setUpdateDate(new Date());
+            appUserInfo.setUnionId(request.getUnionId());
+
+            //customerPoints.setCreateTime(new Date());
+            customerPoints.setUnionId(request.getUnionId());
+            customerPoints.setPoints(0);
+            customerPoints.setConsumptionPoints(0);
+            customerPoints.setAccumulatePoints(0);
+            customerPoints.setInvalidPoints(0);
 
             if(StringUtils.isNotBlank(request.getSexFlag())){
                 appUserInfo.setSexFlag(request.getSexFlag());
@@ -124,9 +140,14 @@ public class AppUserInfoController {
             //判断该用户是否已存在
             int count = appUserInfoService.isExistAppUser(params);
             if(count > 0){
+//                boolean boo = customerPointsService.isExistCustomerPointsInfo(customerPoints);
+//                if(!boo){
+//                    customerPointsService.insertCustomerPointsInfo(customerPoints);
+//                }
                 resultData = ResultData.error(CodeMsg.USER_EXSIST);
             }else {
                 appUserInfoService.AddAppUserInfo(appUserInfo);
+//                customerPointsService.insertCustomerPointsInfo(customerPoints);
                 resultData = ResultData.success(CodeMsg.SUCCESS);
             }
         }catch (Exception e){

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

@@ -701,34 +701,6 @@ public class PayController {
                                     }
                                     //更新客户余额积分
                                     customerPointsService.updateCustomerPointsInfo(customerPoints);
-                                }else {     //不存在
-                                    String ruleType = rule.get(0).getRuleType();   //获取积分规则
-                                    switch (ruleType){
-                                        case "1":   //以订单实付累计
-                                            //已存在:现有余额积分 + 本次消费所获得的积分
-                                            BigDecimal amt1 = new BigDecimal(infoMap.get("amt").toString());  //本次消费实收金额
-                                            if(amt1.compareTo(rule.get(0).getRuleAmt()) ==1){
-                                                //计算积分并取整
-                                                BigDecimal integral = amt1.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
-                                                customerPoints.setPoints(Integer.valueOf(integral.toString()));
-                                                customerPoints.setAccumulatePoints(Integer.valueOf(integral.toString()));
-                                            }
-                                            break;
-                                        case "2":   //以订单应付累计
-                                            //已存在:现有余额积分 + 本次消费所获得的积分
-                                            BigDecimal receivableAmt = new BigDecimal(infoMap.get("receivableAmt").toString());  //本次消费实收金额
-                                            if(receivableAmt.compareTo(rule.get(0).getRuleAmt()) ==1){
-                                                //计算积分并取整
-                                                BigDecimal integral = receivableAmt.divide(rule.get(0).getSaleAmt(), 0).multiply(rule.get(0).getIntegral()).setScale(0, BigDecimal.ROUND_DOWN);
-                                                customerPoints.setPoints(Integer.valueOf(integral.toString()));
-                                                customerPoints.setAccumulatePoints(Integer.valueOf(integral.toString()));
-                                            }
-                                            break;
-                                        case "3":   //以加油升数
-                                            break;
-
-                                    }
-                                    customerPointsService.insertCustomerPointsInfo(customerPoints);
                                 }
                             }*/
 //========================================================================================================================================================//

+ 4 - 88
YijiaRestful/src/main/java/com/platform/yijia/param/request/AppUserInfoRequest.java

@@ -1,11 +1,14 @@
 package com.platform.yijia.param.request;
 
+import lombok.Data;
+
 /***
  * <Title> AppUserInfoRequest </Title>
  * <Description> 公众号小程序注册用户信息实体类  </Description>
  * @date  2020年12月15日
  * @Author JK
  */
+@Data
 public class AppUserInfoRequest {
     private String userType;        //注册类型:1-微信公众号;2-微信小程序
     private String blogOpenid;      //公众号的openid
@@ -18,92 +21,5 @@ public class AppUserInfoRequest {
     private String minaToken;       //小程序用户token信息
     private String blogProfilePhoto;    //用户头像
     private String updateDate;          //更新时间
-
-    public String getUserType() {
-        return userType;
-    }
-
-    public void setUserType(String userType) {
-        this.userType = userType;
-    }
-
-    public String getBlogOpenid() {
-        return blogOpenid;
-    }
-
-    public void setBlogOpenid(String blogOpenid) {
-        this.blogOpenid = blogOpenid;
-    }
-
-    public String getMinaOpenid() {
-        return minaOpenid;
-    }
-
-    public void setMinaOpenid(String minaOpenid) {
-        this.minaOpenid = minaOpenid;
-    }
-
-    public String getMobilePhone() {
-        return mobilePhone;
-    }
-
-    public void setMobilePhone(String mobilePhone) {
-        this.mobilePhone = mobilePhone;
-    }
-
-    public String getBlogNickName() {
-        return blogNickName;
-    }
-
-    public void setBlogNickName(String blogNickName) {
-        this.blogNickName = blogNickName;
-    }
-
-    public String getSexFlag() {
-        return sexFlag;
-    }
-
-    public void setSexFlag(String sexFlag) {
-        this.sexFlag = sexFlag;
-    }
-
-    public String getRegisteDate() {
-        return registeDate;
-    }
-
-    public void setRegisteDate(String registeDate) {
-        this.registeDate = registeDate;
-    }
-
-    public String getBlogToken() {
-        return blogToken;
-    }
-
-    public void setBlogToken(String blogToken) {
-        this.blogToken = blogToken;
-    }
-
-    public String getMinaToken() {
-        return minaToken;
-    }
-
-    public void setMinaToken(String minaToken) {
-        this.minaToken = minaToken;
-    }
-
-    public String getBlogProfilePhoto() {
-        return blogProfilePhoto;
-    }
-
-    public void setBlogProfilePhoto(String blogProfilePhoto) {
-        this.blogProfilePhoto = blogProfilePhoto;
-    }
-
-    public String getUpdateDate() {
-        return updateDate;
-    }
-
-    public void setUpdateDate(String updateDate) {
-        this.updateDate = updateDate;
-    }
+    private String unionId;          //微信用户unionId
 }

+ 11 - 1
YijiaRestful/src/main/java/com/platform/yijia/pojo/AppUserInfo.java

@@ -111,6 +111,16 @@ public class AppUserInfo {
      */
     private Date updateDate;
 
+    private String unionId;
+
+    public String getUnionId() {
+        return unionId;
+    }
+
+    public void setUnionId(String unionId) {
+        this.unionId = unionId;
+    }
+
     /**
      * This method was generated by MyBatis Generator.
      * This method returns the value of the database column app_user_info.user_id
@@ -398,4 +408,4 @@ public class AppUserInfo {
     public void setUpdateDate(Date updateDate) {
         this.updateDate = updateDate;
     }
-}
+}

+ 1 - 0
YijiaRestful/src/main/java/com/platform/yijia/pojo/CustomerPoints.java

@@ -23,5 +23,6 @@ public class CustomerPoints {
     private Date recentConsumptionDate;          //用户最近消费积分时间
     private Integer stationId;                   //油站ID
     private String stationName;                  //油站名称
+    private Date createTime;                     //创建时间
 
 }

+ 12 - 2
YijiaRestful/src/main/resources/mapper/CustomerPointsMapper.xml

@@ -16,12 +16,13 @@
     <result column="recent_consumption_date" jdbcType="DATE" property="recentConsumptionDate" />
     <result column="station_id" jdbcType="INTEGER" property="stationId" />
     <result column="station_name" jdbcType="VARCHAR" property="stationName" />
+    <result column="create_time" jdbcType="DATE" property="createTime" />
   </resultMap>
 
   <!--查询列-->
   <sql id="Base_Column_List">
     id, union_id, blog_openid, mina_openid, mobile_phone, customer_name, points, consumption_points, accumulate_points, invalid_points,
-    recent_consumption_date, station_id, station_name
+    recent_consumption_date, station_id, station_name, create_time
   </sql>
 
   <!--查询客户积分信息-->
@@ -79,6 +80,9 @@
       <if test="stationName !=null">
         station_name,
       </if>
+      <if test="createTime !=null">
+        create_time,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="unionId !=null">
@@ -117,6 +121,9 @@
       <if test="stationName !=null">
         #{stationName},
       </if>
+      <if test="createTime !=null">
+        #{createTime},
+      </if>
     </trim>
   </insert>
 
@@ -159,7 +166,10 @@
         station_id =#{stationId},
       </if>
       <if test="stationName !=null">
-        station_name =#{stationName}
+        station_name =#{stationName},
+      </if>
+      <if test="createTime !=null">
+        create_time =#{createTime}
       </if>
     </set>
     <where>