Bladeren bron

add:商城添加销售发送优惠券

ct 1 dag geleden
bovenliggende
commit
72552b4c0a

+ 1 - 1
fs-admin/src/main/java/com/fs/hisStore/controller/FsStoreHealthOrderScrmController.java

@@ -112,7 +112,7 @@ public class FsStoreHealthOrderScrmController extends BaseController {
                     }
                 }
                 //
-                if (loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*")) {
+                if ((loginUser.getPermissions().contains("his:storeAfterSales:finance") || loginUser.getPermissions().contains("*:*:*") && (vo.getCost() !=null && vo.getTotalNum() != null))) {
                     vo.setFPrice(vo.getCost().multiply(BigDecimal.valueOf(vo.getTotalNum())));
                 } else {
                     vo.setPayPostage(BigDecimal.ZERO);

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsUserScrm.java

@@ -171,6 +171,10 @@ public class FsUserScrm extends BaseEntity
 
     private String courseMaOpenId; //看课小程序openid
 
+
+
+    private String historyApp; //app登录后不为null(表示是否下载app)
+
     private Long qwExtId;
 
     /**
@@ -839,4 +843,13 @@ public class FsUserScrm extends BaseEntity
     public void setOrderCount(Integer orderCount) {
         this.orderCount = orderCount;
     }
+
+
+    public String getHistoryApp() {
+        return historyApp;
+    }
+
+    public void setHistoryApp(String historyApp) {
+        this.historyApp = historyApp;
+    }
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/mapper/FsUserScrmMapper.java

@@ -3,6 +3,7 @@ package com.fs.hisStore.mapper;
 import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
 import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.vo.UserScrmVo;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
 import com.fs.hisStore.domain.FsUserScrm;
@@ -343,4 +344,6 @@ public interface FsUserScrmMapper
      */
     @Update("update fs_user set total_amount = IFNULL(total_amount, 0) + #{payMoney} where user_id = #{userId}")
     void incPayMoney(@Param("payMoney") BigDecimal payMoney, @Param("userId") Long userId);
+
+    List<UserScrmVo> selectUserVOList(@Param("phone") String phone);
 }

+ 24 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsUserCouponScrmSendParam.java

@@ -0,0 +1,24 @@
+package com.fs.hisStore.param;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class FsUserCouponScrmSendParam {
+
+    /** 优惠劵id */
+    @Excel(name = "优惠劵id")
+    private Long id;
+
+    @Excel(name = "会员ID")
+    private Long userId;
+
+    // 发送人id
+    private Long setSendUserId;
+
+    //发送销售id
+    private Long companyUserId;
+
+    //发送销售公司id
+    private Long companyId;
+}

+ 11 - 8
fs-service/src/main/java/com/fs/hisStore/service/IFsStoreCouponIssueScrmService.java

@@ -6,19 +6,20 @@ import com.fs.common.core.domain.R;
 import com.fs.hisStore.domain.FsStoreCouponIssueScrm;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
+import com.fs.hisStore.param.FsUserCouponScrmSendParam;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 
 /**
  * 优惠券领取Service接口
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
-public interface IFsStoreCouponIssueScrmService 
+public interface IFsStoreCouponIssueScrmService
 {
     /**
      * 查询优惠券领取
-     * 
+     *
      * @param id 优惠券领取ID
      * @return 优惠券领取
      */
@@ -26,7 +27,7 @@ public interface IFsStoreCouponIssueScrmService
 
     /**
      * 查询优惠券领取列表
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 优惠券领取集合
      */
@@ -34,7 +35,7 @@ public interface IFsStoreCouponIssueScrmService
 
     /**
      * 新增优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      */
@@ -42,7 +43,7 @@ public interface IFsStoreCouponIssueScrmService
 
     /**
      * 修改优惠券领取
-     * 
+     *
      * @param fsStoreCouponIssue 优惠券领取
      * @return 结果
      */
@@ -50,7 +51,7 @@ public interface IFsStoreCouponIssueScrmService
 
     /**
      * 批量删除优惠券领取
-     * 
+     *
      * @param ids 需要删除的优惠券领取ID
      * @return 结果
      */
@@ -58,7 +59,7 @@ public interface IFsStoreCouponIssueScrmService
 
     /**
      * 删除优惠券领取信息
-     * 
+     *
      * @param id 优惠券领取ID
      * @return 结果
      */
@@ -73,4 +74,6 @@ public interface IFsStoreCouponIssueScrmService
     FsStoreCouponIssueVO selectFsStoreCouponIssueVOById(Long id);
 
     List<FsStoreCouponIssueVO> selectFsStoreCouponIssueListVO(FsStoreCouponIssueScrm fsStoreCouponIssue);
+
+    R sendFsUserCoupon(FsUserCouponScrmSendParam param);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsUserScrmService.java

@@ -11,6 +11,7 @@ import com.fs.his.domain.FsStoreProductAttrValue;
 import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
 import com.fs.hisStore.domain.FsStoreProductAttrValueScrm;
+import com.fs.hisStore.vo.UserScrmVo;
 import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
@@ -294,4 +295,6 @@ public interface IFsUserScrmService
     void handleFsUserWx(FsUserScrm user, LoginMaWxParam param, WxMaJscode2SessionResult session);
 
     void incPayMoney(BigDecimal payMoney, Long userId);
+
+    List<UserScrmVo> selectUserVOList(String phone);
 }

