diff --git a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java index bb6934f..70fa838 100644 --- a/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java +++ b/bweb/src/main/java/com/bweb/controller/goods/GoodsController.java @@ -133,6 +133,7 @@ public class GoodsController { goodsMsg.setGoodsTypeParent(goodsType.getParentId()); goodsMsg.setGoodsTypeParentName(goodsTypeService.findGoodsType(goodsType.getParentId())); goodsMsg.setType(body.getType()); + goodsMsg.setShowType(body.getShowType()); goodsMsg.setGoodsBrand(body.getGoodsBrand()); goodsMsg.setStatus(body.getStatus()); goodsMsg.setTitle(body.getTitle()); @@ -256,7 +257,6 @@ public class GoodsController { // 判断必填项 if ( goodsSpecs.getId() == null || body.getValidDay() == null - || body.getType() == null || body.getSource() == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } @@ -271,7 +271,6 @@ public class GoodsController { goodsVpd.setSpecsId(goodsSpecs.getId()); goodsVpd.setValidDay(body.getValidDay()); - goodsVpd.setType(body.getType()); goodsVpd.setJumpType(body.getJumpType()); goodsVpd.setJumpUrl(body.getJumpUrl()); goodsVpd.setAppid(body.getAppid()); diff --git a/cweb/src/main/java/com/cweb/config/AuthConfig.java b/cweb/src/main/java/com/cweb/config/AuthConfig.java index 8814050..112bed5 100644 --- a/cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -95,6 +95,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/starbucks/*") .excludePathPatterns("/meiTuan/*") .excludePathPatterns("/jd/*") + .excludePathPatterns("/output/*") ; } diff --git a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java index 5025619..1fa6cee 100644 --- a/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java +++ b/cweb/src/main/java/com/cweb/controller/cms/CmsContentController.java @@ -69,20 +69,21 @@ public class CmsContentController { Map goodsMap = new HashMap<>(); goodsMap.put("status" , 1); + goodsMap.put("showType" , 1); List goodsMsgs = new ArrayList<>(); if (cmsContent.getShowType() == 1) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(2).collect(Collectors.toList()); + goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(2).collect(Collectors.toList()); } if (cmsContent.getShowType() == 2) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(4).collect(Collectors.toList()); + goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(4).collect(Collectors.toList()); } if (cmsContent.getShowType() == 3) { goodsMap.put("goodsType", cmsContent.getShowDataId()); - goodsMsgs = goodsMsgService.getList(goodsMap).stream().limit(10).collect(Collectors.toList()); + goodsMsgs = goodsMsgService.getListCrest(goodsMap).stream().limit(10).collect(Collectors.toList()); } for (GoodsMsg goodsMsg : goodsMsgs) { diff --git a/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java index 6822885..af030a3 100644 --- a/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java +++ b/cweb/src/main/java/com/cweb/controller/discount/DiscountController.java @@ -1,5 +1,6 @@ package com.cweb.controller.discount; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -10,9 +11,11 @@ import com.hfkj.common.security.SessionObject; import com.hfkj.common.security.UserCenter; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.entity.*; +import com.hfkj.haioil.HaiOilService; import com.hfkj.model.ResponseData; import com.hfkj.model.SecUserSessionObject; import com.hfkj.model.UserSessionObject; +import com.hfkj.model.discount.CouponDiscountUserRelModel; import com.hfkj.model.discount.DiscountGoodsModel; import com.hfkj.service.CommonService; import com.hfkj.service.SecDictionaryService; @@ -63,18 +66,70 @@ public class DiscountController { @RequestMapping(value = "/getListUserDiscount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取用户优惠券列表") - public ResponseData getListUserDiscount(@RequestParam(value = "status", required = true) Integer status) { + public ResponseData getListUserDiscount( + @RequestParam(value = "status", required = true) Integer status, + @RequestParam(value = "source", required = true) Integer source + ) { try { // 用户session UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); - Map map = new HashMap<>(); + if (source == 1) { + Map map = new HashMap<>(); - map.put("userId", userSession.getUser().getId()); - map.put("status", status); + map.put("userId", userSession.getUser().getId()); + map.put("status", status); + + return ResponseMsgUtil.success(discountUserRelService.getList(map)); + + } else { + List list = new ArrayList<>(); + + if (userSession.getUser().getPhone() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户未绑定手机号!"); + } + + Map map = new HashMap<>(); + if (status == 0) { + status = 3; + } + map.put("status" , status); + map.put("phone" , userSession.getUser().getPhone()); + JSONObject object = HaiOilService.queryListByPhone(map); + if (object.getString("return_code").equals("000000")) { + JSONArray array = object.getJSONObject("return_data").getJSONArray("dataList"); + for (int i = 0; i < array.size(); i++) { + JSONObject jsonObject = array.getJSONObject(i); + CouponDiscountUserRelModel rel = new CouponDiscountUserRelModel(); + rel.setSource(2); + rel.setUserId(userSession.getUser().getId()); + rel.setDiscountName(jsonObject.getString("discountName")); + rel.setDiscountType(jsonObject.getInteger("discountType")); + rel.setDiscountCondition(jsonObject.getBigDecimal("discountCondition")); + if (jsonObject.getInteger("discountType") == 3) { + rel.setDiscountPercentage(jsonObject.getBigDecimal("discountPrice")); + } else { + rel.setDiscountPrice(jsonObject.getBigDecimal("discountPrice")); + } + if (jsonObject.getInteger("status") == 3) { + rel.setStatus(0); + }else { + rel.setStatus(jsonObject.getInteger("status")); + } + rel.setCreateTime(jsonObject.getDate("createTime")); + rel.setUseTime(jsonObject.getDate("useTime")); + rel.setUseEndTime(jsonObject.getDate("expirationTime")); + + list.add(rel); + } + return ResponseMsgUtil.success(list); + } else { + return ResponseMsgUtil.success(null); + } + + } - return ResponseMsgUtil.success(discountUserRelService.getList(map)); } catch (Exception e) { log.error("GoodsDetailController --> getListUser() error!", e); diff --git a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java index eefcc10..630ba37 100644 --- a/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java +++ b/cweb/src/main/java/com/cweb/controller/goods/GoodsController.java @@ -59,7 +59,6 @@ public class GoodsController { @Resource private GoodsVpdService goodsVpdService; - @Resource private JdService jdService; @@ -114,6 +113,7 @@ public class GoodsController { @RequestParam(value = "title", required = false) String title, @RequestParam(value = "goodsTypeParent", required = false) Long goodsTypeParent, @RequestParam(value = "goodsType", required = false) Long goodsType, + @RequestParam(value = "showType", required = false) Integer showType, @RequestParam(value = "goodsBrand", required = false) Long goodsBrand, @RequestParam(value = "price", required = false) Integer price, @RequestParam(value = "saleNum", required = false) Integer saleNum, @@ -129,6 +129,7 @@ public class GoodsController { map.put("title", title); map.put("goodsType", goodsType); + map.put("showType", showType); map.put("goodsTypeParent", goodsTypeParent); map.put("goodsBrand", goodsBrand); map.put("saleNum", saleNum); diff --git a/cweb/src/main/java/com/cweb/controller/output/OutputController.java b/cweb/src/main/java/com/cweb/controller/output/OutputController.java new file mode 100644 index 0000000..7804f8b --- /dev/null +++ b/cweb/src/main/java/com/cweb/controller/output/OutputController.java @@ -0,0 +1,101 @@ +package com.cweb.controller.output; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.api.ApiMerService; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.ResponseMsgUtil; +import com.hfkj.common.utils.SignatureUtil; +import com.hfkj.entity.*; +import com.hfkj.model.ResponseData; +import com.hfkj.model.UserSessionObject; +import com.hfkj.service.SecDictionaryService; +import com.hfkj.service.discount.CouponDiscountPackageService; +import com.hfkj.service.discount.CouponDiscountService; +import com.hfkj.service.discount.CouponDiscountUserRelService; +import com.hfkj.service.user.BsUserService; +import com.hfkj.sysenum.UserLoginPlatform; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +@Controller +@RequestMapping(value="/output") +@Api(value="输出外部接口") +public class OutputController { + + private static final Logger log = LoggerFactory.getLogger(OutputController.class); + + @Resource + private ApiMerService apiMerService; + + @Resource + private CouponDiscountUserRelService discountUserRelService; + @Resource + private BsUserService bsUserService; + + @RequestMapping(value = "/getListUserDiscount", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "获取用户优惠券列表") + public ResponseData getListUserDiscount(@RequestBody JSONObject body) { + try { + + if (body == null + || StringUtils.isBlank(body.getString("status")) + || StringUtils.isBlank(body.getString("phone")) + || StringUtils.isBlank(body.getString("sign")) + || StringUtils.isBlank(body.getString("appid")) + ) { + log.error("LoginController --> phone() error!", "请求参数校验失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询api商户信息 + ApiMer apiMer = apiMerService.queryDetail(body.getString("appid")); + + Map map = new HashMap<>(); + map.put("appid" , body.getString("appid")); + map.put("phone" , body.getString("phone")); + map.put("status" , body.getString("status")); + String sign = SignatureUtil.createSign(map , apiMer.getAppSecret()); + if (!body.getString("sign").equals(sign)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!"); + } + + // 查询用户信息 + BsUser user = bsUserService.getUser(body.getString("phone")); + + if (user == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户不存在!"); + } + + Map mapPost = new HashMap<>(); + + mapPost.put("userId", user.getId()); + mapPost.put("status", body.getInteger("status")); + + return ResponseMsgUtil.success(discountUserRelService.getList(mapPost)); + + } catch (Exception e) { + log.error("GoodsDetailController --> getListUser() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + + +} diff --git a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java index 1c78e25..249317c 100644 --- a/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java +++ b/order/src/main/java/com/order/controller/business/BsOrderGoodsController.java @@ -305,10 +305,6 @@ public class BsOrderGoodsController { BsOrderGoods goodsOrder = bsOrderGoodsService.queryDetail(body.getId()); - - - - if (goodsOrder == null) { throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , "信息错误!"); } diff --git a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java index 0663266..60357b3 100644 --- a/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/GoodsMsgMapperExt.java @@ -42,7 +42,6 @@ public interface GoodsMsgMapperExt { " SELECT" + " id ," + " title as title," + - " title as title," + " list_img as listImg," + " third_id as thirdId," + " sale_num as saleNum" + @@ -51,6 +50,7 @@ public interface GoodsMsgMapperExt { " and goods_type_parent = #{param.goodsTypeParent} " + " and title like concat('%',#{param.title},'%') " + " and goods_type = #{param.goodsType} " + + " and show_type = #{param.showType} " + " and goods_brand = #{param.goodsBrand} " + " ORDER BY update_time desc" + " ORDER BY create_time desc" + diff --git a/service/src/main/java/com/hfkj/entity/GoodsVpd.java b/service/src/main/java/com/hfkj/entity/GoodsVpd.java index 4dde190..3e46bd4 100644 --- a/service/src/main/java/com/hfkj/entity/GoodsVpd.java +++ b/service/src/main/java/com/hfkj/entity/GoodsVpd.java @@ -39,7 +39,7 @@ public class GoodsVpd implements Serializable { private Integer type; /** - * 产品来源:1.内部虚拟商品 4.贵州中石化 5.重庆中石油 6.比邻星停车券 7.四川中石油 10.中油优途中石油 + * 产品来源:1.内部优惠券包 2:娱尚虚拟商品 3:嗨加油优惠券包 4.贵州中石化 5.重庆中石油 6.比邻星停车券 7.四川中石油 10.中油优途中石油 */ private Integer source; diff --git a/service/src/main/java/com/hfkj/haioil/HaiOilService.java b/service/src/main/java/com/hfkj/haioil/HaiOilService.java index ef02a5b..b103a27 100644 --- a/service/src/main/java/com/hfkj/haioil/HaiOilService.java +++ b/service/src/main/java/com/hfkj/haioil/HaiOilService.java @@ -37,6 +37,27 @@ public class HaiOilService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); } + } + + + /** + * @MethodName queryListByPhone + * @Description: 根据手机号查询优惠券包 + * @param map + * @return: com.alibaba.fastjson.JSONObject + * @Author: Sum1Dream + * @Date: 2024/9/9 下午3:00 + */ + public static JSONObject queryListByPhone(Map map) throws Exception { + + JSONObject object = request("/openapi/discount/queryListByPhone" , map); + + if (Objects.equals(object.getString("return_code"), "000000")) { + return object; + } else { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败!"); + } + } /** diff --git a/service/src/main/java/com/hfkj/model/discount/CouponDiscountUserRelModel.java b/service/src/main/java/com/hfkj/model/discount/CouponDiscountUserRelModel.java new file mode 100644 index 0000000..3a05b9b --- /dev/null +++ b/service/src/main/java/com/hfkj/model/discount/CouponDiscountUserRelModel.java @@ -0,0 +1,14 @@ +package com.hfkj.model.discount; + +import com.hfkj.entity.CouponDiscountUserRel; +import lombok.Data; + +@Data +public class CouponDiscountUserRelModel extends CouponDiscountUserRel { + + /** + * 优惠券来源 + */ + private Integer source; + +} diff --git a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java index c6ca6b7..71bbe97 100644 --- a/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java +++ b/service/src/main/java/com/hfkj/service/discount/CouponDiscountPackageService.java @@ -111,6 +111,16 @@ public interface CouponDiscountPackageService { void deleteDetail(Integer id); + /** + * @MethodName findDiscountPackageByKey + * @Description: 根据key查询优惠券包 + * @param key + * @return: com.hfkj.entity.CouponDiscountPackage + * @Author: Sum1Dream + * @Date: 2024/12/16 下午5:38 + */ + CouponDiscountPackage findDiscountPackageByKey(String key); + /** * @MethodName giveDiscountPackage * @Description: 赠送优惠券包 diff --git a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java index e5ede3f..1b747eb 100644 --- a/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/discount/impl/CouponDiscountPackageServiceImpl.java @@ -156,6 +156,21 @@ public class CouponDiscountPackageServiceImpl implements CouponDiscountPackageSe couponDiscountPackageDetailsMapper.deleteByPrimaryKey(id); } + + @Override + public CouponDiscountPackage findDiscountPackageByKey(String key) { + CouponDiscountPackageExample example = new CouponDiscountPackageExample(); + CouponDiscountPackageExample.Criteria criteria = example.createCriteria(); + criteria.andKeyEqualTo(key); + + List list = couponDiscountPackageMapper.selectByExample(example); + + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public void giveDiscountPackage(Integer discountPackageId, String phone) { CouponDiscountPackage discountPackage = queryDetail(Long.valueOf(discountPackageId)); diff --git a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java index 24ac6e8..a5dbc1e 100644 --- a/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java +++ b/service/src/main/java/com/hfkj/service/goods/BsOrderGoodsService.java @@ -27,6 +27,7 @@ public interface BsOrderGoodsService { * @return void */ void update(BsOrderGoods orderGoods); + void updateIsNull(BsOrderGoods orderGoods); /** * @Author Sum1Dream diff --git a/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java b/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java new file mode 100644 index 0000000..3a0e3cf --- /dev/null +++ b/service/src/main/java/com/hfkj/service/goods/GoodPresentService.java @@ -0,0 +1,4 @@ +package com.hfkj.service.goods; + +public interface GoodPresentService { +} diff --git a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java index 8b84e5a..dc4be80 100644 --- a/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/goods/impl/BsOrderGoodsServiceImpl.java @@ -53,6 +53,11 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { bsOrderGoodsMapper.updateByPrimaryKeySelective(orderGoods); } + @Override + public void updateIsNull(BsOrderGoods orderGoods) { + bsOrderGoodsMapper.updateByPrimaryKey(orderGoods); + } + @Override public void delete(Long id, Boolean fullDelete) { if (fullDelete) { @@ -312,6 +317,7 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { @Override public void confirmReceipt(Long orderGoodsId) { BsOrderGoods orderGoods = queryDetail(orderGoodsId); + if (orderGoods == null || orderGoods.getStatus() == 1 || orderGoods.getStatus() == 5 || @@ -321,6 +327,9 @@ public class BsOrderGoodsServiceImpl implements BsOrderGoodsService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态,不支持确认收货!"); } + if (orderGoods.getLogisticsNo() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前状态,不支持确认收货!"); + } // 子订单完成 orderService.childOrderComplete(orderGoods.getChildOrderNo()); diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index fde4b28..be1bbf0 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -129,7 +129,11 @@ public class OrderCreateService { orderChild.setBusiness(goodsVpd); if (goodsVpd.getSource().equals(GoodsVpdSourceEnum.type2.getCode())) { yuShang(order , orderChild , goodsVpd , goodsMsg , goodsSpecs , businessObj); - } else if (goodsVpd.getSource().equals(GoodsVpdSourceEnum.type4.getCode()) || goodsVpd.getSource().equals(GoodsVpdSourceEnum.type10.getCode())) { + } else if ( + goodsVpd.getSource().equals(GoodsVpdSourceEnum.type1.getCode()) || + goodsVpd.getSource().equals(GoodsVpdSourceEnum.type3.getCode()) || + goodsVpd.getSource().equals(GoodsVpdSourceEnum.type4.getCode()) || + goodsVpd.getSource().equals(GoodsVpdSourceEnum.type10.getCode())) { couponHlt(order , orderChild , goodsVpd , goodsMsg , goodsSpecs , businessObj); } @@ -219,6 +223,7 @@ public class OrderCreateService { } orderCouponNo.setChannelOrderNo(response.getJSONObject("data").getString("rechargeOrderId")); } + orderCouponNoService.editData(orderCouponNo); } } diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index a9e5107..e0f4fcc 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -9,6 +9,7 @@ import com.hfkj.common.utils.DateUtil; import com.hfkj.common.utils.OrderUtil; import com.hfkj.config.CommonSysConst; import com.hfkj.entity.*; +import com.hfkj.haioil.HaiOilService; import com.hfkj.jd.JdService; import com.hfkj.meituan.MeiTuanService; import com.hfkj.model.order.OrderModel; @@ -17,6 +18,7 @@ import com.hfkj.qianzhu.StarbucksService; import com.hfkj.service.coupon.BsOrderCouponNoService; import com.hfkj.service.coupon.BsOrderCouponService; import com.hfkj.service.coupon.channel.*; +import com.hfkj.service.discount.CouponDiscountPackageService; import com.hfkj.service.goods.*; import com.hfkj.service.goods.impl.BsOrderStarbucksServiceImpl; import com.hfkj.service.hlt.HuiLianTongUnionCardService; @@ -57,14 +59,15 @@ public class OrderPaySuccessService { @Resource private GoodsVpdService goodsVpdService; @Resource - private BsOrderStarbucksService orderStarbucksService; + private CouponDiscountPackageService discountPackageService; @Resource private BsOrderCinemaService bsOrderCinemaService; @Resource private BsOrderStarbucksServiceImpl bsOrderStarbucksService; @Resource private BsOrderMeiTuanService bsOrderMeiTuanService; - + @Resource + private CouponDiscountPackageService couponDiscountPackageService; @Resource private BsOrderMemberService bsOrderMemberService; @Resource @@ -152,8 +155,37 @@ public class OrderPaySuccessService { List couponNoList = orderCouponNoService.getListByCouponOrderId(orderCoupon.getId()); for (BsOrderCouponNo couponNo : couponNoList) { try { + if (vpd.getSource() == GoodsVpdSourceEnum.type1.getCode()) { + // 查询优惠券包 + CouponDiscountPackage couponDiscountPackage = discountPackageService.findDiscountPackageByKey(vpd.getKey()); + + if (couponDiscountPackage != null) { + couponDiscountPackageService.giveDiscountPackage(couponDiscountPackage.getId().intValue() , order.getUserPhone()); + couponNo.setExpireTime(couponDiscountPackage.getEffectiveTime()); + couponNo.setDeliverTime(new Date()); + couponNo.setGoodsVpdSourceCouNo(couponDiscountPackage.getKey()); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); + orderCouponNoService.editData(couponNo); + } + + } else if (vpd.getSource() == GoodsVpdSourceEnum.type3.getCode()) { + // 推送给嗨加油 + Map map = new HashMap<>(); + map.put("discountPkNo" , vpd.getKey()); + map.put("number" , 1); + map.put("phone" , order.getUserPhone()); + JSONObject returnParam = HaiOilService.pushPk(map); + + if (returnParam.getString("return_code").equals("000000")) { + JSONArray dataArray = returnParam.getJSONObject("return_data").getJSONArray("codeList"); + couponNo.setExpireTime(dataArray.getJSONObject(0).getDate("expirationDate")); + couponNo.setDeliverTime(new Date()); + couponNo.setGoodsVpdSourceCouNo(vpd.getKey()); + couponNo.setStatus(OrderCouponNoStatusEnum.status2.getCode()); + orderCouponNoService.editData(couponNo); + } - if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { + }else if (vpd.getSource() == GoodsVpdSourceEnum.type4.getCode()) { // 推送给汇联通 JSONObject returnParam = HuiLianTongCouponService.costRechargeOrder(couponNo.getChannelOrderNo()); if (returnParam.getString("respCode").equals("0000")) { diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java index 606c964..f6ce496 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderAfterSalesApplyServiceImpl.java @@ -15,10 +15,7 @@ import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsMsgService; import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.order.*; -import com.hfkj.sysenum.order.OrderAfterSalesApplyStatusEnum; -import com.hfkj.sysenum.order.OrderAfterSalesApplyTypeEnum; -import com.hfkj.sysenum.order.OrderChildStatusEnum; -import com.hfkj.sysenum.order.OrderRefundStatusEnum; +import com.hfkj.sysenum.order.*; import com.jd.open.api.sdk.response.vopsh.VopAfsCreateAfsApplyResponse; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -62,6 +59,7 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply private GoodsMsgService goodsMsgService; @Resource private BsOrderAfterSalesAddressRecordService afterSalesAddressRecordService; + @Override public void editData(BsOrderAfterSalesApply data) { data.setUpdateTime(new Date()); @@ -85,6 +83,7 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply && !orderChild.getStatus().equals(OrderChildStatusEnum.status3.getCode()) ) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误,无法提交"); } + // 查询订单 BsOrder order = orderService.getOrder(orderChild.getOrderNo()); if (order == null) { @@ -132,6 +131,16 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply } editData(apply); + // 实物商品状态修改为售后中 + if (orderChild.getProductType().equals(OrderChildProductTypeEnum.type1.getCode())) { + BsOrderGoods goods = bsOrderGoodsService.findGoodsOrderByChild(orderChild.getChildOrderNo()); + goods.setStatus(6); + goods.setLogisticsStatus("售后中"); + goods.setLogisticsStatusDesc("售后中"); + goods.setUpdateTime(new Date()); + bsOrderGoodsService.update(goods); + } + // 操作记录 BsOrderAfterSalesOpRecord opRecord = new BsOrderAfterSalesOpRecord(); opRecord.setApplyNo(apply.getApplyNo()); @@ -184,6 +193,15 @@ public class BsOrderAfterSalesApplyServiceImpl implements BsOrderAfterSalesApply } else { apply.setStatus(OrderAfterSalesApplyStatusEnum.type2.getCode()); + BsOrderGoods bsOrderGoods = bsOrderGoodsService.findGoodsOrderByChild(apply.getChildOrderNo()); + if (bsOrderGoods != null) { + + bsOrderGoods.setStatus(2); + bsOrderGoods.setLogisticsStatus(null); + bsOrderGoods.setLogisticsStatusDesc(null); + bsOrderGoods.setUpdateTime(new Date()); + bsOrderGoodsService.updateIsNull(bsOrderGoods); + } } // 操作记录 diff --git a/service/src/main/java/com/hfkj/sysenum/GoodsVpdSourceEnum.java b/service/src/main/java/com/hfkj/sysenum/GoodsVpdSourceEnum.java index 710c05b..ab4184b 100644 --- a/service/src/main/java/com/hfkj/sysenum/GoodsVpdSourceEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/GoodsVpdSourceEnum.java @@ -9,13 +9,17 @@ package com.hfkj.sysenum; public enum GoodsVpdSourceEnum { /** - * 内部虚拟商品 + * 内部优惠券包 */ - type1(1, "内部虚拟商品"), + type1(1, "内部优惠券包"), /** * 娱尚虚拟商品 */ type2(2, "娱尚虚拟商品"), + /** + * 娱尚虚拟商品 + */ + type3(3, "嗨加油优惠券包"), /** * 贵州中石化 */