浏览代码

采美豆修改

plf 4 年之前
父节点
当前提交
06fd4680ff

+ 8 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -100,4 +100,12 @@ public interface ClubMapper {
      * @return
      */
     List<BeansHistoryVo> findAllBeansHistory(@Param("userId") Integer userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") Integer type);
+
+    /**
+     * 查询今天是否有登录送豆
+     *
+     * @param userId
+     * @return
+     */
+    Integer findLoginBeans(Integer userId);
 }

+ 3 - 3
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -176,7 +176,7 @@ public class ClubServiceImpl implements ClubService {
     }
 
     private void saveUserBeans(UserVo user) {
-        //机构完善资料,送20采美豆
+        //机构完善资料,送500采美豆
         UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
         beansHistory.setUserId(user.getUserId());
         if (user.getUserIdentity() == 4) {
@@ -187,12 +187,12 @@ public class ClubServiceImpl implements ClubService {
             beansHistory.setBeansType(4);
         }
         beansHistory.setType(1);
-        beansHistory.setNum(20);
+        beansHistory.setNum(500);
         beansHistory.setPushStatus(0);
         beansHistory.setAddTime(new Date());
         registerMapper.insertBeansHistory(beansHistory);
         Integer userBeans = user.getUserBeans();
-        userBeans = userBeans == null ? 20 : userBeans + 20;
+        userBeans = userBeans == null ? 500 : userBeans + 500;
         clubMapper.updateUserBeans(user.getUserId(), userBeans);
     }
 

+ 25 - 4
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -5,16 +5,15 @@ import com.alibaba.fastjson.JSONObject;
 import com.caimei365.user.components.CommonService;
 import com.caimei365.user.components.RedisService;
 import com.caimei365.user.components.WeChatService;
-import com.caimei365.user.mapper.BaseMapper;
-import com.caimei365.user.mapper.LoginMapper;
-import com.caimei365.user.mapper.OperationMapper;
-import com.caimei365.user.mapper.RegisterMapper;
+import com.caimei365.user.mapper.*;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.AuthBindDto;
 import com.caimei365.user.model.dto.LoginPasswordDto;
 import com.caimei365.user.model.dto.ScanBindDto;
 import com.caimei365.user.model.po.OperationPo;
+import com.caimei365.user.model.po.UserBeansHistoryPo;
 import com.caimei365.user.model.vo.UserLoginVo;
+import com.caimei365.user.model.vo.UserVo;
 import com.caimei365.user.service.LoginService;
 import com.caimei365.user.utils.JwtUtil;
 import com.caimei365.user.utils.Md5Util;
@@ -49,6 +48,10 @@ public class LoginServiceImpl implements LoginService {
     private RegisterMapper registerMapper;
     @Resource
     private OperationMapper operationMapper;
+    @Resource
+    private ClubMapper clubMapper;
+    @Resource
+    private BaseMapper baseMapper;
 
     /**
      * 小程序邀请码过期天数
@@ -284,6 +287,24 @@ public class LoginServiceImpl implements LoginService {
                 return ResponseJson.error(-3, "您的企业账号审核未通过", loginUser);
             }
         }
+        if (null != loginUser.getUserIdentity() && (2 == loginUser.getUserIdentity() || 4 == loginUser.getUserIdentity())) {
+            Integer id = clubMapper.findLoginBeans(loginUser.getUserId());
+            if (id == null) {
+                //登录赠送10采美豆
+                UserVo user = baseMapper.getUserByUserId(loginUser.getUserId());
+                UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
+                beansHistory.setUserId(user.getUserId());
+                beansHistory.setBeansType(12);
+                beansHistory.setType(1);
+                beansHistory.setNum(10);
+                beansHistory.setPushStatus(0);
+                beansHistory.setAddTime(new Date());
+                registerMapper.insertBeansHistory(beansHistory);
+                Integer userBeans = user.getUserBeans();
+                userBeans = userBeans == null ? 10 : userBeans + 10;
+                clubMapper.updateUserBeans(loginUser.getUserId(), userBeans);
+            }
+        }
         return ResponseJson.success("登录成功", loginUser);
     }
 

+ 3 - 3
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -164,7 +164,7 @@ public class RegisterServiceImpl implements RegisterService {
         // 协销状态,已上线
         user.setServiceProviderStatus(90);
         //采美豆
-        user.setUserBeans(50);
+        user.setUserBeans(1000);
         /*
             保存数据库 user
          */
@@ -259,12 +259,12 @@ public class RegisterServiceImpl implements RegisterService {
         if (!smsFlag) {
             log.info("短信发送失败,手机号:" + clubRegisterDto.getBindMobile());
         }
-        //新用户自主注册送50采美豆
+        //新用户自主注册送1000采美豆
         UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
         beansHistory.setUserId(user.getUserId());
         beansHistory.setBeansType(1);
         beansHistory.setType(1);
-        beansHistory.setNum(50);
+        beansHistory.setNum(1000);
         beansHistory.setPushStatus(0);
         beansHistory.setAddTime(date);
         registerMapper.insertBeansHistory(beansHistory);

+ 12 - 1
src/main/resources/mapper/ClubMapper.xml

@@ -98,7 +98,7 @@
           user_beans_history
         WHERE
           pushStatus = 0
-          AND beansType IN (1, 2, 3, 4, 8)
+          AND beansType IN (1, 2, 3, 4, 8, 12)
           AND delFlag = 0
           AND userId = #{userId}
         ORDER BY
@@ -141,4 +141,15 @@
           </if>
         ORDER BY addTime DESC
     </select>
+
+    <select id="findLoginBeans" resultType="integer">
+        SELECT
+          id
+        FROM
+          user_beans_history
+        WHERE
+          beansType IN (1,12)
+          AND DATE_FORMAT(addTime, '%Y-%m-%d') = DATE_FORMAT(NOW(), '%Y-%m-%d')
+          AND userId = #{userId}
+    </select>
 </mapper>