+ 53 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCouponIssueScrmServiceImpl.java

@@ -6,11 +6,13 @@ import java.util.List;
 
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.CustomException;
 import com.fs.common.utils.DateUtils;
 import com.fs.hisStore.domain.*;
 import com.fs.hisStore.mapper.*;
 import com.fs.hisStore.param.FsCouponIssueParam;
 import com.fs.hisStore.param.FsStoreCouponReceiveParam;
+import com.fs.hisStore.param.FsUserCouponScrmSendParam;
 import com.fs.hisStore.vo.FsStoreCouponIssueVO;
 import lombok.Synchronized;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -181,5 +183,56 @@ public class FsStoreCouponIssueScrmServiceImpl implements IFsStoreCouponIssueScr
         return fsStoreCouponIssueMapper.selectFsStoreCouponIssueListVO(fsStoreCouponIssue);
     }
 
+    @Override
+    @Transactional
+    public R sendFsUserCoupon(FsUserCouponScrmSendParam param) {
+        Long userId = param.getUserId();
+        if (userId ==null){
+            throw new CustomException("用户不能为空");
+        }
+        FsStoreCouponIssueScrm couponIssue=fsStoreCouponIssueMapper.selectFsStoreCouponIssueById(param.getId());
+        if(couponIssue.getStatus().equals(0)){
+            return R.error("此优惠券已停止领取");
+        }
+        if(couponIssue.getLimitTime().getTime()<new Date().getTime()){
+            return R.error("此优惠券已过期");
+        }
+        //判断用户是否领取过
+        FsUserScrm user= userMapper.selectFsUserById(userId);
+        if(user.getLevel().equals(0)){
+            if(fsStoreCouponIssueUserMapper.checkReceive(userId.toString(),param.getId())>0){
+                return R.error("已领取");
+            }
+        }
+        if(couponIssue.getTotalCount()<=couponIssue.getRemainCount()){
+            return R.error("此优惠券已领完");
+        }
+        FsStoreCouponScrm coupon=couponMapper.selectFsStoreCouponById(couponIssue.getCouponId());
+        //写入领取表
+        FsStoreCouponIssueUserScrm couponIssueUser=new FsStoreCouponIssueUserScrm();
+        couponIssueUser.setUserId(userId);
+        couponIssueUser.setIssueId(param.getId());
+        couponIssueUser.setIsDel(0);
+        couponIssueUser.setCreateTime(new Date());
+        fsStoreCouponIssueUserMapper.insertFsStoreCouponIssueUser(couponIssueUser);
+        FsStoreCouponUserScrm couponUser=new FsStoreCouponUserScrm();
+        couponUser.setCouponId(couponIssue.getCouponId());
+        couponUser.setUserId(userId);
+        couponUser.setCouponTitle(couponIssue.getCouponName());
+        couponUser.setCouponPrice(coupon.getCouponPrice());
+        couponUser.setUseMinPrice(coupon.getUseMinPrice());
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DATE,coupon.getCouponTime().intValue());
+        couponUser.setLimitTime(calendar.getTime());
+        couponUser.setCreateTime(new Date());
+        couponUser.setType("send");
+        couponUser.setStatus(0);
+        fsStoreCouponUserMapper.insertFsStoreCouponUser(couponUser);
+        //更新领取数量
+        fsStoreCouponIssueMapper.updateFsStoreCouponIssueCount(param.getId());
+        return R.ok("领取成功");
+    }
+
 
 }

+ 6 - 4
fs-service/src/main/java/com/fs/hisStore/service/impl/FsUserScrmServiceImpl.java

@@ -37,6 +37,7 @@ import com.fs.his.domain.FsUserBill;
 import com.fs.his.domain.FsUserWx;
 import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.OptionsVO;
+import com.fs.hisStore.vo.*;
 import com.fs.live.domain.LiveOrder;
 import com.fs.qw.param.QwFsUserParam;
 import com.fs.qw.vo.QwFsUserVO;
@@ -57,10 +58,6 @@ import com.fs.hisStore.service.IFsUserCompanyUserScrmService;
 import com.fs.hisStore.service.IFsUserProjectTagScrmService;
 import com.fs.hisStore.service.IFsUserScrmService;
 import com.fs.hisStore.service.cache.IFsUserCourseCountCacheService;
