瀏覽代碼

add:用户我的钱包初次提交

lyx 1 月之前
父節點
當前提交
a813bc6bd8

+ 11 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeUser.java

@@ -122,4 +122,15 @@ public class LifeUser implements Serializable {
     @TableField("bind_invite_code")
     private String bindInviteCode;
 
+    @ApiModelProperty(value = "支付宝账号")
+    @TableField("alipay_account")
+    private String alipayAccount;
+
+    @ApiModelProperty(value = "用户余额")
+    @TableField("money")
+    private Integer money;
+
+    @ApiModelProperty(value = "支付密码")
+    @TableField("pay_password")
+    private String payPassword;
 }

+ 35 - 0
alien-store/src/main/java/shop/alien/store/controller/LifeUserController.java

@@ -1,5 +1,6 @@
 package shop.alien.store.controller;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
@@ -192,4 +193,38 @@ public class LifeUserController {
         log.info("LifeUserController.getUserByPhone?phone={}", phone);
         return R.data(service.getUserByPhone(phone));
     }
+
+    /**
+     * 支付设置增加支付宝账户
+     */
+    @ApiOperation("支付设置增加支付宝账户")
+    @PostMapping("/addAlipayAccount")
+    public R<Integer> addAlipayAccount(@RequestBody LifeUserVo lifeUserVo) {
+        log.info("LifeUserController.addAlipayAccount?storeUserVo={}", lifeUserVo);
+        LambdaUpdateWrapper<LifeUser> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
+        lambdaUpdateWrapper.set(LifeUser :: getAlipayAccount, lifeUserVo.getAlipayAccount());
+        lambdaUpdateWrapper.eq(LifeUser :: getId, lifeUserVo.getId());
+        return R.data(lifeUserMapper.update(null,lambdaUpdateWrapper));
+    }
+
+    /**
+     * 根据id判断是否有支付密码
+     */
+    @ApiOperation("是否有支付密码")
+    @GetMapping("/havePayPassword")
+    public R<Boolean> havePayPassword(@RequestParam String userId,@RequestParam(required = false) String password){
+        log.info("LifeUserController.havePayPassword?userId={},password={}",userId,password);
+        return lifeUserService.havePayPassword(userId,password);
+    }
+
+    @ApiOperation("修改支付密码")
+    @ApiOperationSupport(order = 5)
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "payPassword", value = "支付密码", dataType = "String", paramType = "query", required = true)})
+    @GetMapping("/setPayPassword")
+    public R<Boolean> setPayPassword(Integer id, String payPassword) {
+        if (lifeUserService.setPayPassword(id, payPassword)) {
+            return R.success("修改成功");
+        }
+        return R.fail("修改失败");
+    }
 }

+ 41 - 1
alien-store/src/main/java/shop/alien/store/service/LifeUserService.java

@@ -15,17 +15,18 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
+import shop.alien.entity.result.R;
 import shop.alien.entity.store.LifeFans;
 import shop.alien.entity.store.LifeNotice;
 import shop.alien.entity.store.LifeUser;
 import shop.alien.entity.store.vo.LifeMessageVo;
 import shop.alien.entity.store.vo.LifeUserVo;
 import shop.alien.entity.store.vo.WebSocketVo;
-import shop.alien.store.config.BaseRedisService;
 import shop.alien.mapper.LifeFansMapper;
 import shop.alien.mapper.LifeMessageMapper;
 import shop.alien.mapper.LifeNoticeMapper;
 import shop.alien.mapper.LifeUserMapper;
+import shop.alien.store.config.BaseRedisService;
 import shop.alien.store.config.WebSocketProcess;
 import shop.alien.store.util.FunctionMagic;
 import shop.alien.util.common.JwtUtil;
@@ -301,4 +302,43 @@ public class LifeUserService extends ServiceImpl<LifeUserMapper, LifeUser> {
             log.error("LifeUserService webSocketProcess Stack={}", e);
         }
     }
+
+    public R havePayPassword(String userId, String password) {
+        LifeUser lifeUser = lifeUserMapper.selectById(userId);
+        HashMap<Object, Object> returnMap = new HashMap<>();
+        returnMap.put("code",200);
+        if (null == lifeUser) {
+            returnMap.put("message","未查询到用户");
+            returnMap.put("data","false");
+            return R.data(returnMap);
+        }
+        if( null == lifeUser.getPayPassword()){
+            returnMap.put("message","用户未设置支付密码");
+            returnMap.put("data","false");
+            return R.data(returnMap);
+        } else if(null != password){
+            if( !password.equals(lifeUser.getPayPassword())){
+                returnMap.put("message","密码错误");
+                returnMap.put("data","false");
+                return R.data(returnMap);
+            }
+        }
+        returnMap.put("data","true");
+        returnMap.put("message","用户已设置支付密码");
+        return R.data(returnMap);
+    }
+
+    /**
+     * 修改支付密码
+     *
+     * @param id          主键
+     * @param payPassword 支付密码
+     * @return boolean
+     */
+    public boolean setPayPassword(Integer id, String payPassword) {
+        LifeUser lifeUser = new LifeUser();
+        lifeUser.setId(id);
+        lifeUser.setPayPassword(payPassword);
+        return this.updateById(lifeUser);
+    }
 }