|
|
@@ -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;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -315,6 +321,7 @@ public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> impl
|
|
|
integralItem.setCpId(companyVO.getCpIdFrom());
|
|
|
integralItem.setAccDate(LocalDateTime.now());
|
|
|
integralItem.setUserId(companyVO.getUserIdFrom());
|
|
|
+ integralItem.setShareId(companyVO.getShareId());
|
|
|
// 来源公司公司的人员
|
|
|
integralItem.setStaffName(companyVO.getStaffNameFrom());
|
|
|
integralItemMapper.insert(integralItem);
|
|
|
@@ -601,7 +608,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 +678,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());
|