소스 검색

Merge branch 'master' of http://s.dev01.dkiboss.com:9001/iBOSS-2.0-Mini/iboss-server-oauth

liuyao 1 년 전
부모
커밋
a8abdaaeca

+ 12 - 0
src/main/java/com/dk/oauth/controller/integral/CouponUseController.java

@@ -4,6 +4,7 @@ import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.model.VO.integral.CouponReceiveVO;
+import com.dk.oauth.model.VO.integral.CouponSendVO;
 import com.dk.oauth.model.VO.integral.CouponUseVO;
 import com.dk.oauth.model.pojo.integral.CouponUse;
 import com.dk.common.controller.BaseController;
@@ -19,6 +20,7 @@ import io.swagger.annotations.Api;
 import com.dk.oauth.service.integral.CouponUseService;
 
 import javax.validation.Valid;
+import java.util.Map;
 
 @Api(tags = "优惠券使用API接口")
 @RestController
@@ -82,4 +84,14 @@ public class CouponUseController{
         return ResponseResultUtil.success(couponUseService.countByCond(couponUseQuery));
     }
 
+    /**
+     * @desc   : 条件查询-优惠券使用 优惠券未使用的数据
+     * @date   : 2024/7/26 11:06
+     * @author : 姜永辉
+     */
+    @PostMapping({"list_by_use"})
+    public ResponseResultVO<Map<String, Object>> selectByCondUse(@RequestBody CouponUseQuery couponReceiveQuery) {
+        return couponUseService.selectByCondUse(couponReceiveQuery);
+    }
+
 }

+ 20 - 10
src/main/java/com/dk/oauth/mapper/integral/IntegralTacticMapper.xml

@@ -5,24 +5,31 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        tactic_id, share_day_num, reg_integral, sign_integral, fifteen_integral, share_integral, share_reg_integral, sign_day_num, share_valid_times
+        tactic_id
+        , share_day_num, reg_integral, sign_integral, fifteen_integral, share_integral, share_reg_integral,
+        sign_day_num, share_valid_times, exchange_rate
     </sql>
     <!-- 通用查询列Response -->
     <sql id="Base_Column_List_Response">
-        tmit.tactic_id, tmit.share_day_num, tmit.reg_integral, tmit.sign_integral, tmit.fifteen_integral, tmit.share_integral, tmit.share_reg_integral, tmit.sign_day_num, tmit.share_valid_times
+        tmit
+        .
+        tactic_id
+        , tmit.share_day_num, tmit.reg_integral, tmit.sign_integral, tmit.fifteen_integral,
+        tmit.share_integral, tmit.share_reg_integral, tmit.sign_day_num, tmit.share_valid_times, tmit.exchange_rate
     </sql>
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.oauth.model.pojo.integral.IntegralTactic">
         <id column="tactic_id" property="tacticId"/>
-                <result column="share_day_num" property="shareDayNum"/>
-                <result column="reg_integral" property="regIntegral"/>
-                <result column="sign_integral" property="signIntegral"/>
-                <result column="fifteen_integral" property="fifteenIntegral"/>
-                <result column="share_integral" property="shareIntegral"/>
-                <result column="share_reg_integral" property="shareRegIntegral"/>
-                <result column="sign_day_num" property="signDayNum"/>
-                <result column="share_valid_times" property="shareValidTimes"/>
+        <result column="share_day_num" property="shareDayNum"/>
+        <result column="reg_integral" property="regIntegral"/>
+        <result column="sign_integral" property="signIntegral"/>
+        <result column="fifteen_integral" property="fifteenIntegral"/>
+        <result column="share_integral" property="shareIntegral"/>
+        <result column="share_reg_integral" property="shareRegIntegral"/>
+        <result column="sign_day_num" property="signDayNum"/>
+        <result column="share_valid_times" property="shareValidTimes"/>
+        <result column="exchange_rate" property="exchangeRate"/>
     </resultMap>
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMapResponse" type="com.dk.oauth.model.response.integral.IntegralTacticResponse">
@@ -35,6 +42,7 @@
         <result column="share_reg_integral" property="shareRegIntegral"/>
         <result column="sign_day_num" property="signDayNum"/>
         <result column="share_valid_times" property="shareValidTimes"/>
