袁野 1 month ago
parent 74600b4e78
commit 4779cbaf7d
  1. 87
      bweb/src/main/java/com/bweb/controller/TestController.java
  2. 4
      schedule/src/main/java/com/schedule/controller/OrderGoodsSchedule.java
  3. 5
      service/src/main/java/com/hfkj/jd/Impl/JdServiceImpl.java
  4. 3
      service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java
  5. 8
      service/src/main/java/com/hfkj/service/goods/GoodPresentService.java
  6. 126
      service/src/main/java/com/hfkj/service/goods/impl/GoodPresentServiceImpl.java
  7. 13
      service/src/main/java/com/hfkj/service/goods/impl/GoodsAutoTaskServiceImpl.java
  8. 3
      service/src/main/java/com/hfkj/service/goods/impl/GoodsTypeServiceImpl.java
  9. 3
      service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java
  10. 122
      service/src/main/java/com/hfkj/service/order/impl/BsOrderRefundServiceImpl.java
  11. 5
      service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java

@ -1,5 +1,6 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
@ -9,6 +10,7 @@ import com.hfkj.config.AliMessageConfig;
import com.hfkj.config.ShanGaoConfig;
import com.hfkj.entity.*;
import com.hfkj.haioil.HaiOilService;
import com.hfkj.jd.JdPostService;
import com.hfkj.jd.JdService;
import com.hfkj.model.OpenAccountRequestDto;
@ -55,6 +57,9 @@ public class TestController {
@Resource
private CmsContentService cmsContentService;
@Resource
private GoodsTypeService goodsTypeService;
@RequestMapping(value="/getLogisticsMsg",method = RequestMethod.GET)
@ -412,7 +417,89 @@ public class TestController {
}
}
@RequestMapping(value="/pushPk",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "送券")
public ResponseData pushPk() {
try {
Map<String , Object> pushMap = new HashMap<>();
pushMap.put("discountPkNo" , "DPK10014"); // 添加礼品密钥
pushMap.put("number" , 1); // 添加数量
pushMap.put("phone" , "18090580471"); // 添加用户手机号
return ResponseMsgUtil.success(HaiOilService.pushPk(pushMap));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/queryPkDetailByStockCode",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询用来多少前")
public ResponseData queryPkDetailByStockCode(@RequestParam(value = "discountPkStockCode", required = false) String discountPkStockCode) {
try {
// 定义已经使用的金额
BigDecimal useAmount = BigDecimal.ZERO;
// 查询嗨加油优惠券使用剩余情况
Map<String , Object> map = new HashMap<>();
map.put("discountPkStockCode" , discountPkStockCode);
JSONObject returnParam = HaiOilService.queryPkDetailByStockCode(map);
if (returnParam.getString("return_code").equals("000000")) {
JSONArray data = returnParam.getJSONObject("return_data").getJSONArray("codeList");
// 1:未使用 2:已使用 3:已过期 4:已作废
for (int i = 0; i < data.size(); i++) {
JSONObject jsonObject = data.getJSONObject(i);
if (!jsonObject.getInteger("status").equals(1)) {
useAmount = useAmount.add(jsonObject.getBigDecimal("discountPrice"));
}
}
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!");
}
return ResponseMsgUtil.success(useAmount);
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/refundPk",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "回收券包")
public ResponseData refundPk(@RequestParam(value = "discountPkStockCode", required = false) String discountPkStockCode) {
try {
Map<String , Object> mapRefund = new HashMap<>();
mapRefund.put("discountPkStockCode" , discountPkStockCode);
return ResponseMsgUtil.success(HaiOilService.refundPk(mapRefund));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/goodType",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "上线使用的分类")
public ResponseData goodType() {
try {
// 查询已经上架商品
Map<String , Object> good = new HashMap<>();
good.put("status" , 1);
List<GoodsMsg> goodsMsg = goodsMsgService.getList(good);
for (GoodsMsg goodsMsg1 : goodsMsg) {
if (goodsMsg1.getGoodsType() != null){
GoodsType goodsType = goodsTypeService.queryDetail(goodsMsg1.getGoodsType());
goodsType.setStatus(1);
goodsTypeService.update(goodsType);
}
}
return ResponseMsgUtil.success("完成");
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -233,7 +233,7 @@ public class OrderGoodsSchedule {
if (!list.isEmpty()) {
for (GoodsAutoTask goodsAutoTask : list) {
if(goodsAutoTask.getListingTime() != null) {
if(goodsAutoTask.getListingTime().getTime() <= System.currentTimeMillis()) {
// 执行逻辑
goodsAutoTaskService.startListingTask(goodsAutoTask , 1);
}
@ -252,7 +252,7 @@ public class OrderGoodsSchedule {
List<GoodsAutoTask> list = goodsAutoTaskService.getRemovalTimeList();
for (GoodsAutoTask goodsAutoTask : list) {
if(goodsAutoTask.getRemovalTime() != null) {
if(goodsAutoTask.getRemovalTime().getTime() <= System.currentTimeMillis()) {
// 执行逻辑
goodsAutoTaskService.startListingTask(goodsAutoTask , 2);
}

@ -444,10 +444,7 @@ public class JdServiceImpl implements JdService {
JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "skuId编码错误");
return true;
}
if (!goodsMsg.getTitle().equals(resp.getSkuInfoList().get(0).getSkuName())) {
JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "商品错误!");
return true;
}
if (resp.getOrderPrice().getOrderTotalPrice().compareTo(bsOrder.getTotalPrice()) > 0) {
JdPostService.cancelOrder(getToken(), Long.valueOf(orderGoods.getThirdOrderNo()), orderGoods.getChildOrderNo() , "商品价格错误");

@ -80,6 +80,9 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService {
if (MapUtils.getLong(map, "finishTimeE") != null) {
criteria.andUpdateTimeLessThan(new Date(MapUtils.getLong(map, "finishTimeE")));
}
if (StringUtils.isNotBlank(MapUtils.getString(map ,"childOrderNo"))) {
criteria.andChildOrderNoEqualTo(MapUtils.getString(map ,"childOrderNo"));
}
if (MapUtils.getLong(map, "merId") != null) {
criteria.andMerIdEqualTo(MapUtils.getLong(map, "merId"));
}

@ -1,7 +1,10 @@
package com.hfkj.service.goods;
import com.hfkj.entity.BsOrderChild;
import com.hfkj.entity.GoodPresent;
import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import java.util.List;
import java.util.Map;
@ -60,9 +63,10 @@ public interface GoodPresentService {
/**
* @MethodName PresentDiscountPackage
* @Description:
* @param specsId
* @param order
* @param orderChild
* @Author: Sum1Dream
* @Date: 2024/12/30 下午3:47
*/
void presentDiscountPackage(Long specsId, String phone) throws Exception;
void presentDiscountPackage(OrderModel order, BsOrderChild orderChild) throws Exception;
}

@ -1,13 +1,26 @@
package com.hfkj.service.goods.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.RandomUtils;
import com.hfkj.dao.GoodPresentMapper;
import com.hfkj.entity.CouponDiscountPackage;
import com.hfkj.entity.GoodPresent;
import com.hfkj.entity.GoodPresentExample;
import com.hfkj.entity.GoodsBrand;
import com.hfkj.entity.*;
import com.hfkj.haioil.HaiOilService;
import com.hfkj.model.order.OrderChildModel;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.coupon.BsOrderCouponNoService;
import com.hfkj.service.coupon.BsOrderCouponService;
import com.hfkj.service.coupon.channel.HuiLianTongCouponService;
import com.hfkj.service.discount.CouponDiscountPackageService;
import com.hfkj.service.goods.GoodPresentService;
import com.hfkj.service.hlt.HuiLianTongUnionCardService;
import com.hfkj.service.order.BsOrderChildService;
import com.hfkj.sysenum.GoodsVpdSourceEnum;
import com.hfkj.sysenum.order.OrderChildStatusEnum;
import com.hfkj.sysenum.order.OrderCouponNoStatusEnum;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -20,10 +33,17 @@ public class GoodPresentServiceImpl implements GoodPresentService {
@Resource
private GoodPresentMapper goodPresentMapper;
@Resource
private BsOrderChildService orderChildService;
@Resource
private CouponDiscountPackageService couponDiscountPackageService;
@Resource
private BsOrderCouponService orderCouponService;
@Resource
private BsOrderCouponNoService orderCouponNoService;
@Override
public void create(GoodPresent goodPresent) {
goodPresentMapper.insert(goodPresent);
@ -66,21 +86,103 @@ public class GoodPresentServiceImpl implements GoodPresentService {
@Override
public void presentDiscountPackage(Long specsId , String phone) throws Exception {
public void presentDiscountPackage(OrderModel order, BsOrderChild orderChild) throws Exception {
orderChild.setExt2("1001");
orderChildService.editData(orderChild);
// 创建一个Map对象,用于存储查询条件
Map<String , Object> map = new HashMap<>();
map.put("specsId",specsId);
// 向Map中添加商品规格ID作为查询条件
map.put("specsId",orderChild.getProductSpecId());
// 根据查询条件获取礼品列表
List<GoodPresent> list = getList(map);
// 遍历礼品列表
for (GoodPresent goodPresent : list) {
// 创建卡券订单对象
BsOrderCoupon orderCoupon = new BsOrderCoupon();
// 设置卡券订单的基本信息
orderCoupon.setOrderNo(orderChild.getOrderNo()); // 设置订单号
orderCoupon.setChildOrderNo(orderChild.getChildOrderNo()); // 设置子订单号
orderCoupon.setMerId(orderChild.getMerId()); // 设置商家ID
orderCoupon.setUserId(order.getUserId()); // 设置用户ID
orderCoupon.setGoodsId(orderChild.getProductId()); // 设置商品ID
orderCoupon.setGoodsName(orderChild.getProductName()); // 设置商品名称
// 设置商品规格相关信息
orderCoupon.setGoodsSpecsId(orderChild.getProductSpecId()); // 设置商品规格ID
orderCoupon.setGoodsSpecsName(orderChild.getProductSpecName()); // 设置商品规格名称
orderCoupon.setGoodsSpescOriginalPrice(orderChild.getProductPrice()); // 设置商品规格原价
orderCoupon.setGoodsSpescSalePrice(orderChild.getProductActualPrice()); // 设置商品规格售价
orderCoupon.setGoodsVpdKey(goodPresent.getKey()); // 设置商品礼品密钥
orderCoupon.setGoodsCount(1); // 设置商品数量
orderCoupon.setStatus(OrderChildStatusEnum.status3.getCode()); // 设置订单状态
// 创建优惠券折扣包对象
CouponDiscountPackage discountPackage = new CouponDiscountPackage();
JSONObject returnParam = new JSONObject();
// 根据礼品类型处理不同的逻辑
if (goodPresent.getType() == 1) {
// 类型为1时,处理优惠券折扣包
discountPackage = couponDiscountPackageService.findDiscountPackageByKey(goodPresent.getKey());
couponDiscountPackageService.giveDiscountPackage(discountPackage.getId().intValue() , order.getUserPhone() , null);
orderCoupon.setGoodsVpdSource(1); // 设置礼品来源为1
} else {
// 类型不为1时,处理其他类型的礼品
Map<String , Object> pushMap = new HashMap<>();
pushMap.put("discountPkNo" , goodPresent.getKey()); // 添加礼品密钥
pushMap.put("number" , 1); // 添加数量
pushMap.put("phone" , order.getUserPhone()); // 添加用户手机号
returnParam = HaiOilService.pushPk(pushMap); // 调用服务推送礼品
orderCoupon.setGoodsVpdSource(3); // 设置礼品来源为3
}
// 保存卡券订单信息
orderCouponService.editData(orderCoupon);
// 卡券订单卡密
BsOrderCouponNo orderCouponNo = new BsOrderCouponNo();
// 设置优惠券订单号关联的订单ID
orderCouponNo.setCouponOrderId(orderCoupon.getId());
// 设置订单号,由优惠券ID和6位随机数字组成
orderCouponNo.setOrderNo(orderCoupon.getId() + RandomUtils.number(6, false));
// 设置商品VPD键
orderCouponNo.setGoodsVpdKey(orderCoupon.getGoodsVpdKey());
// 设置商品VPD来源
orderCouponNo.setGoodsVpdSource(orderCoupon.getGoodsVpdSource());
// 设置过期状态为未过期
orderCouponNo.setExpireStatus(false);
// 设置异常状态为未异常
orderCouponNo.setExceptionStatus(false);
// 设置优惠券状态为状态2
orderCouponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode());
// 根据商品类型进行不同处理
if (goodPresent.getType() == 1) {
CouponDiscountPackage discountPackage = couponDiscountPackageService.findDiscountPackageByKey(goodPresent.getKey());
couponDiscountPackageService.giveDiscountPackage(discountPackage.getId().intValue() , phone , null);
// 如果是类型1,设置过期时间为优惠套餐的有效时间
orderCouponNo.setExpireTime(discountPackage.getEffectiveTime());
// 设置交付时间为当前时间
orderCouponNo.setDeliverTime(new Date());
// 设置商品VPD来源优惠券号为优惠套餐的键
orderCouponNo.setGoodsVpdSourceCouNo(discountPackage.getKey());
} else {
map.put("discountPkNo" , goodPresent.getKey());
map.put("number" , 1);
map.put("phone" , phone);
HaiOilService.pushPk(map);
// 如果不是类型1,从返回参数中获取数据
JSONArray dataArray = returnParam.getJSONObject("return_data").getJSONArray("list");
// 设置过期时间为返回数据中的过期日期
orderCouponNo.setExpireTime(dataArray.getJSONObject(0).getJSONArray("codeList").getJSONObject(0).getDate("expirationDate"));
// 设置交付时间为当前时间
orderCouponNo.setDeliverTime(new Date());
// 设置渠道订单号为返回数据中的请求ID
orderCouponNo.setChannelOrderNo(returnParam.getJSONObject("return_data").getString("reqId"));
// 设置商品VPD来源优惠券号为返回数据中的折扣库存代码
orderCouponNo.setGoodsVpdSourceCouNo(dataArray.getJSONObject(0).getString("discountPkStockCode"));
}
// 更新优惠券订单号数据
orderCouponNoService.editData(orderCouponNo);
}
}
}

@ -164,7 +164,6 @@ public class GoodsAutoTaskServiceImpl implements GoodsAutoTaskService {
// 判断是上架操作还是下架操作
if (taskType == 1) {
// 判断商品上架时间是否已到(将时间戳转换为秒进行比较)
if (rel.getListingTime().getTime() / 1000 <= System.currentTimeMillis() / 1000) {
// 上架操作,更新商品状态为上架
// 根据商品ID查询规格列表
List<GoodsSpecs> specs = goodsSpecsService.getList(specsMap);
@ -180,18 +179,10 @@ public class GoodsAutoTaskServiceImpl implements GoodsAutoTaskService {
}
// 更新商品状态和更新时间
goodsMsg.setStatus(1); // 设置商品状态为已上架
}
} else {
// 检查商品是否应该被下架
// 比较商品的下架时间和当前时间(秒级)
if (rel.getRemovalTime().getTime() / 1000 <= System.currentTimeMillis() / 1000) {
// 下架操作,更新商品状态为下架
goodsMsg.setStatus(2);
}
// 下架操作,更新商品状态为下架
goodsMsg.setStatus(2);
}
goodsMsg.setUpdateTime(new Date());

@ -113,6 +113,9 @@ public class GoodsTypeServiceImpl implements GoodsTypeService {
} else {
criteria.andStatusNotEqualTo(0);
}
if (MapUtils.getInteger(map , "child") != null) {
criteria.andParentIdIsNotNull();
}
example.setOrderByClause("sort asc");
return goodsTypeMapper.selectByExample(example);

@ -160,7 +160,6 @@ public class OrderPaySuccessService {
if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) {
// 查询优惠券包
CouponDiscountPackage couponDiscountPackage = discountPackageService.findDiscountPackageByKey(vpd.getKey());
if (couponDiscountPackage != null) {
couponDiscountPackageService.giveDiscountPackage(couponDiscountPackage.getId().intValue() , order.getUserPhone() , couponNo.getId()) ;
couponNo.setExpireTime(couponDiscountPackage.getEffectiveTime());
@ -298,7 +297,7 @@ public class OrderPaySuccessService {
jdService.confirmOrder(goodsOrder);
}
if (childOrder.getProductSpecId() != null) {
goodPresentService.presentDiscountPackage(childOrder.getProductSpecId() , order.getUserPhone());
goodPresentService.presentDiscountPackage(order , childOrder);
}
goodsMsgService.editSaleNum(goodsOrder.getGoodsId() , goodsOrder.getGoodsCount() , 1);

@ -187,7 +187,6 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的交易订单");
}
// 创建退款订单
BsOrderRefund orderRefund = new BsOrderRefund();
orderRefund.setMerId(orderChild.getMerId());
@ -243,20 +242,51 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
} else {
if (orderChild.getSurplusRefundCount().equals(productCount)) {
// 全部退款
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
} else {
// 部分退款
// 计算单价
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
.divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
if (orderChild.getExt2() != null && orderChild.getExt2().equals("10001")) {
BigDecimal useAmount;
useAmount = getGoodsPresentRefundAmount(orderChild);
if (useAmount == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!");
}
if (useAmount.compareTo(new BigDecimal(0)) == 0) {
// 全部退款
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
} else {
// 判断支付金额
if (orderChild.getProductActualPrice().compareTo(useAmount) > 0) {
// 部分退款
// 计算单价
BigDecimal unitPrice = orderChild.getProductActualPrice().subtract(useAmount);
BigDecimal unitPriceIntegral = unitPrice.divide(orderChild.getProductActualPrice() , 2, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(orderChild.getSurplusRefundIntegral().toString()));
orderRefund.setRefundPrice(unitPrice);
orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
}
if (orderChild.getProductActualPrice().compareTo(useAmount) < 0) {
throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "金额不足,退款失败");
}
}
} {
if (orderChild.getSurplusRefundCount().equals(productCount)) {
// 全部退款
orderRefund.setRefundPrice(orderChild.getSurplusRefundPrice());
orderRefund.setRefundIntegral(orderChild.getSurplusRefundIntegral());
} else {
// 部分退款
// 计算单价
BigDecimal unitPrice = orderChild.getSurplusRefundPrice().divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
BigDecimal unitPriceIntegral = new BigDecimal(orderChild.getSurplusRefundIntegral().toString()).divide(new BigDecimal("100"))
.divide(new BigDecimal(orderChild.getProductCount().toString()), 2, BigDecimal.ROUND_DOWN).setScale(2);
orderRefund.setRefundPrice(unitPrice.multiply(new BigDecimal(productCount.toString())));
orderRefund.setRefundIntegral(unitPriceIntegral.multiply(new BigDecimal("100")).longValue());
}
}
}
@ -540,7 +570,7 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
// 定义已经使用的金额
BigDecimal useAmount = BigDecimal.ZERO;
// 查询内部优惠券包剩余情况
// 查询优惠券包剩余情况
for (BsOrderCouponNo couponNo : couponNoList) {
// 内部优惠券
if (couponNo.getGoodsVpdSource() == GoodsVpdSourceEnum.type1.getCode()) {
@ -578,7 +608,67 @@ public class BsOrderRefundServiceImpl implements BsOrderRefundService {
}
}
// 查询嗨加油优惠券包剩余情况
return useAmount;
} catch (Exception e) {
System.out.println(e);
}
return null;
}
private BigDecimal getGoodsPresentRefundAmount(OrderChildModel orderChild){
try {
// 定义已经使用的金额
BigDecimal useAmount = BigDecimal.ZERO;
Map<String , Object> mapCouPon = new HashMap<>();
mapCouPon.put("childOrderNo" , orderChild.getChildOrderNo());
// 查询卡券订单
List<BsOrderCoupon> orderCoupon = orderCouponService.getOrderCouponList(mapCouPon);
for (BsOrderCoupon coupon : orderCoupon) {
// 查询卡券订单的卡密
List<BsOrderCouponNo> couponNoList = orderCouponNoService.getListByCouponOrderId(coupon.getId());
// 查询优惠券包剩余情况
for (BsOrderCouponNo couponNo : couponNoList) {
// 内部优惠券
if (couponNo.getGoodsVpdSource() == GoodsVpdSourceEnum.type1.getCode()) {
// 查询用户优惠券使用情况
Map<String , Object> map = new HashMap<>();
map.put("couponOrderId" , couponNo.getId());
List<CouponDiscountUserRel> userRelList = discountUserRelService.getList(map);
useAmount = userRelList.stream().filter(s->s.getStatus().equals(2)).map(CouponDiscountUserRel::getDiscountPrice).reduce(BigDecimal.ZERO, BigDecimal::add).add(userRelList.stream().filter(s->s.getStatus().equals(0)).map(CouponDiscountUserRel::getDiscountPrice).reduce(BigDecimal.ZERO, BigDecimal::add));
} else if (couponNo.getGoodsVpdSource() == GoodsVpdSourceEnum.type3.getCode()) {
// 查询嗨加油优惠券使用剩余情况
Map<String , Object> map = new HashMap<>();
map.put("discountPkStockCode" , couponNo.getGoodsVpdSourceCouNo());
JSONObject returnParam = HaiOilService.queryPkDetailByStockCode(map);
if (returnParam.getString("return_code").equals("000000")) {
JSONArray data = returnParam.getJSONObject("return_data").getJSONArray("codeList");
// 1:未使用 2:已使用 3:已过期 4:已作废
for (int i = 0; i < data.size(); i++) {
JSONObject jsonObject = data.getJSONObject(i);
if (!jsonObject.getInteger("status").equals(1)) {
useAmount = useAmount.add(jsonObject.getBigDecimal("discountPrice"));
}
}
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!");
}
// 回收券包
Map<String , Object> mapRefund = new HashMap<>();
mapRefund.put("discountPkStockCode" , couponNo.getGoodsVpdSourceCouNo());
JSONObject refundParam = HaiOilService.refundPk(mapRefund);
if (!refundParam.getString("return_code").equals("000000") || !refundParam.getString("return_data").equals("ok")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!");
}
}
}
}
return useAmount;
} catch (Exception e) {

@ -155,14 +155,14 @@ public class BsOrderServiceImpl implements BsOrderService {
/************** 处理业务 ***************/
for (OrderChildModel child : order.getOrderChildList()) {
if (child.getProductCount() < 1) {
if (child.getProductCount() != null && child.getProductCount() < 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商品数量不能小于1!");
}
// 查询规格
GoodsSpecs specs = goodsSpecsService.queryDetail(child.getProductSpecId());
if (specs.getPurLimit() != null) {
if (specs != null && specs.getPurLimit() != null) {
boolean l = checkPurchaseLimit(order.getUserId() , specs.getId());
if (l) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商品限购数量不能超过" + specs.getPurLimit());
@ -183,7 +183,6 @@ public class BsOrderServiceImpl implements BsOrderService {
// checkPurchaseLimit 限购
child.setOrderNo(order.getOrderNo());
// 子订单号 交易id + 线程随机数 + 4位随机数
child.setChildOrderNo(order.getId()+ IDGenerator.nextId(1) +RandomUtils.number(4, false));

Loading…
Cancel
Save