|
|
@@ -34,14 +34,10 @@ import com.cyksj.dto.RedisKey;
|
|
|
import com.cyksj.dto.Result;
|
|
|
import com.cyksj.enums.GatewayResponse;
|
|
|
import com.cyksj.mapper.*;
|
|
|
-import com.cyksj.mapper.manage.distribute.*;
|
|
|
-import com.cyksj.model.dto.AliPayParams;
|
|
|
-import com.cyksj.model.dto.H5JsPayParams;
|
|
|
-import com.cyksj.model.dto.WxMpTemplateData;
|
|
|
-import com.cyksj.model.dto.WxMpTemplateMessage;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponSkuMapper;
|
|
|
import com.cyksj.mapper.manage.coupon.CouponUserMapper;
|
|
|
+import com.cyksj.mapper.manage.distribute.*;
|
|
|
import com.cyksj.model.dto.*;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
@@ -69,8 +65,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_ALREADY_BE_USER;
|
|
|
import static com.cyksj.enums.GatewayApiCode.GROUP_INDEX_NOT_FIND;
|
|
|
@@ -1036,6 +1034,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
alipayTradeWapPayModel.setTotalAmount(orderDon.getMoney().divide(new BigDecimal(100), 2, RoundingMode.HALF_EVEN).toString());
|
|
|
alipayTradeWapPayModel.setSubject(goodsDon.getTitle());
|
|
|
alipayTradeWapPayModel.setProductCode(productCode);
|
|
|
+ //5分钟订单失效时间
|
|
|
+ alipayTradeWapPayModel.setTimeExpire(DateUtil.offsetMinute(orderDon.getCreatedTime(), 5).toString());
|
|
|
alipayTradeWapPayRequest.setBizModel(alipayTradeWapPayModel);
|
|
|
return alipayTradeWapPayRequest;
|
|
|
} else if (ZfbProductCode.PC_WEB.getProductCode().equals(productCode)) {
|
|
|
@@ -1169,7 +1169,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (exists == null) {
|
|
|
throw BusinessRuntimeException.getInstance("该优惠码不存在");
|
|
|
}
|
|
|
- checkCouponGoods(goodsDon, skuId, exists.getType(), exists.getGoodsSkuIds(), true);
|
|
|
+ checkCouponGoods(goodsDon, skuId, exists.getCouponId(), true);
|
|
|
//检验是否续费可使用
|
|
|
if (isRenew && !exists.getIsRenew()) {
|
|
|
throw BusinessRuntimeException.getInstance("该优惠券续费时不可使用");
|
|
|
@@ -1201,7 +1201,7 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
if (couponUserView.getCouponUserStatus() != CouponUser.Status.unused) {
|
|
|
throw BusinessRuntimeException.getInstance(couponUserView.getReason());
|
|
|
}
|
|
|
- checkCouponGoods(goodsDon, skuId, couponUserView.getType(), couponUserView.getGoodsSkuIds(), false);
|
|
|
+ checkCouponGoods(goodsDon, skuId, couponUserView.getCouponId(), false);
|
|
|
//检验是否续费可使用
|
|
|
if (isRenew && !couponUserView.getIsRenew()) {
|
|
|
throw BusinessRuntimeException.getInstance("该优惠券续费时不可使用");
|
|
|
@@ -1276,16 +1276,21 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
log.info("订单:{}退款,优惠券返还end...", orderDon.getId());
|
|
|
}
|
|
|
|
|
|
- public void checkCouponGoods(GoodsDon goodsDon, Long skuId, Coupon.Type type, String goodsSkuIds, Boolean isCouponCode) throws Exception {
|
|
|
+ public void checkCouponGoods(GoodsDon goodsDon, Long skuId, Long couponId, Boolean isCouponCode) throws Exception {
|
|
|
if (goodsDon.getType() == 1) {
|
|
|
- List<Coupon.CouponGoodsSku> skuIds = Jsons.parseList(goodsSkuIds, Coupon.CouponGoodsSku.class);
|
|
|
- Set<Long> collect = skuIds.stream().map(Coupon.CouponGoodsSku::getSkuId).collect(Collectors.toSet());
|
|
|
- if (!collect.contains(skuId)) {
|
|
|
+ CouponSku couponSku = couponSkuMapper.selectOne(Wrappers.lambdaQuery(CouponSku.class)
|
|
|
+ .eq(CouponSku::getSkuId, skuId)
|
|
|
+ .eq(CouponSku::getCouponId, couponId)
|
|
|
+ .select(CouponSku::getId).last("limit 1"));
|
|
|
+ if (couponSku == null) {
|
|
|
throw BusinessRuntimeException.getInstance(String.format("该%s不适用于该规格", isCouponCode ? "优惠码" : "优惠券"));
|
|
|
}
|
|
|
} else {
|
|
|
Long gid = goodsDon.getId();
|
|
|
- CouponSku couponSku = couponSkuMapper.selectOne(Wrappers.lambdaQuery(CouponSku.class).eq(CouponSku::getGoodsId, gid).eq(CouponSku::getDeleted, true).select(CouponSku::getId).last("limit 1"));
|
|
|
+ CouponSku couponSku = couponSkuMapper.selectOne(Wrappers.lambdaQuery(CouponSku.class)
|
|
|
+ .eq(CouponSku::getGoodsId, gid)
|
|
|
+ .eq(CouponSku::getCouponId, couponId)
|
|
|
+ .select(CouponSku::getId).last("limit 1"));
|
|
|
if (couponSku == null) {
|
|
|
throw BusinessRuntimeException.getInstance(String.format("该%s不可用于实物商品", isCouponCode ? "优惠码" : "优惠券"));
|
|
|
}
|