+        <result column="exchange_rate" property="exchangeRate"/>
     </resultMap>
 
 
@@ -133,6 +141,7 @@
             sign_day_num,
             share_day_num,
             share_valid_times,
+            exchange_rate,
         </trim>
         )
         values
@@ -147,6 +156,7 @@
                 #{item.signDayNum},
                 #{item.shareDayNum},
                 #{item.shareValidTimes},
+                #{item.exchangeRate},
             </trim>
             )
         </foreach>

+ 7 - 0
src/main/java/com/dk/oauth/model/pojo/integral/IntegralTactic.java

@@ -108,6 +108,13 @@ public class IntegralTactic extends PageInfo<IntegralTactic> implements Serializ
     @ApiModelProperty(value = "邀请有效期")
     private Integer shareValidTimes;
 
+    /**
+     * 兑换率(1rmb=**云币)
+     */
+    @Excel(name = "兑换率(1rmb=**云币)")
+    @ApiModelProperty(value = "兑换率(1rmb=**云币)")
+    private Integer exchangeRate;
+
 
     /*
      * 相关属性

+ 7 - 0
src/main/java/com/dk/oauth/model/query/integral/IntegralTacticQuery.java

@@ -90,6 +90,13 @@ public class IntegralTacticQuery extends PageInfo<IntegralTacticQuery>  {
     @ApiModelProperty(value = "邀请有效期")
     private Integer shareValidTimes;
 
+    /**
+     * 兑换率(1rmb=**云币)
+     */
+    @Excel(name = "兑换率(1rmb=**云币)")
+    @ApiModelProperty(value = "兑换率(1rmb=**云币)")
+    private Integer exchangeRate;
+
 
 
     /*

+ 7 - 0
src/main/java/com/dk/oauth/model/response/integral/IntegralTacticResponse.java

@@ -100,6 +100,13 @@ public class IntegralTacticResponse {
     @ApiModelProperty(value = "邀请有效期")
     private Integer shareValidTimes;
 
+    /**
+     * 兑换率(1rmb=**云币)
+     */
+    @Excel(name = "兑换率(1rmb=**云币)")
+    @ApiModelProperty(value = "兑换率(1rmb=**云币)")
+    private Integer exchangeRate;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 65 - 2
src/main/java/com/dk/oauth/service/impl/CompanyServiceImpl.java

@@ -2,6 +2,7 @@ package com.dk.oauth.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.constant.Constant;
@@ -20,9 +21,11 @@ import com.dk.oauth.entity.*;
 import com.dk.oauth.feign.service.OrgFeign;
 import com.dk.oauth.feign.service.StaffFeign;
 import com.dk.oauth.mapper.*;
+import com.dk.oauth.mapper.integral.CouponUseMapper;
 import com.dk.oauth.mapper.integral.IntegralItemMapper;
 import com.dk.oauth.mapper.integral.IntegralMapper;
 import com.dk.oauth.mapper.integral.IntegralTacticMapper;
+import com.dk.oauth.model.pojo.integral.CouponUse;
 import com.dk.oauth.model.pojo.integral.Integral;
 import com.dk.oauth.model.pojo.integral.IntegralItem;
 import com.dk.oauth.model.pojo.integral.IntegralTactic;
@@ -43,6 +46,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
@@ -95,6 +99,8 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
     private IntegralMapper integralMapper;
     @Autowired
     private IntegralItemMapper integralItemMapper;
