Jelajahi Sumber

采美豆收支明细

plf 4 tahun lalu
induk
melakukan
dab1ab13a6

+ 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);
+    }
+
 
 }

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

@@ -2,11 +2,14 @@ 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
  *
@@ -61,4 +64,40 @@ public interface ClubMapper {
      * @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);
 }

+ 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;
+}

+ 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);
 }

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

@@ -9,11 +9,14 @@ 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;
 
 import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -154,8 +157,16 @@ public class ClubServiceImpl implements ClubService {
                     && 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 && club.getSecondClubType() != null && StringUtils.isNotBlank(club.getDepartment())
-                    && StringUtils.isNotBlank(club.getMedicalPracticeLicense()) && StringUtils.isNotBlank(club.getMainProduct());
+                    && 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);
             }
@@ -225,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);
+    }
 }

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

@@ -89,4 +89,51 @@
     <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)
+        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
+    </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}
+          <if test="type != null and type != 0">
+              AND type = #{type}
+          </if>
+    </select>
 </mapper>