-import com.fs.hisStore.vo.FSUserVO;
-import com.fs.hisStore.vo.FsCompanyUserListQueryVO;
-import com.fs.hisStore.vo.FsUserLastCount;
-import com.fs.hisStore.vo.FsUserTuiVO;
 import com.fs.hisStore.vo.h5.*;
 import com.fs.system.mapper.SysDictDataMapper;
 import com.github.pagehelper.PageHelper;
@@ -1162,4 +1159,9 @@ public class FsUserScrmServiceImpl implements IFsUserScrmService
     public void incPayMoney(BigDecimal payMoney, Long userId) {
         fsUserMapper.incPayMoney(payMoney, userId);
     }
+
+    @Override
+    public List<UserScrmVo> selectUserVOList(String phone) {
+        return fsUserMapper.selectUserVOList(phone);
+    }
 }

+ 11 - 0
fs-service/src/main/java/com/fs/hisStore/vo/UserScrmVo.java

@@ -0,0 +1,11 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+@Data
+public class UserScrmVo {
+    Long id;
+    String name;
+    String position;
+    String certificateCode;
+}

+ 3 - 0
fs-service/src/main/resources/mapper/hisStore/FsUserScrmMapper.xml

@@ -2034,5 +2034,8 @@
         <include refid="selectFsUserVo"/>
         where phone = #{phone}
     </select>
+    <select id="selectUserVOList" resultType="com.fs.hisStore.vo.UserScrmVo">
+        select user_id id,CONCAT_WS('-',nick_name) `name` from fs_user  where  phone =#{phone}
+    </select>
 
 </mapper>

+ 18 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/CouponScrmController.java

@@ -4,16 +4,14 @@ package com.fs.app.controller.store;
 import cn.hutool.core.util.IdUtil;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
+import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
 import com.fs.common.param.BaseQueryParam;
 import com.fs.common.utils.StringUtils;
 import com.fs.hisStore.domain.FsStoreCouponIssueScrm;
 import com.fs.hisStore.domain.FsStoreCouponUserScrm;
-import com.fs.hisStore.param.FsCouponIssueParam;
-import com.fs.hisStore.param.FsCouponUserEnableParam;
-import com.fs.hisStore.param.FsCouponUserParam;
-import com.fs.hisStore.param.FsStoreCouponReceiveParam;
+import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.IFsStoreCouponIssueScrmService;
 import com.fs.hisStore.service.IFsStoreCouponScrmService;
 import com.fs.hisStore.service.IFsStoreCouponUserScrmService;
@@ -137,5 +135,21 @@ public class CouponScrmController extends AppBaseController {
         }
     }
 
+    /**
+     * 发送会员优惠券
+     */
+    @RepeatSubmit
+    @Login
+    @PostMapping("/sendCoupon")
+    public R sendCoupon(@RequestBody FsUserCouponScrmSendParam param)
+    {
+        Long companyUserId = getCompanyUserId();
+        if(companyUserId==null){
+            return R.error("销售未登录!");
+        }
+        param.setSetSendUserId(companyUserId);
+        return fsStoreCouponIssueService.sendFsUserCoupon(param);
+    }
+
 
 }

+ 18 - 4
fs-user-app/src/main/java/com/fs/app/controller/store/UserScrmController.java

@@ -13,6 +13,7 @@ import com.fs.common.OrderUtils;
 import com.fs.common.config.FSConfig;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
+import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.exception.CustomException;
 import com.fs.common.param.BaseQueryParam;
 import com.fs.core.config.WxMaConfiguration;
@@ -24,10 +25,7 @@ import com.fs.hisStore.domain.FsUserPromoterApplyScrm;
 import com.fs.hisStore.domain.FsUserScrm;
 import com.fs.hisStore.param.*;
 import com.fs.hisStore.service.*;
-import com.fs.hisStore.vo.FsStoreOrderTuiVO;
-import com.fs.hisStore.vo.FsStoreProductRelationQueryVO;
-import com.fs.hisStore.vo.FsUserExtractVO;
-import com.fs.hisStore.vo.FsUserTuiVO;
+import com.fs.hisStore.vo.*;
 import com.fs.live.domain.LiveOrder;
 import com.fs.live.service.ILiveOrderService;
 import com.fs.utils.FileCacheService;
@@ -62,6 +60,8 @@ import java.util.List;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 
+import static com.fs.his.utils.PhoneUtil.encryptPhone;
+
 
 @Api("个人中心")
 @RestController
@@ -643,4 +643,18 @@ public class UserScrmController extends AppBaseController {
         log.debug("会员关联绑定销售 param:{}", JSON.toJSONString(param));
         return fsUserService.becomeMember(param);
     }
+
+    /**
+     * 查询用户
+     */
+    @GetMapping("/{phone}")
+    public TableDataInfo userList(@PathVariable("phone")String phone)
+    {
+        List<UserScrmVo> list = fsUserService.selectUserVOList(phone);
+        if (list==null|| list.isEmpty()){
+            String s = encryptPhone(phone);
+            list = fsUserService.selectUserVOList(s);
+        }
+        return getDataTable(list);
+    }
 }