+    @Autowired
+    private CouponUseMapper couponUseMapper;
 
 
     /**
@@ -601,7 +607,35 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         trade.setBuyEndDate(companyVO.getBuyEndDate());
         trade.setExtendDays(companyVO.getExtendDays());
         trade.setBuyGradeCode(companyVO.getGradeCode());
-        trade.setTradeStatus(Constant.TradeStatus.INEFFECTIVE.getName());
+        // 金额0时候不需要 付款
+        if (BigDecimal.ZERO.compareTo(companyVO.getTradeAmount()) == 0){
+            trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
+//            更新license
+            Company comp = new Company();
+            comp.setCpId(companyVO.getCpId());
+            companyMapper.updateCompanyLicense(comp);
+            // 交易的 优惠券id 使用 金额为0的时候 用不了优惠券
+
+            // 使用员工   // 积分的使用
+            if (companyVO.getIntegral() != null && companyVO.getIntegral() > 0) {
+                // 积分明细
+                IntegralItem integralItem = new IntegralItem();
+                integralItem.setIntegralType(Constant.IntegralType.INTEGRAL_TYPE_USE.getName());
+                integralItem.setIntegral(-1 * companyVO.getIntegral());
+                integralItem.setCpId(companyVO.getCpId());
+                integralItem.setAccDate(LocalDateTime.now());
+                integralItem.setUserId(companyVO.getWxUserId());
+                integralItem.setStaffName(companyVO.getStaffNameFrom());
+                integralItemMapper.insert(integralItem);
+                // 积分 总积分
+                Integral integral = new Integral();
+                integral.setCpId(companyVO.getCpId());
+                integral.setIntegral(-1 * companyVO.getIntegral());
+                integralMapper.updateById(integral);
+            }
+        }else{
+            trade.setTradeStatus(Constant.TradeStatus.INEFFECTIVE.getName());
+        }
         trade.setTradeDesc(companyVO.getRemarks());
         trade.setActivityId(companyVO.getActivityId());
         trade.setActivityItemId(companyVO.getActivityItemId());
@@ -643,13 +677,42 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
         trade.setCpId(companyVO.getCpId());
         trade.setWxUserId(companyVO.getWxUserId());
         trade.setTradeAmount(companyVO.getTradeAmount());
+
         trade.setTradeType(Constant.TradeType.FUNTION.getName());
         trade.setBuyLong(companyVO.getBuyLong());
         trade.setBuyBeginDate(companyVO.getBuyBeginDate());
         trade.setBuyEndDate(companyVO.getBuyEndDate());
         trade.setExtendDays(companyVO.getExtendDays());
         trade.setBuyGradeCode(companyVO.getGradeCode());
-        trade.setTradeStatus(Constant.TradeStatus.INEFFECTIVE.getName());
+        // 金额0时候不需要 付款
+        if (BigDecimal.ZERO.compareTo(companyVO.getTradeAmount()) == 0){
+            trade.setTradeStatus(Constant.TradeStatus.EFFECTIVE.getName());
+//            更新license
+            Company comp = new Company();
+            comp.setCpId(companyVO.getCpId());
+            companyMapper.updateCompanyLicense(comp);
+            // 交易的 优惠券id 使用 金额为0的时候 用不了优惠券
+
+            // 使用员工   // 积分的使用
+            if (companyVO.getIntegral() != null && companyVO.getIntegral() > 0) {
+                // 积分明细
+                IntegralItem integralItem = new IntegralItem();
+                integralItem.setIntegralType(Constant.IntegralType.INTEGRAL_TYPE_USE.getName());
+                integralItem.setIntegral(-1 * companyVO.getIntegral());
+                integralItem.setCpId(companyVO.getCpId());
+                integralItem.setAccDate(LocalDateTime.now());
+                integralItem.setUserId(companyVO.getWxUserId());
+                integralItem.setStaffName(companyVO.getStaffNameFrom());
+                integralItemMapper.insert(integralItem);
+                // 积分 总积分
+                Integral integral = new Integral();
+                integral.setCpId(companyVO.getCpId());
+                integral.setIntegral(-1 * companyVO.getIntegral());
+                integralMapper.updateById(integral);
+            }
+        }else{
+            trade.setTradeStatus(Constant.TradeStatus.INEFFECTIVE.getName());
+        }
         trade.setActivityId(companyVO.getActivityId());
         trade.setActivityItemId(companyVO.getActivityItemId());
         trade.setActivityIds(companyVO.getActivityIds());

+ 40 - 5
src/main/java/com/dk/oauth/service/integral/CouponUseService.java

@@ -9,6 +9,8 @@ import com.dk.common.model.pojo.PageList;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.oauth.infrastructure.convert.integral.CouponUseConvert;
+import com.dk.oauth.mapper.integral.IntegralMapper;
+import com.dk.oauth.mapper.integral.IntegralTacticMapper;
 import com.dk.oauth.model.VO.integral.CouponReceiveVO;
 import com.dk.oauth.model.VO.integral.CouponUseVO;
 import com.dk.oauth.model.pojo.integral.CouponReceive;
@@ -18,8 +20,11 @@ import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.oauth.model.query.integral.CouponReceiveQuery;
 import com.dk.oauth.model.query.integral.CouponUseQuery;
+import com.dk.oauth.model.query.integral.IntegralTacticQuery;
 import com.dk.oauth.model.response.integral.CouponReceiveResponse;
 import com.dk.oauth.model.response.integral.CouponUseResponse;
+import com.dk.oauth.model.response.integral.IntegralResponse;
+import com.dk.oauth.model.response.integral.IntegralTacticResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +33,9 @@ import org.springframework.transaction.annotation.Transactional;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 
 @Slf4j
@@ -48,6 +55,13 @@ public class CouponUseService extends BaseService<CouponUse> {
     //优惠券使用实体类型转换
     private CouponUseConvert couponUseConvert;
 
+    @Autowired
+    private IntegralMapper integralMapper;
+
+    @Autowired
+    //积分策略
+    private IntegralTacticMapper integralTacticMapper;
+
 
     /**
      * @desc : 条件查询
@@ -59,6 +73,7 @@ public class CouponUseService extends BaseService<CouponUse> {
         return super.mergeListWithCount(couponReceiveQuery, couponUseMapper.selectByCond(couponReceiveQuery),
                 couponUseMapper.countByCond(couponReceiveQuery));
     }
+
     /**
      * @desc : 条件查询
      * @date : 2024/7/26 11:07
@@ -68,6 +83,7 @@ public class CouponUseService extends BaseService<CouponUse> {
     public Long countByCond(CouponUseQuery couponReceiveQuery) {
         return couponUseMapper.countByCond(couponReceiveQuery);
     }
+
     /**
      * @desc : 更新
      * @date : 2024/7/26 16:50
@@ -121,17 +137,16 @@ public class CouponUseService extends BaseService<CouponUse> {
         //查询全部优惠券使用
         List<CouponUseResponse> couponUseResponseList = couponUseMapper.selectByCond(new CouponUseQuery()
                 .setCouponStatus(Constant.couponStatus.WEI_SHI_YONG.getName()));
-        log.info("retrievalCouponStatus查询全部优惠券使用:{}",couponUseResponseList);
+        log.info("retrievalCouponStatus查询全部优惠券使用:{}", couponUseResponseList);
         //数据存在
         if (couponUseResponseList != null && couponUseResponseList.size() > 0) {
             for (CouponUseResponse couponUseResponse : couponUseResponseList) {
                 //过期时间
-                LocalDate beOverdueTime = couponUseResponse.getReceiveDate().plusDays(couponUseResponse.getUseValidDays())
-                         ;
+                LocalDate beOverdueTime = couponUseResponse.getReceiveDate().plusDays(couponUseResponse.getUseValidDays());
                 //当前时间
 //                long nowTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
                 LocalDate nowTime = LocalDate.now();
-                log.info("过期时间:{},当前时间:{}",beOverdueTime,nowTime);
+                log.info("过期时间:{},当前时间:{}", beOverdueTime, nowTime);
                 //当前时间大于过期时间   优惠券已过期
                 if (nowTime.compareTo(beOverdueTime) >= 0) {
                     //类型转换
@@ -147,11 +162,31 @@ public class CouponUseService extends BaseService<CouponUse> {
                             new UpdateWrapper<CouponUse>().lambda()
                                     .eq(CouponUse::getUseId, UUID.fromString(couponUse.getUseId()))
                     );
-                    log.info("couponUse数据:{}",couponUse);
+                    log.info("couponUse数据:{}", couponUse);
                 }
             }
         }
         return ResponseResultUtil.success();
     }
 
+    /**
+     * @desc : 条件查询-优惠券使用 和优惠券未使用的数据
+     * @date : 2024/7/26 17:06
+     * @author : 寇珊珊
+     */
+    public ResponseResultVO<Map<String, Object>> selectByCondUse(CouponUseQuery couponUseQuery) {
+        Map<String, Object> map = new HashMap<>();
+        //查询全部优惠未使用
+        List<CouponUseResponse> couponUseResponseList = couponUseMapper.selectByCond(couponUseQuery);
+        map.put("list", couponUseResponseList);
+        // 公司积分
+        IntegralResponse integralResponse = integralMapper.selectById(couponUseQuery.getCpId());
+        map.put("integral", integralResponse != null ? integralResponse.getIntegral() : 0);
+        // 积分策略
+        List<IntegralTacticResponse> integralTacticResponses = integralTacticMapper.selectByCond(new IntegralTacticQuery());
+        map.put("listIntegralTactic", integralTacticResponses);
+
+        return ResponseResultUtil.success(map);
+    }
+
 }

