Kaynağa Gözat

Merge remote-tracking branch 'origin/developerB' into developer

chao 3 yıl önce
ebeveyn
işleme
f862f3f6be

+ 70 - 35
src/main/java/com/caimei365/user/controller/ClubApi.java

@@ -2,9 +2,11 @@ package com.caimei365.user.controller;
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubUpdateDto;
+import com.caimei365.user.model.vo.BeansHistoryVo;
 import com.caimei365.user.service.ClubService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -18,7 +20,7 @@ import java.util.Map;
  * @author : Charles
  * @date : 2021/3/4
  */
-@Api(tags="机构用户API")
+@Api(tags = "机构用户API")
 @RestController
 @RequiredArgsConstructor
 @RequestMapping("/user/club")
@@ -28,12 +30,11 @@ public class ClubApi {
 
     /**
      * 根据用户Id查询机构资料
-     *
+     * <p>
      * spi旧接口:/user/club/applicationData
      *
      * @param userId 用户Id
-     *
-     * @return Map(userPo,clubPo)
+     * @return Map(userPo, clubPo)
      */
     @ApiOperation("查询机构资料")
     @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
@@ -44,48 +45,47 @@ public class ClubApi {
 
     /**
      * 修改机构资料
-     *
+     * <p>
      * spi旧接口:/operation/modifiedData
-	 *
-	 * @param club ClubUpdateDto:{
-	 *                      clubId                 机构ID
-	 *                      userId                 用户ID
-	 *                      name                   机构名称
-	 *                      shortName                  机构简称(shortName)
-	 *                      contractEmail          邮箱(contractEmail1)
-	 *                      contractPhone          固定电话
-	 *                      linkMan                联系人(linkMan1)
-	 *                      provinceId             省Id
-	 *                      cityId                 市Id
-	 *                      townId                 县区Id
-	 *                      address                地址
-	 *                      shopPhoto              门头照(headpic)
-	 *                      businessLicense        营业执照(businessLicenseImage)
-	 *                      socialCreditCode       统一社会信用代码(socialCreditCode)
-	 *                      firstClubType          一级分类:医美=1和生美=2
-	 *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
-	 *                      department             医美分类下的门诊和医院则需要填写科室
-	 *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
-	 *                      mainProduct            主打项目(mainpro)
-	 *                      fax                    传真
-	 *                      profile                公司简介
-	 *                  }
-	 * @return ClubUpdateDto
+     *
+     * @param club ClubUpdateDto:{
+     *             clubId                 机构ID
+     *             userId                 用户ID
+     *             name                   机构名称
+     *             shortName                  机构简称(shortName)
+     *             contractEmail          邮箱(contractEmail1)
+     *             contractPhone          固定电话
+     *             linkMan                联系人(linkMan1)
+     *             provinceId             省Id
+     *             cityId                 市Id
+     *             townId                 县区Id
+     *             address                地址
+     *             shopPhoto              门头照(headpic)
+     *             businessLicense        营业执照(businessLicenseImage)
+     *             socialCreditCode       统一社会信用代码(socialCreditCode)
+     *             firstClubType          一级分类:医美=1和生美=2
+     *             secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *             department             医美分类下的门诊和医院则需要填写科室
+     *             medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *             mainProduct            主打项目(mainpro)
+     *             fax                    传真
+     *             profile                公司简介
+     *             }
+     * @return ClubUpdateDto
      */
-	@ApiOperation("更新机构资料")
+    @ApiOperation("更新机构资料")
     @PostMapping("/info/update")
     public ResponseJson<ClubUpdateDto> updateClubUserInfo(ClubUpdateDto club) {
-		return clubService.updateClubUserInfo(club);
+        return clubService.updateClubUserInfo(club);
     }
 
     /**
      * 机构个人中心
-     *
+     * <p>
      * spi旧接口:/personalCenter/myCentre
      *
      * @param userId 用户Id
-     *
-     * @return Map(userPo,clubPo)
+     * @return Map(userPo, clubPo)
      */
     @ApiOperation("机构个人中心(小程序-未调试)")
     @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
@@ -94,5 +94,40 @@ public class ClubApi {
         return clubService.getClubHomeData(userId);
     }
 
+    /**
+     * 赠送采美豆弹窗
+     */
+    @ApiOperation("赠送采美豆弹窗")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/obtain/beans")
+    public ResponseJson<BeansHistoryVo> beansPopUps(Integer userId) {
+        if (userId == null) {
+            return ResponseJson.error("参数异常", null);
+        }
+        return clubService.beansPopUps(userId);
+    }
+
+    /**
+     * 采美豆收支明细
+     */
+    @ApiOperation("采美豆收支明细")
+    @ApiImplicitParams({
+            @ApiImplicitParam(required = true, name = "userId", value = "用户Id"),
+            @ApiImplicitParam(required = true, name = "year", value = "年份"),
+            @ApiImplicitParam(required = true, name = "month", value = "月份"),
+            @ApiImplicitParam(required = true, name = "type", value = "收支类型:1收入,2支出"),
+            @ApiImplicitParam(required = false, name = "pageNum", value = "第几页"),
+            @ApiImplicitParam(required = false, name = "pageSize", value = "一页多少条")
+    })
+    @GetMapping("/beans/history")
+    public ResponseJson<Map<String, Object>> beansHistory(Integer userId, Integer year, Integer month, Integer type,
+                                                          @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
+                                                          @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
+        if (userId == null || year == null || month == null) {
+            return ResponseJson.error("参数异常",null);
+        }
+        return clubService.beansHistory(userId, year, month, type, pageNum, pageSize);
+    }
+
 
 }

+ 64 - 3
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -2,9 +2,13 @@ package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.ClubUpdateDto;
 import com.caimei365.user.model.po.UserPo;
+import com.caimei365.user.model.vo.BeansHistoryVo;
 import com.caimei365.user.model.vo.ClubVo;
 import com.caimei365.user.model.vo.OrderCountVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * Description
@@ -16,27 +20,84 @@ import org.apache.ibatis.annotations.Mapper;
 public interface ClubMapper {
     /**
      * 根据Id查询机构
-     * @param clubId    机构Id
+     *
+     * @param clubId 机构Id
      * @return ClubVo
      */
     ClubVo getClubById(Integer clubId);
 
     /**
      * 修改机构信息保存用户
-     * @param user   用户数据
+     *
+     * @param user 用户数据
      */
     void updateClubUserByUpdateInfo(UserPo user);
 
     /**
      * 修改机构信息保存机构
-     * @param club  机构数据
+     *
+     * @param club 机构数据
      */
     void updateClubByUpdateInfo(ClubUpdateDto club);
 
     /**
      * 获取订单数量
+     *
      * @param userId
      * @return
      */
     OrderCountVo getOrderCount(Integer userId);
+
+    /**
+     * 查询采美豆类型记录
+     *
+     * @param userId
+     * @param beansType
+     * @return
+     */
+    Integer findBeansHistoryByType(@Param("userId") Integer userId, @Param("beansType") int beansType);
+
+    /**
+     * 修改采美豆数量
+     *
+     * @param userId
+     * @param userBeans
+     */
+    void updateUserBeans(@Param("userId") Integer userId, @Param("userBeans") Integer userBeans);
+
+
+    /**
+     * 查询未推送的采美豆记录
+     *
+     * @param userId
+     * @return
+     */
+    BeansHistoryVo findBeansHistory(Integer userId);
+
+    /**
+     * 查询本状态下未推送的采美豆数量
+     *
+     * @param userId
+     * @param beansType
+     * @return
+     */
+    Integer findByBeansType(@Param("userId") Integer userId, @Param("beansType") int beansType);
+
+    /**
+     * 修改推送状态
+     *
+     * @param userId
+     */
+    void updatePushStatus(Integer userId);
+
+    /**
+     * 查询采美豆收支明细
+     *
+     * @param userId
+     * @param startTime
+     * @param endTime
+     * @param type
+     * @return
+     */
+    List<BeansHistoryVo> findAllBeansHistory(@Param("userId") Integer userId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("type") Integer type);
 }

+ 8 - 4
src/main/java/com/caimei365/user/mapper/RegisterMapper.java

@@ -2,10 +2,7 @@ package com.caimei365.user.mapper;
 
 import com.caimei365.user.model.dto.ClubOnlineDto;
 import com.caimei365.user.model.dto.ShopApplyDto;
-import com.caimei365.user.model.po.ClubPo;
-import com.caimei365.user.model.po.OperationPo;
-import com.caimei365.user.model.po.ShopPo;
-import com.caimei365.user.model.po.UserPo;
+import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.vo.ClubTemporaryVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -131,4 +128,11 @@ public interface RegisterMapper {
      * @return
      */
     ClubTemporaryVo getTemporary(Integer id);
+
+    /**
+     * 保存采美豆记录
+     *
+     * @param beansHistory
+     */
+    void insertBeansHistory(UserBeansHistoryPo beansHistory);
 }

+ 54 - 0
src/main/java/com/caimei365/user/model/po/UserBeansHistoryPo.java

@@ -0,0 +1,54 @@
+package com.caimei365.user.model.po;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import lombok.Data;
+
+/**
+ * user_beans_history
+ *
+ * @author
+ */
+@Data
+public class UserBeansHistoryPo implements Serializable {
+    private Integer id;
+
+    /**
+     * 用户id
+     */
+    private Integer userId;
+
+    /**
+     * 收支类型:1收入,2支出
+     */
+    private Integer type;
+
+    /**
+     * 采美豆类型:1注册机构,2升级会员机构,3普通机构完善资料,4会员机构完善资料,5下单,
+     * 6线上支付订单,7确认收货,8系统发放,9抵用退回,10抵用运费,11退款回收
+     */
+    private Integer beansType;
+
+    /**
+     * 主订单id
+     */
+    private Integer orderId;
+
+    /**
+     * 采美豆数量
+     */
+    private Integer num;
+
+    /**
+     * 推送状态:0未推送,1已推送
+     */
+    private Integer pushStatus;
+
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    private static final long serialVersionUID = 1L;
+}

+ 4 - 0
src/main/java/com/caimei365/user/model/po/UserPo.java

@@ -104,5 +104,9 @@ public class UserPo implements Serializable {
      * 用户状态,1正常,0冻结
      */
     private Integer validFlag;
+    /**
+     * 采美豆数量
+     */
+    private Integer userBeans;
 
 }

+ 38 - 0
src/main/java/com/caimei365/user/model/vo/BeansHistoryVo.java

@@ -0,0 +1,38 @@
+package com.caimei365.user.model.vo;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/6/8
+ */
+@Data
+public class BeansHistoryVo implements Serializable {
+    /**
+     * 采美豆类型:1注册机构,2升级会员机构,3普通机构完善资料,4会员机构完善资料,5下单,
+     * 6线上支付订单,7确认收货,8系统发放,9抵用退回,10抵用运费,11退款回收
+     */
+    private Integer beansType;
+
+    /**
+     * 采美豆数量
+     */
+    private Integer num;
+
+    /**
+     * 添加时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date addTime;
+
+    /**
+     * 收支类型:1收入,2支出
+     */
+    private Integer type;
+}

+ 5 - 0
src/main/java/com/caimei365/user/model/vo/UserVo.java

@@ -112,6 +112,11 @@ public class UserVo implements Serializable {
      */
     private String auditNote;
 
+    /**
+     * 采美豆数量
+     */
+    private Integer userBeans;
+
     /**
      * 审核不通过原因列表
      */

+ 47 - 26
src/main/java/com/caimei365/user/service/ClubService.java

@@ -2,7 +2,7 @@ package com.caimei365.user.service;
 
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubUpdateDto;
-import com.caimei365.user.model.po.ClubPo;
+import com.caimei365.user.model.vo.BeansHistoryVo;
 
 import java.util.Map;
 
@@ -15,9 +15,9 @@ import java.util.Map;
 public interface ClubService {
     /**
      * 根据用户Id查询机构资料
-     * @param userId 用户Id
      *
-     * @return Map(userPo,clubPo)
+     * @param userId 用户Id
+     * @return Map(userPo, clubPo)
      */
     ResponseJson<Map<String, Object>> getClubUserInfo(Integer userId);
 
@@ -25,28 +25,28 @@ public interface ClubService {
      * 修改机构资料
      *
      * @param club ClubUpgradeDto:{
-     *                      clubId                 机构ID
-     *                      userId                 用户ID
-     *                      name                   机构名称
-     *                      shortName                  机构简称(shortName)
-     *                      contractEmail          邮箱(contractEmail1)
-     *                      contractPhone          固定电话
-     *                      linkMan                联系人(linkMan1)
-     *                      provinceId             省Id
-     *                      cityId                 市Id
-     *                      townId                 县区Id
-     *                      address                地址
-     *                      shopPhoto              门头照(headpic)
-     *                      businessLicense        营业执照(businessLicenseImage)
-     *                      socialCreditCode       统一社会信用代码(socialCreditCode)
-     *                      firstClubType          一级分类:医美=1和生美=2
-     *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
-     *                      department             医美分类下的门诊和医院则需要填写科室
-     *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
-     *                      mainProduct            主打项目(mainpro)
-     *                      fax                    传真
-     *                      profile                公司简介
-     *                  }
+     *             clubId                 机构ID
+     *             userId                 用户ID
+     *             name                   机构名称
+     *             shortName                  机构简称(shortName)
+     *             contractEmail          邮箱(contractEmail1)
+     *             contractPhone          固定电话
+     *             linkMan                联系人(linkMan1)
+     *             provinceId             省Id
+     *             cityId                 市Id
+     *             townId                 县区Id
+     *             address                地址
+     *             shopPhoto              门头照(headpic)
+     *             businessLicense        营业执照(businessLicenseImage)
+     *             socialCreditCode       统一社会信用代码(socialCreditCode)
+     *             firstClubType          一级分类:医美=1和生美=2
+     *             secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *             department             医美分类下的门诊和医院则需要填写科室
+     *             medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *             mainProduct            主打项目(mainpro)
+     *             fax                    传真
+     *             profile                公司简介
+     *             }
      * @return ClubUpdateDto
      */
     ResponseJson<ClubUpdateDto> updateClubUserInfo(ClubUpdateDto club);
@@ -55,7 +55,28 @@ public interface ClubService {
      * 机构个人中心
      *
      * @param userId 用户Id
-     * @return Map(userPo,clubPo)
+     * @return Map(userPo, clubPo)
      */
     ResponseJson<Map<String, Object>> getClubHomeData(Integer userId);
+
+    /**
+     * 赠送采美豆弹窗
+     *
+     * @param userId 用户Id
+     * @return
+     */
+    ResponseJson<BeansHistoryVo> beansPopUps(Integer userId);
+
+    /**
+     * 采美豆收支明细
+     *
+     * @param userId   用户Id
+     * @param year     年份
+     * @param month    月份
+     * @param type     收支类型:1收入,2支出
+     * @param pageNum  第几页
+     * @param pageSize 一页多少条
+     * @return
+     */
+    ResponseJson<Map<String, Object>> beansHistory(Integer userId, Integer year, Integer month, Integer type, int pageNum, int pageSize);
 }

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

@@ -2,12 +2,15 @@ package com.caimei365.user.service.impl;
 
 import com.caimei365.user.mapper.BaseMapper;
 import com.caimei365.user.mapper.ClubMapper;
+import com.caimei365.user.mapper.RegisterMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.ClubUpdateDto;
-import com.caimei365.user.model.po.ClubPo;
+import com.caimei365.user.model.po.UserBeansHistoryPo;
 import com.caimei365.user.model.po.UserPo;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.ClubService;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.stereotype.Service;
@@ -30,6 +33,8 @@ public class ClubServiceImpl implements ClubService {
     private ClubMapper clubMapper;
     @Resource
     private BaseMapper baseMapper;
+    @Resource
+    private RegisterMapper registerMapper;
 
     /**
      * 根据用户Id查询机构资料
@@ -78,28 +83,28 @@ public class ClubServiceImpl implements ClubService {
      * 修改机构资料
      *
      * @param club ClubUpgradeDto:{
-     *                      clubId                 机构ID
-     *                      userId                 用户ID
-     *                      name                   机构名称
-     *                      shortName                  机构简称(shortName)
-     *                      contractEmail          邮箱(contractEmail1)
-     *                      contractPhone          固定电话
-     *                      linkMan                联系人(linkMan1)
-     *                      provinceId             省Id
-     *                      cityId                 市Id
-     *                      townId                 县区Id
-     *                      address                地址
-     *                      shopPhoto              门头照(headpic)
-     *                      businessLicense        营业执照(businessLicenseImage)
-     *                      socialCreditCode       统一社会信用代码(socialCreditCode)
-     *                      firstClubType          一级分类:医美=1和生美=2
-     *                      secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
-     *                      department             医美分类下的门诊和医院则需要填写科室
-     *                      medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
-     *                      mainProduct            主打项目(mainpro)
-     *                      fax                    传真
-     *                      profile                公司简介
-     *                  }
+     *             clubId                 机构ID
+     *             userId                 用户ID
+     *             name                   机构名称
+     *             shortName                  机构简称(shortName)
+     *             contractEmail          邮箱(contractEmail1)
+     *             contractPhone          固定电话
+     *             linkMan                联系人(linkMan1)
+     *             provinceId             省Id
+     *             cityId                 市Id
+     *             townId                 县区Id
+     *             address                地址
+     *             shopPhoto              门头照(headpic)
+     *             businessLicense        营业执照(businessLicenseImage)
+     *             socialCreditCode       统一社会信用代码(socialCreditCode)
+     *             firstClubType          一级分类:医美=1和生美=2
+     *             secondClubType         医美的二级分类:诊所=1、门诊=2、医院=3。  生美没有二级分类
+     *             department             医美分类下的门诊和医院则需要填写科室
+     *             medicalPracticeLicense 医美分类必须上传医疗执业许可证(medicalPracticeLicenseImg)
+     *             mainProduct            主打项目(mainpro)
+     *             fax                    传真
+     *             profile                公司简介
+     *             }
      * @return ClubUpdateDto
      */
     @Override
@@ -116,7 +121,7 @@ public class ClubServiceImpl implements ClubService {
         }
         if (StringUtils.isNotBlank(club.getContractEmail())) {
             Integer userIdByEmail = baseMapper.getUserIdByEmail(club.getContractEmail());
-            if (null != userIdByEmail && !userIdByEmail.equals(club.getUserId()) ) {
+            if (null != userIdByEmail && !userIdByEmail.equals(club.getUserId())) {
                 return ResponseJson.error("该邮箱已被使用", null);
             }
         }
@@ -130,16 +135,67 @@ public class ClubServiceImpl implements ClubService {
             user.setEmail(club.getContractEmail());
         }
         // 机构名称
-        if (StringUtils.isNotBlank(club.getName())){
+        if (StringUtils.isNotBlank(club.getName())) {
             user.setName(club.getName());
         }
         // 更新机构用户信息
         clubMapper.updateClubUserByUpdateInfo(user);
         // 更新机构信息
         clubMapper.updateClubByUpdateInfo(club);
+
+        UserVo userVo = baseMapper.getUserByUserId(club.getUserId());
+        if (userVo != null && userVo.getUserIdentity() == 4) {
+            Integer id = clubMapper.findBeansHistoryByType(club.getUserId(), 3);
+            boolean b = StringUtils.isNotBlank(club.getLinkMan()) && StringUtils.isNotBlank(club.getFax())
+                    && StringUtils.isNotBlank(club.getContractPhone()) && StringUtils.isNotBlank(club.getProfile());
+            if (b && id == null) {
+                saveUserBeans(userVo);
+            }
+        } else if (userVo != null && userVo.getUserIdentity() == 2) {
+            Integer id = clubMapper.findBeansHistoryByType(club.getUserId(), 4);
+            boolean b = StringUtils.isNotBlank(club.getLinkMan()) && StringUtils.isNotBlank(club.getFax()) && club.getTownId() != null
+                    && StringUtils.isNotBlank(club.getContractPhone()) && StringUtils.isNotBlank(club.getProfile()) && StringUtils.isNotBlank(club.getAddress())
+                    && StringUtils.isNotBlank(club.getName()) && StringUtils.isNotBlank(club.getShortName()) && StringUtils.isNotBlank(club.getContractEmail())
+                    && StringUtils.isNotBlank(club.getSocialCreditCode()) && StringUtils.isNotBlank(club.getBusinessLicense()) && StringUtils.isNotBlank(club.getShopPhoto())
+                    && club.getFirstClubType() != null && StringUtils.isNotBlank(club.getMainProduct());
+            if (b) {
+                if (club.getFirstClubType() == 1) {
+                    //医美
+                    b = club.getSecondClubType() != null && StringUtils.isNotBlank(club.getMedicalPracticeLicense());
+                    if (b && ("2".equals(club.getMedicalPracticeLicense()) || "3".equals(club.getMedicalPracticeLicense()))) {
+                        b = StringUtils.isNotBlank(club.getDepartment());
+                    }
+                }
+            }
+            if (b && id == null) {
+                saveUserBeans(userVo);
+            }
+        }
+
         return ResponseJson.success("修改机构资料成功", club);
     }
 
+    private void saveUserBeans(UserVo user) {
+        //机构完善资料,送20采美豆
+        UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
+        beansHistory.setUserId(user.getUserId());
+        if (user.getUserIdentity() == 4) {
+            //普通机构完善资料
+            beansHistory.setBeansType(3);
+        } else {
+            //会员机构完善资料
+            beansHistory.setBeansType(4);
+        }
+        beansHistory.setType(1);
+        beansHistory.setNum(20);
+        beansHistory.setPushStatus(0);
+        beansHistory.setAddTime(new Date());
+        registerMapper.insertBeansHistory(beansHistory);
+        Integer userBeans = user.getUserBeans();
+        userBeans = userBeans == null ? 20 : userBeans + 20;
+        clubMapper.updateUserBeans(user.getUserId(), userBeans);
+    }
+
     /**
      * 机构个人中心
      *
@@ -180,4 +236,46 @@ public class ClubServiceImpl implements ClubService {
 
         return ResponseJson.success(map);
     }
+
+    @Override
+    public ResponseJson<BeansHistoryVo> beansPopUps(Integer userId) {
+        BeansHistoryVo beansHistory = clubMapper.findBeansHistory(userId);
+        if (beansHistory == null) {
+            beansHistory = new BeansHistoryVo();
+            //线上支付送豆
+            Integer num = clubMapper.findByBeansType(userId, 6);
+            beansHistory.setBeansType(6);
+            if (num == null || num == 0) {
+                //下单送豆
+                num = clubMapper.findByBeansType(userId, 5);
+                beansHistory.setBeansType(5);
+            }
+            beansHistory.setNum(num);
+        }
+        if (beansHistory.getNum() == null || beansHistory.getNum() == 0) {
+            return ResponseJson.error("无推送", null);
+        }
+        clubMapper.updatePushStatus(userId);
+        return ResponseJson.success(beansHistory);
+    }
+
+    @Override
+    public ResponseJson<Map<String, Object>> beansHistory(Integer userId, Integer year, Integer month, Integer type, int pageNum, int pageSize) {
+        Map<String, Object> map = new HashMap<>(2);
+        UserVo user = baseMapper.getUserByUserId(userId);
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month - 1);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getMinimum(Calendar.DATE));
+        String startTime = format.format(calendar.getTime()) + " 00:00:00";
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DATE));
+        String endTime = format.format(calendar.getTime()) + " 23:59:59";
+        PageHelper.startPage(pageNum, pageSize);
+        List<BeansHistoryVo> historyList = clubMapper.findAllBeansHistory(userId, startTime, endTime, type);
+        PageInfo<BeansHistoryVo> pageInfo = new PageInfo<>(historyList);
+        map.put("pageInfo", pageInfo);
+        map.put("userBeans", user.getUserBeans());
+        return ResponseJson.success(map);
+    }
 }

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

@@ -9,10 +9,7 @@ import com.caimei365.user.mapper.RegisterMapper;
 import com.caimei365.user.mapper.SellerMapper;
 import com.caimei365.user.model.ResponseJson;
 import com.caimei365.user.model.dto.*;
-import com.caimei365.user.model.po.ClubPo;
-import com.caimei365.user.model.po.OperationPo;
-import com.caimei365.user.model.po.ShopPo;
-import com.caimei365.user.model.po.UserPo;
+import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.RegisterService;
 import com.caimei365.user.utils.AliyunSmsUtil;
@@ -166,6 +163,8 @@ public class RegisterServiceImpl implements RegisterService {
         user.setServiceProviderId(1342);
         // 协销状态,已上线
         user.setServiceProviderStatus(90);
+        //采美豆
+        user.setUserBeans(50);
         /*
             保存数据库 user
          */
@@ -260,6 +259,15 @@ public class RegisterServiceImpl implements RegisterService {
         if (!smsFlag) {
             log.info("短信发送失败,手机号:" + clubRegisterDto.getBindMobile());
         }
+        //新用户自主注册送50采美豆
+        UserBeansHistoryPo beansHistory = new UserBeansHistoryPo();
+        beansHistory.setUserId(user.getUserId());
+        beansHistory.setBeansType(1);
+        beansHistory.setType(1);
+        beansHistory.setNum(50);
+        beansHistory.setPushStatus(0);
+        beansHistory.setAddTime(date);
+        registerMapper.insertBeansHistory(beansHistory);
         return ResponseJson.success("机构注册成功", null);
     }
 

+ 2 - 1
src/main/resources/mapper/BaseMapper.xml

@@ -91,7 +91,8 @@
                registerTime,
                registerIP as registerIp,
                guideFlag,
-               validFlag
+               validFlag,
+               userBeans
         from user
         where userID = #{userId}
     </select>

+ 60 - 0
src/main/resources/mapper/ClubMapper.xml

@@ -81,4 +81,64 @@
         where  userID = #{userId} and delFlag = '0'
         limit 1
     </select>
+
+    <select id="findBeansHistoryByType" resultType="integer">
+        SELECT id FROM user_beans_history WHERE userId = #{userId} AND beansType = #{beansType} AND delFlag = 0
+    </select>
+
+    <update id="updateUserBeans">
+        UPDATE USER SET userBeans = #{userBeans} WHERE userID = #{userId}
+    </update>
+
+    <select id="findBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
+        SELECT
+          beansType,
+          num
+        FROM
+          user_beans_history
+        WHERE
+          pushStatus = 0
+          AND beansType IN (1, 2, 3, 4, 8)
+          AND delFlag = 0
+          AND userId = #{userId}
+        ORDER BY
+          ADDTIME DESC
+        LIMIT
+          1
+    </select>
+
+    <select id="findByBeansType" resultType="integer">
+        SELECT
+          SUM(num)
+        FROM
+          user_beans_history
+        WHERE
+          userId = #{userId}
+          AND beansType = #{beansType}
+          AND pushStatus = 0
+          AND delFlag = 0
+    </select>
+
+    <update id="updatePushStatus">
+        UPDATE user_beans_history SET pushStatus = 1 WHERE userId = #{userId}
+    </update>
+
+    <select id="findAllBeansHistory" resultType="com.caimei365.user.model.vo.BeansHistoryVo">
+        SELECT
+          type,
+          beansType,
+          num,
+          addTime
+        FROM
+          user_beans_history
+        WHERE
+          userId = #{userId}
+          AND addTime <![CDATA[ >= ]]> #{startTime}
+          AND addTime <![CDATA[ <= ]]> #{endTime}
+          AND delFlag = 0
+          <if test="type != null and type != 0">
+              AND type = #{type}
+          </if>
+        ORDER BY addTime DESC
+    </select>
 </mapper>

+ 15 - 2
src/main/resources/mapper/RegisterMapper.xml

@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.RegisterMapper">
     <insert id="insertClubUser" parameterType="com.caimei365.user.model.po.UserPo" keyProperty="userId" useGeneratedKeys="true">
-        insert into user(`userOrganizeID`,`registerTime`,`registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`,`guideFlag`,`clubStatus`, `password`, `agreeFlag`, `validFlag`, `serviceProviderID`, `serviceProviderStatus`)
-                  values(#{organizeId},#{registerTime},#{registerIp},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{guideFlag},#{clubStatus},#{password},#{agreeFlag},#{validFlag},#{serviceProviderId},#{serviceProviderStatus})
+        insert into user(`userOrganizeID`,`registerTime`,`registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`,`guideFlag`,`clubStatus`, `password`, `agreeFlag`, `validFlag`, `serviceProviderID`, `serviceProviderStatus`, userBeans)
+                  values(#{organizeId},#{registerTime},#{registerIp},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{guideFlag},#{clubStatus},#{password},#{agreeFlag},#{validFlag},#{serviceProviderId},#{serviceProviderStatus}, #{userBeans})
     </insert>
     <insert id="insertClub" parameterType="com.caimei365.user.model.po.ClubPo" keyProperty="clubId" useGeneratedKeys="true">
         insert into club(`name`, `sname`, `contractMobile`, `linkMan`, `userID`, `addTime`, `status`, `spID`, `scanFlag`)
@@ -110,6 +110,7 @@
             status = #{status}
         where shopID = #{shopId}
     </update>
+
     <update id="updateGuideFlagByUserId">
         update user set guideFlag=1 where userID=#{userId}
     </update>
@@ -163,4 +164,16 @@
           id = #{id}
     </select>
 
+    <insert id="insertBeansHistory">
+        INSERT INTO `user_beans_history` (
+          `userId`, `type`, `beansType`, `orderId`,
+          `num`, `pushStatus`, `addTime`, delFlag
+        )
+        VALUES
+          (
+            #{userId}, #{type}, #{beansType}, #{orderId},
+            #{num}, #{pushStatus}, #{addTime}, 0
+          )
+    </insert>
+
 </mapper>