Parcourir la source

苹果游客帐号创建

小么熊🐻 il y a 1 an
Parent
commit
9fa9cf456c

+ 52 - 4
jsjp-admin/src/main/java/com/miaxis/app/controller/applePay/ApplePayController.java

@@ -9,8 +9,14 @@ import com.miaxis.common.constant.Constants;
 import com.miaxis.common.core.controller.BaseController;
 import com.miaxis.common.core.domain.Response;
 import com.miaxis.common.core.domain.entity.SysDictData;
+import com.miaxis.common.core.domain.entity.UserInfo;
 import com.miaxis.common.exception.CustomException;
 import com.miaxis.common.utils.IosVerifyUtil;
+import com.miaxis.common.utils.SecurityUtils;
+import com.miaxis.common.utils.uuid.UUID;
+import com.miaxis.newgzpt.domain.GzptUserInfo;
+import com.miaxis.newgzpt.dto.GzptAppleInfoDTO;
+import com.miaxis.newgzpt.service.IGzptUserInfoService;
 import com.miaxis.order.service.IOrderInfoService;
 import com.miaxis.system.service.ISysDictDataService;
 import io.swagger.annotations.Api;
@@ -18,13 +24,13 @@ import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.core.parameters.P;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.Random;
 
 /**
  * 【小程序-微信支付】Controller
@@ -51,6 +57,10 @@ public class ApplePayController extends BaseController {
 
     @Autowired
     private ISysDictDataService dictDataService;
+
+    @Autowired
+    private IGzptUserInfoService userInfoService;
+
     /**
      * TransactionID:苹果配置的产品id
      * String receipt_data:需要客户端传过来的参数2
@@ -119,6 +129,44 @@ public class ApplePayController extends BaseController {
     }
 
 
+    /**
+     * 根据用户帐号获取
+     */
+    @GetMapping("/getAppleUserInfo")
+    @ApiOperation("获取学员详细信息")
+    public Response<GzptUserInfo> getAppleUserInfo(GzptAppleInfoDTO appleInfoDTO) {
+
+        GzptUserInfo userInfo = userInfoService.getAppleUserInfo(appleInfoDTO);
+
+        if(userInfo==null) {  //不存在用户
+            userInfo = new GzptUserInfo();
+            String userName = "游客"+System.currentTimeMillis()/100;
+            userInfo.setUserName(userName);
+            userInfo.setSex("1");
+            userInfo.setLogincode(appleInfoDTO.getLogincode());
+            userInfo.setCartype("C1");
+            userInfo.setPassword("e10adc3949ba59abbe56e057f20f883e");
+            userInfo.setPhoto("https://t1-1305573081.file.myqcloud.com/jsjp/head/tourist.png");
+            userInfo.setNickname(userName);
+            userInfo.setCrdate(new Date());
+            userInfo.setPxjd(1);
+            userInfo.setMnStatus(0);
+            userInfo.setEduStatus(0);
+            Long id = userInfoService.saveGzptUserInfo(userInfo);
+            if(id!=null) {
+                userInfo.setId(id);
+                return Response.success(userInfo);
+            } else {
+                Response response = new Response(200,"新增失败");
+                return response;
+            }
+        } else {  //存在用户
+            return Response.success(userInfo);
+        }
+    }
+
+
+
     public static void main(String[] args) {
 
         String str = "com.kestrel.JSJPStudent.vip.212";

+ 12 - 0
jsjp-admin/src/test/java/com/miaxis/test/Test08.java

@@ -0,0 +1,12 @@
+package com.miaxis.test;
+
+public class Test08 {
+
+    public static void main(String[] args) {
+
+        System.out.println(System.currentTimeMillis()/100);
+
+
+    }
+
+}

+ 3 - 0
jsjp-service/src/main/java/com/miaxis/newgzpt/domain/GzptUserInfo.java

@@ -3,6 +3,7 @@ package com.miaxis.newgzpt.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -52,6 +53,7 @@ public class GzptUserInfo implements Serializable {
 
     @ApiModelProperty(value = "出生日期")
     @TableField("BIRTHDAY")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private String birthday;
 
     @ApiModelProperty(value = "电子邮箱")
@@ -120,6 +122,7 @@ public class GzptUserInfo implements Serializable {
 
     @ApiModelProperty(value = "注册时间")
     @TableField("CRDATE")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date crdate;
 
     @ApiModelProperty(value = "培训阶段 1、第一阶段 2、第二阶段 3、第三阶段 4、第四阶段")

+ 27 - 0
jsjp-service/src/main/java/com/miaxis/newgzpt/dto/GzptAppleInfoDTO.java

@@ -0,0 +1,27 @@
+package com.miaxis.newgzpt.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 学员基本信息表
+ * </p>
+ *
+ * @author ${author}
+ * @since 2021-03-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class GzptAppleInfoDTO implements Serializable {
+
+
+    @ApiModelProperty(value = "登录账号")
+    private String logincode;
+
+
+}

+ 5 - 0
jsjp-service/src/main/java/com/miaxis/newgzpt/mapper/GzptUserInfoMapper.java

@@ -2,6 +2,7 @@ package com.miaxis.newgzpt.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.miaxis.newgzpt.domain.GzptUserInfo;
+import com.miaxis.newgzpt.dto.GzptAppleInfoDTO;
 import com.miaxis.newgzpt.dto.GzptUserInfoDTO;
 import com.miaxis.newgzpt.vo.GzptExamInfoVO;
 
@@ -24,4 +25,8 @@ public interface GzptUserInfoMapper extends BaseMapper<GzptUserInfo> {
     GzptUserInfo getInfoById(Long id);
 
     List<GzptExamInfoVO> getUserScoreByOutId(Long stuOutId);
+
+    GzptUserInfo getAppleUserInfo(GzptAppleInfoDTO appleInfoDTO);
+
+    Long saveGzptUserInfo(GzptUserInfo gzptUserInfo);
 }

+ 5 - 0
jsjp-service/src/main/java/com/miaxis/newgzpt/service/IGzptUserInfoService.java

@@ -2,6 +2,7 @@ package com.miaxis.newgzpt.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.miaxis.newgzpt.domain.GzptUserInfo;
+import com.miaxis.newgzpt.dto.GzptAppleInfoDTO;
 import com.miaxis.newgzpt.dto.GzptUserInfoDTO;
 import com.miaxis.newgzpt.vo.GzptExamInfoVO;
 
@@ -22,7 +23,11 @@ public interface IGzptUserInfoService extends IService<GzptUserInfo> {
 
     GzptUserInfo getUserWxlogin(GzptUserInfoDTO userInfoDTO);
 
+    GzptUserInfo getAppleUserInfo(GzptAppleInfoDTO appleInfoDTO);
+
     GzptUserInfo getInfoById(Long id);
 
     List<GzptExamInfoVO> getUserScoreByOutId(Long stuOutId);
+
+    Long saveGzptUserInfo(GzptUserInfo userInfo);
 }

+ 13 - 0
jsjp-service/src/main/java/com/miaxis/newgzpt/service/impl/GzptUserInfoServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.miaxis.common.annotation.DataSource;
 import com.miaxis.common.enums.DataSourceTypeEnum;
 import com.miaxis.newgzpt.domain.GzptUserInfo;
+import com.miaxis.newgzpt.dto.GzptAppleInfoDTO;
 import com.miaxis.newgzpt.dto.GzptUserInfoDTO;
 import com.miaxis.newgzpt.mapper.GzptUserInfoMapper;
 import com.miaxis.newgzpt.service.IGzptUserInfoService;
@@ -40,6 +41,12 @@ public class GzptUserInfoServiceImpl extends ServiceImpl<GzptUserInfoMapper, Gzp
         return mapper.getUserByWxlogin(userInfoDTO);
     }
 
+    @Override
+    public GzptUserInfo getAppleUserInfo(GzptAppleInfoDTO appleInfoDTO) {
+        return mapper.getAppleUserInfo(appleInfoDTO);
+    }
+
+
     @Override
     public GzptUserInfo getInfoById(Long id) {
         return  mapper.getInfoById(id);
@@ -49,4 +56,10 @@ public class GzptUserInfoServiceImpl extends ServiceImpl<GzptUserInfoMapper, Gzp
     public List<GzptExamInfoVO> getUserScoreByOutId(Long stuOutId) {
         return mapper.getUserScoreByOutId(stuOutId);
     }
+
+
+    @Override
+    public Long saveGzptUserInfo(GzptUserInfo userInfo) {
+        return mapper.saveGzptUserInfo(userInfo);
+    }
 }

+ 24 - 0
jsjp-service/src/main/resources/mapper/newgzpt/GzptUserInfoMapper.xml

@@ -29,6 +29,30 @@
     </select>
 
 
+    <select id="getAppleUserInfo" parameterType="com.miaxis.newgzpt.dto.GzptUserInfoDTO" resultType="com.miaxis.newgzpt.domain.GzptUserInfo">
+        select * from gzpt_user_info g where g.id =
+                                             (select max(id) from gzpt_user_info g where g.logincode=#{logincode} and apptype=2)
+    </select>
+
+
+    <insert id="saveGzptUserInfo" parameterType="com.miaxis.newgzpt.domain.GzptUserInfo">
+        insert into gzpt_user_info (id,user_name,sex,logincode,CARTYPE,PASSWORD,PHOTO
+        ,NICKNAME,APPTYPE,CRDATE,pxjd,MN_STATUS,EDU_STATUS)
+        VALUES (seq_gzpt_user_info.nextval, #{userName},
+                                            #{sex},
+                                            #{logincode},
+                                             #{cartype},
+                                             #{password},
+                                             #{photo},
+                                             #{nickname},
+                                             #{apptype,jdbcType=VARCHAR},
+                                             #{crdate},
+                                             #{pxjd,jdbcType=NUMERIC},
+                                            #{mnStatus,jdbcType=NUMERIC},
+                                            #{eduStatus,jdbcType=NUMERIC})
+    </insert>
+
+
 
     <select id="getInfoById"  resultType="com.miaxis.newgzpt.domain.GzptUserInfo">
         select * from GZPT_USER_INFO where id =#{id,jdbcType=NUMERIC}