+ 9 - 7
src/main/java/com/dk/oauth/service/wxapi/basic/WechatPayService.java

@@ -167,6 +167,7 @@ public class WechatPayService {
         log.info("微信用户----------" + byWxid);
         // 获取交易记录
         TradeResponse tradeResponse = tradeMapper.selectTradeByNo(new Trade().setTradeNo(info.getOutTradeNo()));
+        log.info("获取交易记录----------{}," + tradeResponse);
         if (tradeResponse == null) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(),
                     ErrorCodeEnum.NO_FIND_TRADE.getMessage());
@@ -190,12 +191,12 @@ public class WechatPayService {
             //核销日期
             couponUse.setUseDate(LocalDate.now());
             // 使用员工
-            couponUse.setUseStaff(trade.getStaffName());
+            couponUse.setUseStaff(tradeResponse.getStaffName());
             //更新
             couponUseMapper.update(couponUse,
                     new UpdateWrapper<CouponUse>().lambda()
                             .eq(CouponUse::getUseId, java.util.UUID.fromString(couponUse.getUseId())));
-
+            log.info("更新优惠券的状态----------{}," + couponUse);
         }
 
         // 使用员工   // 积分的使用
@@ -206,19 +207,20 @@ public class WechatPayService {
             integralItem.setIntegral(-1 * tradeResponse.getIntegral());
             integralItem.setCpId(tradeResponse.getCpId());
             integralItem.setAccDate(LocalDateTime.now());
-            integralItem.setUserId(trade.getWxUserId());
-            integralItem.setStaffName(trade.getStaffName());
+            integralItem.setUserId(tradeResponse.getWxUserId());
+            integralItem.setStaffName(tradeResponse.getStaffName());
             integralItemMapper.insert(integralItem);
             // 积分 总积分
             Integral integral = new Integral();
             integral.setCpId(tradeResponse.getCpId());
             integral.setIntegral(-1 * tradeResponse.getIntegral());
             integralMapper.updateById(integral);
+            log.info("更新优惠券的状态----------{}," + integralItem);
         }
 
         // 交易类型-续费- 将该公司的 生成一个job的任务
