|
@@ -6,21 +6,22 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
|
|
import com.example.xiaoshiweixinback.business.exception.ExceptionEnum;
|
|
import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
|
|
import com.example.xiaoshiweixinback.business.utils.BatchNoUtil;
|
|
|
|
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
|
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
import com.example.xiaoshiweixinback.domain.*;
|
|
import com.example.xiaoshiweixinback.domain.*;
|
|
|
|
|
|
import com.example.xiaoshiweixinback.entity.dto.ticket.TicketProcessUpDTO;
|
|
import com.example.xiaoshiweixinback.entity.dto.ticket.TicketProcessUpDTO;
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
import com.example.xiaoshiweixinback.entity.vo.person.PersonVO;
|
|
import com.example.xiaoshiweixinback.entity.vo.person.PersonVO;
|
|
-import com.example.xiaoshiweixinback.entity.weixinPay.GetPayTicketVO;
|
|
|
|
-import com.example.xiaoshiweixinback.entity.weixinPay.GoodVO;
|
|
|
|
-import com.example.xiaoshiweixinback.entity.weixinPay.JsApiDTO;
|
|
|
|
-import com.example.xiaoshiweixinback.entity.weixinPay.WeiXinPayDTO;
|
|
|
|
|
|
+import com.example.xiaoshiweixinback.entity.weixinPay.*;
|
|
import com.example.xiaoshiweixinback.factorys.goodFactory.GoodFactory;
|
|
import com.example.xiaoshiweixinback.factorys.goodFactory.GoodFactory;
|
|
import com.example.xiaoshiweixinback.factorys.goodFactory.GoodImp;
|
|
import com.example.xiaoshiweixinback.factorys.goodFactory.GoodImp;
|
|
import com.example.xiaoshiweixinback.mapper.AssoPersonProductMapper;
|
|
import com.example.xiaoshiweixinback.mapper.AssoPersonProductMapper;
|
|
import com.example.xiaoshiweixinback.mapper.OrderMapper;
|
|
import com.example.xiaoshiweixinback.mapper.OrderMapper;
|
|
import com.example.xiaoshiweixinback.service.weixinpay.AssoPayOrderGoodService;
|
|
import com.example.xiaoshiweixinback.service.weixinpay.AssoPayOrderGoodService;
|
|
import com.example.xiaoshiweixinback.service.weixinpay.AssoPayOrderVoucherService;
|
|
import com.example.xiaoshiweixinback.service.weixinpay.AssoPayOrderVoucherService;
|
|
|
|
+import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -41,7 +42,7 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
|
|
private VipService vipService;
|
|
private VipService vipService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
- private TicketService ticketService;
|
|
|
|
|
|
+ private InviteMessageService inviteMessageService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private AssoPayOrderGoodService assoPayOrderGoodService;
|
|
private AssoPayOrderGoodService assoPayOrderGoodService;
|
|
@@ -51,10 +52,14 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
|
|
private GoodFactory goodFactory;
|
|
private GoodFactory goodFactory;
|
|
@Autowired
|
|
@Autowired
|
|
private AssoPersonVoucherService assoPersonVoucherService;
|
|
private AssoPersonVoucherService assoPersonVoucherService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ActivityService activityService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private CacheUtil cacheUtil;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Order addOrder(WeiXinPayDTO weiXinPayDTO, String tradeNo, PersonnelVO personVO) {
|
|
public Order addOrder(WeiXinPayDTO weiXinPayDTO, String tradeNo, PersonnelVO personVO) {
|
|
- this.verifyPrice(weiXinPayDTO,personVO);
|
|
|
|
|
|
+ this.verifyPrice(weiXinPayDTO, personVO);
|
|
Integer type = weiXinPayDTO.getGoodType();
|
|
Integer type = weiXinPayDTO.getGoodType();
|
|
Double price = weiXinPayDTO.getPrice();
|
|
Double price = weiXinPayDTO.getPrice();
|
|
Double finalPrice = weiXinPayDTO.getFinalPrice();
|
|
Double finalPrice = weiXinPayDTO.getFinalPrice();
|
|
@@ -92,12 +97,21 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
|
|
}
|
|
}
|
|
order.setOrderState(1);
|
|
order.setOrderState(1);
|
|
order.updateById();
|
|
order.updateById();
|
|
|
|
+
|
|
List<AssoPayOrderGood> assoPayOrderGoods = assoPayOrderGoodService.getPayOrderGoodByOrderId(order.getId());
|
|
List<AssoPayOrderGood> assoPayOrderGoods = assoPayOrderGoodService.getPayOrderGoodByOrderId(order.getId());
|
|
- Integer orderType =assoPayOrderGoods.get(0).getGoodType();
|
|
|
|
|
|
+ Integer orderType = assoPayOrderGoods.get(0).getGoodType();
|
|
|
|
+
|
|
|
|
+ //执行活动逻辑
|
|
|
|
+ activityService.executeActivity(order, orderType, 1, null);
|
|
GoodImp goodImp = goodFactory.getClass(orderType);
|
|
GoodImp goodImp = goodFactory.getClass(orderType);
|
|
goodImp.activeGood(order, assoPayOrderGoods);
|
|
goodImp.activeGood(order, assoPayOrderGoods);
|
|
List<Integer> assoPersonVoucherIds = assoPayOrderVoucherService.getAssoVoucherIdsByOrder(order.getId());
|
|
List<Integer> assoPersonVoucherIds = assoPayOrderVoucherService.getAssoVoucherIdsByOrder(order.getId());
|
|
assoPersonVoucherService.useVoucher(assoPersonVoucherIds, 1);
|
|
assoPersonVoucherService.useVoucher(assoPersonVoucherIds, 1);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (orderType.equals(-1)) {
|
|
|
|
+ inviteMessageService.updateInvite(order.getPersonUuid());
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -111,35 +125,92 @@ public class OrderService extends ServiceImpl<OrderMapper, Order> {
|
|
List<Integer> assoVoucherIds = weiXinPayDTO.getPersonVoucherIds();
|
|
List<Integer> assoVoucherIds = weiXinPayDTO.getPersonVoucherIds();
|
|
Double price = weiXinPayDTO.getFinalPrice();
|
|
Double price = weiXinPayDTO.getFinalPrice();
|
|
Double discount = weiXinPayDTO.getDiscount();
|
|
Double discount = weiXinPayDTO.getDiscount();
|
|
- if(discount==null){
|
|
|
|
- discount=1d;
|
|
|
|
|
|
+
|
|
|
|
+ if (discount == null) {
|
|
|
|
+ discount = 1d;
|
|
}
|
|
}
|
|
//校验优惠卷是否能使用
|
|
//校验优惠卷是否能使用
|
|
Double voucherMon = assoPersonVoucherService.verifyVouchers(assoVoucherIds, personVO);
|
|
Double voucherMon = assoPersonVoucherService.verifyVouchers(assoVoucherIds, personVO);
|
|
|
|
|
|
//计算商品价格
|
|
//计算商品价格
|
|
GoodImp goodImp = goodFactory.getClass(type);
|
|
GoodImp goodImp = goodFactory.getClass(type);
|
|
- Double allPrice = goodImp.computePrice(goodVOS);
|
|
|
|
- System.out.println("总价"+allPrice);
|
|
|
|
- System.out.println("卷值"+voucherMon);
|
|
|
|
- BigDecimal allPriceBig =new BigDecimal(allPrice.toString());
|
|
|
|
- BigDecimal voucherMonBig =new BigDecimal(voucherMon.toString());
|
|
|
|
- BigDecimal withVocherPriceBig =allPriceBig.subtract(voucherMonBig);
|
|
|
|
- BigDecimal discontBig =new BigDecimal(discount.toString());
|
|
|
|
-
|
|
|
|
- if(withVocherPriceBig.doubleValue()<=0){
|
|
|
|
- withVocherPriceBig=new BigDecimal("0");
|
|
|
|
- }
|
|
|
|
|
|
+ Double allPrice = goodImp.computePrice(goodVOS);
|
|
|
|
+ WeiXinPayDTO weiXinPayDTO1 = new WeiXinPayDTO();
|
|
|
|
+ BeanUtils.copyProperties(weiXinPayDTO, weiXinPayDTO1);
|
|
|
|
+ weiXinPayDTO1.setFinalPrice(allPrice);
|
|
|
|
+ Object obj = activityService.executeActivity(weiXinPayDTO, type, 0, null);
|
|
|
|
+ Double trueDiscount = (Double) obj;
|
|
|
|
+ if (trueDiscount == null) {
|
|
|
|
+ trueDiscount = 1d;
|
|
|
|
+ }
|
|
|
|
+ System.out.println("总价" + allPrice);
|
|
|
|
+ System.out.println("卷值" + voucherMon);
|
|
|
|
+ BigDecimal allPriceBig = new BigDecimal(allPrice.toString());
|
|
|
|
+ BigDecimal voucherMonBig = new BigDecimal(voucherMon.toString());
|
|
|
|
+ BigDecimal withVocherPriceBig = allPriceBig.subtract(voucherMonBig);
|
|
|
|
+ BigDecimal discontBig = new BigDecimal(trueDiscount.toString());
|
|
|
|
+
|
|
|
|
+ if (withVocherPriceBig.doubleValue() <= 0) {
|
|
|
|
+ withVocherPriceBig = new BigDecimal("0");
|
|
|
|
+ }
|
|
//查看是否有折扣
|
|
//查看是否有折扣
|
|
// 计算价格 (商品总价格-优惠券) *折扣
|
|
// 计算价格 (商品总价格-优惠券) *折扣
|
|
- BigDecimal truePriceBig =withVocherPriceBig.multiply(discontBig);
|
|
|
|
- System.out.println("价格"+truePriceBig);
|
|
|
|
-
|
|
|
|
- System.out.println("折扣"+discontBig);
|
|
|
|
- Double truePrice=truePriceBig.doubleValue();
|
|
|
|
- System.out.println("总价"+truePrice);
|
|
|
|
- if(!truePrice.equals(price)){
|
|
|
|
- throw new BusinessException(ExceptionEnum.BUSINESS_ERROR,"价格错误");
|
|
|
|
|
|
+ BigDecimal truePriceBig = withVocherPriceBig.multiply(discontBig);
|
|
|
|
+ System.out.println("价格" + truePriceBig);
|
|
|
|
+
|
|
|
|
+ System.out.println("折扣" + discontBig);
|
|
|
|
+ Double truePrice = truePriceBig.doubleValue();
|
|
|
|
+ System.out.println("总价" + truePrice);
|
|
|
|
+ if (!truePrice.equals(price)) {
|
|
|
|
+ throw new BusinessException(ExceptionEnum.BUSINESS_ERROR, "价格错误");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private OrderMessageVO getOrderMessage(WeiXinPayDTO weiXinPayDTO, PersonnelVO personVO) {
|
|
|
|
+ OrderMessageVO orderMessageVO = new OrderMessageVO();
|
|
|
|
+ List<GoodVO> goodVOS = weiXinPayDTO.getGoods();
|
|
|
|
+ List<Integer> assoVoucherIds = weiXinPayDTO.getPersonVoucherIds();
|
|
|
|
+ Integer type = weiXinPayDTO.getGoodType();
|
|
|
|
+ Integer activityId = weiXinPayDTO.getActivityId();
|
|
|
|
+ //校验优惠卷是否能使用
|
|
|
|
+ Double voucherMon = assoPersonVoucherService.verifyVouchers(assoVoucherIds, personVO);
|
|
|
|
+ GoodImp goodImp = goodFactory.getClass(type);
|
|
|
|
+ Double allPrice = goodImp.computePrice(goodVOS);
|
|
|
|
+
|
|
|
|
+ orderMessageVO.setPrice(allPrice);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ BigDecimal allPriceBig = new BigDecimal(allPrice.toString());
|
|
|
|
+ BigDecimal voucherMonBig = new BigDecimal(voucherMon.toString());
|
|
|
|
+ BigDecimal withVocherPriceBig = allPriceBig.subtract(voucherMonBig);
|
|
|
|
+ weiXinPayDTO.setPrice(withVocherPriceBig.doubleValue());
|
|
|
|
+ Object obj = activityService.executeActivity(weiXinPayDTO, type, 0, activityId);
|
|
|
|
+ Double trueDiscount = (Double) obj;
|
|
|
|
+ if (trueDiscount == null) {
|
|
|
|
+ trueDiscount = 1d;
|
|
|
|
+ }
|
|
|
|
+ orderMessageVO.setDiscount(trueDiscount);
|
|
|
|
+ BigDecimal discontBig = new BigDecimal(trueDiscount.toString());
|
|
|
|
+ if (withVocherPriceBig.doubleValue() <= 0) {
|
|
|
|
+ withVocherPriceBig = new BigDecimal("0");
|
|
|
|
+ }
|
|
|
|
+ BigDecimal truePriceBig = withVocherPriceBig.multiply(discontBig);
|
|
|
|
+ orderMessageVO.setFinalPrice(truePriceBig.doubleValue());
|
|
|
|
+ return orderMessageVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public OrderDetailVO getOrderDetail(WeiXinPayDTO weiXinPayDTO) {
|
|
|
|
+ Integer type = weiXinPayDTO.getGoodType();
|
|
|
|
+ Integer activityId = weiXinPayDTO.getActivityId();
|
|
|
|
+ OrderDetailVO orderDetailVO = new OrderDetailVO();
|
|
|
|
+ List<GoodVO> goodVOS = weiXinPayDTO.getGoods();
|
|
|
|
+ List<Activity> activities = activityService.getActivities(activityId, type, 0);
|
|
|
|
+ PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
|
|
|
|
+ OrderMessageVO orderMessageVO = this.getOrderMessage(weiXinPayDTO, personnelVO);
|
|
|
|
+ orderDetailVO.setOrderMessage(orderMessageVO);
|
|
|
|
+ orderDetailVO.setActivities(activities);
|
|
|
|
+ orderDetailVO.setGoods(goodVOS);
|
|
|
|
+ orderDetailVO.setPersonVoucherIds(weiXinPayDTO.getPersonVoucherIds());
|
|
|
|
+ return orderDetailVO;
|
|
|
|
+ }
|
|
}
|
|
}
|