-        if (Constant.TradeType.RENEW.getName().equals(trade.getTradeType())) {
-            log.error("交易类型-续费插入任务数据-getTradeType:" + trade.getTradeType());
+        if (Constant.TradeType.RENEW.getName().equals(tradeResponse.getTradeType())) {
+            log.error("交易类型-续费插入任务数据-getTradeType:" + tradeResponse.getTradeType());
             try {
                 Company company = companyMapper.selectById(tradeResponse.getCpId());
                 // 解析license信息
@@ -242,7 +244,7 @@ public class WechatPayService {
         }
 
         // 更新企业,把临时license更新到license中
-        log.info("交易记录----------" + trade);
+        log.info("交易记录----------" + tradeResponse);
 //        企业
         Company comp = new Company();
         comp.setCpId(tradeResponse.getCpId());

+ 5 - 0
src/main/resources/mapper/TradeMapper.xml

@@ -27,6 +27,10 @@
         ,t.trade_desc
         ,t.activity_ids
         ,t.activity_item_ids
+        ,t.receipt_date
+        ,t.coupon_use_id
+        ,t.integral
+        ,t.staff_name
     </sql>
 
     <resultMap type="com.dk.oauth.entity.Trade" id="ResultMap">
@@ -81,6 +85,7 @@
         <result column="tradeTypeName" property="tradeTypeName"/>
         <result column="tradeStatusName" property="tradeStatusName"/>
         <result column="receiptStatusName" property="receiptStatusName"/>
+        <result column="coupon_use_id" property="couponUseId" typeHandler="UuidTypeHandler"/>
         <result column="integral" property="integral"/>
         <result column="staff_name" property="staffName"/>
     </resultMap>