From 1c6d1f3cc605260ad69402a3b9a1c9ddd315e763 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 23 May 2024 14:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/order/config/AuthConfig.java | 1 + .../controller/notify/CqNotifyController.java | 100 ++++++++++++++ .../com/hfkj/schedule/CouponSchedule.java | 97 +++++++++++++ .../com/hfkj/dao/BsOrderCouponNoMapper.java | 18 ++- .../hfkj/dao/BsOrderCouponNoSqlProvider.java | 28 ++++ .../java/com/hfkj/entity/BsOrderCouponNo.java | 36 ++++- .../hfkj/entity/BsOrderCouponNoExample.java | 130 ++++++++++++++++++ .../coupon/BsOrderCouponNoService.java | 15 ++ .../service/coupon/BsOrderCouponService.java | 7 + .../impl/BsOrderCouponNoServiceImpl.java | 35 +++++ .../coupon/impl/BsOrderCouponServiceImpl.java | 5 + .../service/order/BsOrderChildService.java | 7 + .../hfkj/service/order/BsOrderService.java | 6 + .../service/order/OrderCreateService.java | 2 + .../service/order/OrderPaySuccessService.java | 4 + .../order/impl/BsOrderChildServiceImpl.java | 8 ++ .../order/impl/BsOrderServiceImpl.java | 25 ++++ 17 files changed, 517 insertions(+), 7 deletions(-) create mode 100644 order/src/main/java/com/order/controller/notify/CqNotifyController.java create mode 100644 schedule/src/main/java/com/hfkj/schedule/CouponSchedule.java diff --git a/order/src/main/java/com/order/config/AuthConfig.java b/order/src/main/java/com/order/config/AuthConfig.java index 89c52ea..8c71d98 100644 --- a/order/src/main/java/com/order/config/AuthConfig.java +++ b/order/src/main/java/com/order/config/AuthConfig.java @@ -87,6 +87,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/**/springfox-swagger-ui/**") .excludePathPatterns("/**/swagger-ui.html") .excludePathPatterns("/notify/*") + .excludePathPatterns("/cqNotify/*") ; } diff --git a/order/src/main/java/com/order/controller/notify/CqNotifyController.java b/order/src/main/java/com/order/controller/notify/CqNotifyController.java new file mode 100644 index 0000000..5b8b0b6 --- /dev/null +++ b/order/src/main/java/com/order/controller/notify/CqNotifyController.java @@ -0,0 +1,100 @@ +package com.order.controller.notify; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.utils.AESTool; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.MD5Util; +import com.hfkj.config.CommonSysConst; +import com.hfkj.entity.BsOrderCoupon; +import com.hfkj.entity.BsOrderCouponNo; +import com.hfkj.service.coupon.BsOrderCouponNoService; +import com.hfkj.service.coupon.channel.ChongQingCNPCCouponService; +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.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/cqNotify") +@Api(value = "重庆业务通知") +public class CqNotifyController { + + private static final Logger log = LoggerFactory.getLogger(CqNotifyController.class); + + @Resource + private BsOrderCouponNoService orderCouponNoService; + + @RequestMapping(value = "/cqCnpcNotify", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "重庆中石油通知") + public Object cqCnpcNotify(@RequestBody String paramsStr) { + System.out.println(paramsStr); + log.info("重庆中石油核销通知"); + log.info("通知参数:" + paramsStr); + try { + if (StringUtils.isNotBlank(paramsStr)) { + + JSONObject sendMessage = JSONObject.parseObject(paramsStr).getJSONObject("sendMessage"); + JSONObject body = ChongQingCNPCCouponService.decryptBody(sendMessage.getString("body")); + + // 查询卡密 + BsOrderCouponNo coupon = orderCouponNoService.getDetailByCouNo(body.getString("couponNo")); + if (coupon != null) { + coupon.setFinishTime(DateUtil.format(body.getString("useTime"), "yyyyMMddHHmmss")); + coupon.setStatus(40); + orderCouponNoService.editData(coupon); + } + + Map param = new HashMap<>(); + param.put("status", 1); + param.put("msg", "成功"); + String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); + + Map returnContent = new HashMap<>(); + Map returnPostMessage = new HashMap<>(); + + Map returnHead = new HashMap<>(); + returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); + returnHead.put("requestType", "couponNotice"); + returnPostMessage.put("head", returnHead); + + returnPostMessage.put("body", verifyCode); + returnContent.put("postMessage", returnPostMessage); + return returnContent; + } else { + Map param = new HashMap<>(); + param.put("status", 0); + param.put("msg", "解析参数错误"); + String verifyCode = AESTool.Encrypt(JSONObject.toJSONString(param), CommonSysConst.getSysConfig().getChongQingCnpcMerKey()); + + Map returnContent = new HashMap<>(); + Map returnPostMessage = new HashMap<>(); + + Map returnHead = new HashMap<>(); + returnHead.put("verifyCode", MD5Util.encode((verifyCode + CommonSysConst.getSysConfig().getChongQingCnpcMerKey()).getBytes()).toLowerCase()); + returnHead.put("requestType", "couponNotice"); + returnPostMessage.put("head", returnHead); + + returnPostMessage.put("body", verifyCode); + returnContent.put("postMessage", returnPostMessage); + return returnContent; + } + } catch (Exception e) { + log.info("重庆中石油核销通知业务出现异常", e); + return null; + // return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/schedule/src/main/java/com/hfkj/schedule/CouponSchedule.java b/schedule/src/main/java/com/hfkj/schedule/CouponSchedule.java new file mode 100644 index 0000000..2d38d72 --- /dev/null +++ b/schedule/src/main/java/com/hfkj/schedule/CouponSchedule.java @@ -0,0 +1,97 @@ +package com.hfkj.schedule; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.entity.BsOrderCoupon; +import com.hfkj.entity.BsOrderCouponNo; +import com.hfkj.service.coupon.BsOrderCouponNoService; +import com.hfkj.service.coupon.BsOrderCouponService; +import com.hfkj.service.coupon.channel.HuiLianTongCouponService; +import com.hfkj.service.coupon.channel.PetroConfig; +import com.hfkj.service.hlt.HuiLianTongUnionCardService; +import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.service.order.BsOrderService; +import com.hfkj.sysenum.GoodsVpdSourceEnum; +import com.hfkj.sysenum.order.OrderCouponNoStatusEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @Auther: 胡锐 + * @Description: 卡卷定时任务 + * @Date: 2021/3/27 15:39 + */ +@Configuration +public class CouponSchedule { + + private static Logger log = LoggerFactory.getLogger(CouponSchedule.class); + + @Resource + private BsOrderChildService orderChildService; + @Resource + private BsOrderService orderService; + @Resource + BsOrderCouponService orderCouponService; + @Resource + private BsOrderCouponNoService orderCouponNoService; + + //每日凌晨12点5秒执行一次 + @Scheduled(cron = "5 0 0 * * ?") + public void expiredCoupon() { + Map param = new HashMap<>(); + param.put("status", OrderCouponNoStatusEnum.status2.getCode()); + param.put("expireStatus", false); + param.put("exceptionStatus", false); + // 查询卡密 + List list = orderCouponNoService.getList(param); + for (BsOrderCouponNo coupon : list) { + try { + if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type4.getCode())) { + // 渠道查询 + JSONObject jsonObject = HuiLianTongCouponService.getPayOrderByCouNo(coupon.getGoodsVpdSourceCouNo()); + if (jsonObject.getString("respCode").equals("0000")) { + // 解析数据 + JSONObject data = HuiLianTongUnionCardService.resolveResponse(jsonObject.getString("data")); + if (data.getString("respCode").equals("0000")) { + JSONObject responseObject = JSONObject.parseObject(data.getString("data")); + if (responseObject.getInteger("state") == 40) { + coupon.setStatus(OrderCouponNoStatusEnum.status3.getCode()); + coupon.setFinishTime(new Date()); + orderCouponNoService.editData(coupon); + } + } + } + + } else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type5.getCode())) { + + } else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type7.getCode())) { + + } else if (coupon.getGoodsVpdSource().equals(GoodsVpdSourceEnum.type10.getCode())) { + // 查询卡券订单 + BsOrderCoupon orderCoupon = orderCouponService.getDetail(coupon.getCouponOrderId()); + if (orderCoupon != null) { + JSONObject jsonObject = PetroConfig.couponDetail(coupon.getGoodsVpdSourceCouNo(), orderCoupon.getUserPhone()); + if (jsonObject.getString("resultCode").equals("0000")) { + String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); + JSONObject jsonData = JSONObject.parseObject(data); + if (jsonData.getInteger("state") == 40) { + coupon.setStatus(OrderCouponNoStatusEnum.status3.getCode()); + coupon.setFinishTime(jsonData.getDate("usedTime")); + orderCouponNoService.editData(coupon); + } + } + } + } + } catch (Exception e) { + + } + } + } +} diff --git a/service/src/main/java/com/hfkj/dao/BsOrderCouponNoMapper.java b/service/src/main/java/com/hfkj/dao/BsOrderCouponNoMapper.java index 60ea76c..7cd646a 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderCouponNoMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderCouponNoMapper.java @@ -40,14 +40,16 @@ public interface BsOrderCouponNoMapper extends BsOrderCouponNoMapperExt { @Insert({ "insert into bs_order_coupon_no (coupon_order_id, order_no, ", - "channel_order_no, goods_vpd_source_cou_no, ", + "channel_order_no, goods_vpd_source, ", + "goods_vpd_key, goods_vpd_source_cou_no, ", "expire_status, expire_time, ", "`status`, exception_status, ", "create_time, deliver_time, ", "finish_time, update_time, ", "ext_1, ext_2, ext_3)", "values (#{couponOrderId,jdbcType=BIGINT}, #{orderNo,jdbcType=VARCHAR}, ", - "#{channelOrderNo,jdbcType=VARCHAR}, #{goodsVpdSourceCouNo,jdbcType=VARCHAR}, ", + "#{channelOrderNo,jdbcType=VARCHAR}, #{goodsVpdSource,jdbcType=INTEGER}, ", + "#{goodsVpdKey,jdbcType=VARCHAR}, #{goodsVpdSourceCouNo,jdbcType=VARCHAR}, ", "#{expireStatus,jdbcType=BIT}, #{expireTime,jdbcType=TIMESTAMP}, ", "#{status,jdbcType=INTEGER}, #{exceptionStatus,jdbcType=BIT}, ", "#{createTime,jdbcType=TIMESTAMP}, #{deliverTime,jdbcType=TIMESTAMP}, ", @@ -67,6 +69,8 @@ public interface BsOrderCouponNoMapper extends BsOrderCouponNoMapperExt { @Result(column="coupon_order_id", property="couponOrderId", jdbcType=JdbcType.BIGINT), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="channel_order_no", property="channelOrderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="goods_vpd_source", property="goodsVpdSource", jdbcType=JdbcType.INTEGER), + @Result(column="goods_vpd_key", property="goodsVpdKey", jdbcType=JdbcType.VARCHAR), @Result(column="goods_vpd_source_cou_no", property="goodsVpdSourceCouNo", jdbcType=JdbcType.VARCHAR), @Result(column="expire_status", property="expireStatus", jdbcType=JdbcType.BIT), @Result(column="expire_time", property="expireTime", jdbcType=JdbcType.TIMESTAMP), @@ -84,9 +88,9 @@ public interface BsOrderCouponNoMapper extends BsOrderCouponNoMapperExt { @Select({ "select", - "id, coupon_order_id, order_no, channel_order_no, goods_vpd_source_cou_no, expire_status, ", - "expire_time, `status`, exception_status, create_time, deliver_time, finish_time, ", - "update_time, ext_1, ext_2, ext_3", + "id, coupon_order_id, order_no, channel_order_no, goods_vpd_source, goods_vpd_key, ", + "goods_vpd_source_cou_no, expire_status, expire_time, `status`, exception_status, ", + "create_time, deliver_time, finish_time, update_time, ext_1, ext_2, ext_3", "from bs_order_coupon_no", "where id = #{id,jdbcType=BIGINT}" }) @@ -95,6 +99,8 @@ public interface BsOrderCouponNoMapper extends BsOrderCouponNoMapperExt { @Result(column="coupon_order_id", property="couponOrderId", jdbcType=JdbcType.BIGINT), @Result(column="order_no", property="orderNo", jdbcType=JdbcType.VARCHAR), @Result(column="channel_order_no", property="channelOrderNo", jdbcType=JdbcType.VARCHAR), + @Result(column="goods_vpd_source", property="goodsVpdSource", jdbcType=JdbcType.INTEGER), + @Result(column="goods_vpd_key", property="goodsVpdKey", jdbcType=JdbcType.VARCHAR), @Result(column="goods_vpd_source_cou_no", property="goodsVpdSourceCouNo", jdbcType=JdbcType.VARCHAR), @Result(column="expire_status", property="expireStatus", jdbcType=JdbcType.BIT), @Result(column="expire_time", property="expireTime", jdbcType=JdbcType.TIMESTAMP), @@ -124,6 +130,8 @@ public interface BsOrderCouponNoMapper extends BsOrderCouponNoMapperExt { "set coupon_order_id = #{couponOrderId,jdbcType=BIGINT},", "order_no = #{orderNo,jdbcType=VARCHAR},", "channel_order_no = #{channelOrderNo,jdbcType=VARCHAR},", + "goods_vpd_source = #{goodsVpdSource,jdbcType=INTEGER},", + "goods_vpd_key = #{goodsVpdKey,jdbcType=VARCHAR},", "goods_vpd_source_cou_no = #{goodsVpdSourceCouNo,jdbcType=VARCHAR},", "expire_status = #{expireStatus,jdbcType=BIT},", "expire_time = #{expireTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/BsOrderCouponNoSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsOrderCouponNoSqlProvider.java index 4010770..69f9b48 100644 --- a/service/src/main/java/com/hfkj/dao/BsOrderCouponNoSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsOrderCouponNoSqlProvider.java @@ -40,6 +40,14 @@ public class BsOrderCouponNoSqlProvider { sql.VALUES("channel_order_no", "#{channelOrderNo,jdbcType=VARCHAR}"); } + if (record.getGoodsVpdSource() != null) { + sql.VALUES("goods_vpd_source", "#{goodsVpdSource,jdbcType=INTEGER}"); + } + + if (record.getGoodsVpdKey() != null) { + sql.VALUES("goods_vpd_key", "#{goodsVpdKey,jdbcType=VARCHAR}"); + } + if (record.getGoodsVpdSourceCouNo() != null) { sql.VALUES("goods_vpd_source_cou_no", "#{goodsVpdSourceCouNo,jdbcType=VARCHAR}"); } @@ -101,6 +109,8 @@ public class BsOrderCouponNoSqlProvider { sql.SELECT("coupon_order_id"); sql.SELECT("order_no"); sql.SELECT("channel_order_no"); + sql.SELECT("goods_vpd_source"); + sql.SELECT("goods_vpd_key"); sql.SELECT("goods_vpd_source_cou_no"); sql.SELECT("expire_status"); sql.SELECT("expire_time"); @@ -146,6 +156,14 @@ public class BsOrderCouponNoSqlProvider { sql.SET("channel_order_no = #{record.channelOrderNo,jdbcType=VARCHAR}"); } + if (record.getGoodsVpdSource() != null) { + sql.SET("goods_vpd_source = #{record.goodsVpdSource,jdbcType=INTEGER}"); + } + + if (record.getGoodsVpdKey() != null) { + sql.SET("goods_vpd_key = #{record.goodsVpdKey,jdbcType=VARCHAR}"); + } + if (record.getGoodsVpdSourceCouNo() != null) { sql.SET("goods_vpd_source_cou_no = #{record.goodsVpdSourceCouNo,jdbcType=VARCHAR}"); } @@ -206,6 +224,8 @@ public class BsOrderCouponNoSqlProvider { sql.SET("coupon_order_id = #{record.couponOrderId,jdbcType=BIGINT}"); sql.SET("order_no = #{record.orderNo,jdbcType=VARCHAR}"); sql.SET("channel_order_no = #{record.channelOrderNo,jdbcType=VARCHAR}"); + sql.SET("goods_vpd_source = #{record.goodsVpdSource,jdbcType=INTEGER}"); + sql.SET("goods_vpd_key = #{record.goodsVpdKey,jdbcType=VARCHAR}"); sql.SET("goods_vpd_source_cou_no = #{record.goodsVpdSourceCouNo,jdbcType=VARCHAR}"); sql.SET("expire_status = #{record.expireStatus,jdbcType=BIT}"); sql.SET("expire_time = #{record.expireTime,jdbcType=TIMESTAMP}"); @@ -240,6 +260,14 @@ public class BsOrderCouponNoSqlProvider { sql.SET("channel_order_no = #{channelOrderNo,jdbcType=VARCHAR}"); } + if (record.getGoodsVpdSource() != null) { + sql.SET("goods_vpd_source = #{goodsVpdSource,jdbcType=INTEGER}"); + } + + if (record.getGoodsVpdKey() != null) { + sql.SET("goods_vpd_key = #{goodsVpdKey,jdbcType=VARCHAR}"); + } + if (record.getGoodsVpdSourceCouNo() != null) { sql.SET("goods_vpd_source_cou_no = #{goodsVpdSourceCouNo,jdbcType=VARCHAR}"); } diff --git a/service/src/main/java/com/hfkj/entity/BsOrderCouponNo.java b/service/src/main/java/com/hfkj/entity/BsOrderCouponNo.java index f60e0f8..841d367 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderCouponNo.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderCouponNo.java @@ -33,6 +33,16 @@ public class BsOrderCouponNo implements Serializable { */ private String channelOrderNo; + /** + * 商品虚拟来源 + */ + private Integer goodsVpdSource; + + /** + * 商品虚拟key + */ + private String goodsVpdKey; + /** * 商品虚拟来源卡券编号 */ @@ -49,12 +59,12 @@ public class BsOrderCouponNo implements Serializable { private Date expireTime; /** - * 状态 1:未派发 2:已派发 3:已使用 4:已过期 + * 状态 1:未派发 2:已派发 3:已使用 4:已过期 5:已退款 */ private Integer status; /** - * 异常状态 0:异常 1:正常 + * 异常状态 0:正常 1:异常 */ private Boolean exceptionStatus; @@ -118,6 +128,22 @@ public class BsOrderCouponNo implements Serializable { this.channelOrderNo = channelOrderNo; } + public Integer getGoodsVpdSource() { + return goodsVpdSource; + } + + public void setGoodsVpdSource(Integer goodsVpdSource) { + this.goodsVpdSource = goodsVpdSource; + } + + public String getGoodsVpdKey() { + return goodsVpdKey; + } + + public void setGoodsVpdKey(String goodsVpdKey) { + this.goodsVpdKey = goodsVpdKey; + } + public String getGoodsVpdSourceCouNo() { return goodsVpdSourceCouNo; } @@ -230,6 +256,8 @@ public class BsOrderCouponNo implements Serializable { && (this.getCouponOrderId() == null ? other.getCouponOrderId() == null : this.getCouponOrderId().equals(other.getCouponOrderId())) && (this.getOrderNo() == null ? other.getOrderNo() == null : this.getOrderNo().equals(other.getOrderNo())) && (this.getChannelOrderNo() == null ? other.getChannelOrderNo() == null : this.getChannelOrderNo().equals(other.getChannelOrderNo())) + && (this.getGoodsVpdSource() == null ? other.getGoodsVpdSource() == null : this.getGoodsVpdSource().equals(other.getGoodsVpdSource())) + && (this.getGoodsVpdKey() == null ? other.getGoodsVpdKey() == null : this.getGoodsVpdKey().equals(other.getGoodsVpdKey())) && (this.getGoodsVpdSourceCouNo() == null ? other.getGoodsVpdSourceCouNo() == null : this.getGoodsVpdSourceCouNo().equals(other.getGoodsVpdSourceCouNo())) && (this.getExpireStatus() == null ? other.getExpireStatus() == null : this.getExpireStatus().equals(other.getExpireStatus())) && (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime())) @@ -252,6 +280,8 @@ public class BsOrderCouponNo implements Serializable { result = prime * result + ((getCouponOrderId() == null) ? 0 : getCouponOrderId().hashCode()); result = prime * result + ((getOrderNo() == null) ? 0 : getOrderNo().hashCode()); result = prime * result + ((getChannelOrderNo() == null) ? 0 : getChannelOrderNo().hashCode()); + result = prime * result + ((getGoodsVpdSource() == null) ? 0 : getGoodsVpdSource().hashCode()); + result = prime * result + ((getGoodsVpdKey() == null) ? 0 : getGoodsVpdKey().hashCode()); result = prime * result + ((getGoodsVpdSourceCouNo() == null) ? 0 : getGoodsVpdSourceCouNo().hashCode()); result = prime * result + ((getExpireStatus() == null) ? 0 : getExpireStatus().hashCode()); result = prime * result + ((getExpireTime() == null) ? 0 : getExpireTime().hashCode()); @@ -277,6 +307,8 @@ public class BsOrderCouponNo implements Serializable { sb.append(", couponOrderId=").append(couponOrderId); sb.append(", orderNo=").append(orderNo); sb.append(", channelOrderNo=").append(channelOrderNo); + sb.append(", goodsVpdSource=").append(goodsVpdSource); + sb.append(", goodsVpdKey=").append(goodsVpdKey); sb.append(", goodsVpdSourceCouNo=").append(goodsVpdSourceCouNo); sb.append(", expireStatus=").append(expireStatus); sb.append(", expireTime=").append(expireTime); diff --git a/service/src/main/java/com/hfkj/entity/BsOrderCouponNoExample.java b/service/src/main/java/com/hfkj/entity/BsOrderCouponNoExample.java index 159e7fe..f073eb7 100644 --- a/service/src/main/java/com/hfkj/entity/BsOrderCouponNoExample.java +++ b/service/src/main/java/com/hfkj/entity/BsOrderCouponNoExample.java @@ -385,6 +385,136 @@ public class BsOrderCouponNoExample { return (Criteria) this; } + public Criteria andGoodsVpdSourceIsNull() { + addCriterion("goods_vpd_source is null"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceIsNotNull() { + addCriterion("goods_vpd_source is not null"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceEqualTo(Integer value) { + addCriterion("goods_vpd_source =", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceNotEqualTo(Integer value) { + addCriterion("goods_vpd_source <>", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceGreaterThan(Integer value) { + addCriterion("goods_vpd_source >", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceGreaterThanOrEqualTo(Integer value) { + addCriterion("goods_vpd_source >=", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceLessThan(Integer value) { + addCriterion("goods_vpd_source <", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceLessThanOrEqualTo(Integer value) { + addCriterion("goods_vpd_source <=", value, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceIn(List values) { + addCriterion("goods_vpd_source in", values, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceNotIn(List values) { + addCriterion("goods_vpd_source not in", values, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceBetween(Integer value1, Integer value2) { + addCriterion("goods_vpd_source between", value1, value2, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdSourceNotBetween(Integer value1, Integer value2) { + addCriterion("goods_vpd_source not between", value1, value2, "goodsVpdSource"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyIsNull() { + addCriterion("goods_vpd_key is null"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyIsNotNull() { + addCriterion("goods_vpd_key is not null"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyEqualTo(String value) { + addCriterion("goods_vpd_key =", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyNotEqualTo(String value) { + addCriterion("goods_vpd_key <>", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyGreaterThan(String value) { + addCriterion("goods_vpd_key >", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyGreaterThanOrEqualTo(String value) { + addCriterion("goods_vpd_key >=", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyLessThan(String value) { + addCriterion("goods_vpd_key <", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyLessThanOrEqualTo(String value) { + addCriterion("goods_vpd_key <=", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyLike(String value) { + addCriterion("goods_vpd_key like", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyNotLike(String value) { + addCriterion("goods_vpd_key not like", value, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyIn(List values) { + addCriterion("goods_vpd_key in", values, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyNotIn(List values) { + addCriterion("goods_vpd_key not in", values, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyBetween(String value1, String value2) { + addCriterion("goods_vpd_key between", value1, value2, "goodsVpdKey"); + return (Criteria) this; + } + + public Criteria andGoodsVpdKeyNotBetween(String value1, String value2) { + addCriterion("goods_vpd_key not between", value1, value2, "goodsVpdKey"); + return (Criteria) this; + } + public Criteria andGoodsVpdSourceCouNoIsNull() { addCriterion("goods_vpd_source_cou_no is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java index 03c0741..26de9b3 100644 --- a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java +++ b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponNoService.java @@ -3,6 +3,7 @@ package com.hfkj.service.coupon; import com.hfkj.entity.BsOrderCouponNo; import java.util.List; +import java.util.Map; /** * @className: BsOrderCouponNoService @@ -17,6 +18,13 @@ public interface BsOrderCouponNoService { */ void editData(BsOrderCouponNo data); + /** + * 查询详情 + * @param couNo + * @return + */ + BsOrderCouponNo getDetailByCouNo(String couNo); + /** * 查询列表 * @param couponOrderId @@ -24,4 +32,11 @@ public interface BsOrderCouponNoService { */ List getListByCouponOrderId(Long couponOrderId); + /** + * 查询列表 + * @param param + * @return + */ + List getList(Map param); + } diff --git a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java index 9b97cdb..c8d8910 100644 --- a/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java +++ b/service/src/main/java/com/hfkj/service/coupon/BsOrderCouponService.java @@ -27,6 +27,13 @@ public interface BsOrderCouponService { */ BsOrderCoupon getDetailByChildOrderNo(String orderChildNo); + /** + * 查询详情 + * @param id + * @return + */ + BsOrderCoupon getDetail(Long id); + /** * 查询卡券订单 * @param param diff --git a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponNoServiceImpl.java b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponNoServiceImpl.java index a5e1648..0182f93 100644 --- a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponNoServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponNoServiceImpl.java @@ -4,11 +4,13 @@ import com.hfkj.dao.BsOrderCouponNoMapper; import com.hfkj.entity.BsOrderCouponNo; import com.hfkj.entity.BsOrderCouponNoExample; import com.hfkj.service.coupon.BsOrderCouponNoService; +import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; +import java.util.Map; /** * @className: BsOrderCouponNoServiceImpl @@ -30,10 +32,43 @@ public class BsOrderCouponNoServiceImpl implements BsOrderCouponNoService { } } + @Override + public BsOrderCouponNo getDetailByCouNo(String couNo) { + BsOrderCouponNoExample example = new BsOrderCouponNoExample(); + example.createCriteria().andGoodsVpdSourceCouNoEqualTo(couNo); + List list = orderCouponNoMapper.selectByExample(example); + if (!list.isEmpty()) { + return list.get(0); + } + return null; + } + @Override public List getListByCouponOrderId(Long couponOrderId) { BsOrderCouponNoExample example = new BsOrderCouponNoExample(); example.createCriteria().andCouponOrderIdEqualTo(couponOrderId); + example.setOrderByClause("create_time desc"); + return orderCouponNoMapper.selectByExample(example); + } + + @Override + public List getList(Map param) { + BsOrderCouponNoExample example = new BsOrderCouponNoExample(); + BsOrderCouponNoExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(param, "status") != null) { + criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); + } + + if (MapUtils.getBoolean(param, "expireStatus") != null) { + criteria.andExpireStatusEqualTo(MapUtils.getBoolean(param, "expireStatus")); + } + + if (MapUtils.getBoolean(param, "exceptionStatus") != null) { + criteria.andExceptionStatusEqualTo(MapUtils.getBoolean(param, "exceptionStatus")); + } + + example.setOrderByClause("create_time desc"); return orderCouponNoMapper.selectByExample(example); } } diff --git a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java index 5d83914..10215ae 100644 --- a/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/coupon/impl/BsOrderCouponServiceImpl.java @@ -47,6 +47,11 @@ public class BsOrderCouponServiceImpl implements BsOrderCouponService { return null; } + @Override + public BsOrderCoupon getDetail(Long id) { + return orderCouponMapper.selectByPrimaryKey(id); + } + @Override public List getOrderList(Map param) { if (MapUtils.getLong(param, "createTimeS") != null) { diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderChildService.java b/service/src/main/java/com/hfkj/service/order/BsOrderChildService.java index 54619c0..c075951 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderChildService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderChildService.java @@ -33,4 +33,11 @@ public interface BsOrderChildService { */ List getOrderChildListByOrderNo(String orderNo); + /** + * 获取未完成的子订单数量 + * @param orderNo + * @return + */ + long getUndoneChildOrder(String orderNo); + } diff --git a/service/src/main/java/com/hfkj/service/order/BsOrderService.java b/service/src/main/java/com/hfkj/service/order/BsOrderService.java index f4082de..d6d7954 100644 --- a/service/src/main/java/com/hfkj/service/order/BsOrderService.java +++ b/service/src/main/java/com/hfkj/service/order/BsOrderService.java @@ -49,6 +49,12 @@ public interface BsOrderService { */ OrderModel cancel(String orderNo, boolean system); + /** + * 子订单完成 + * @param childOrderNo + */ + void childOrderComplete(String childOrderNo); + /** * 支付成功业务 * @param order 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 9ecae65..eae3357 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -117,6 +117,8 @@ public class OrderCreateService { BsOrderCouponNo orderCouponNo = new BsOrderCouponNo(); orderCouponNo.setCouponOrderId(orderCoupon.getId()); orderCouponNo.setOrderNo(orderCoupon.getId() + RandomUtils.number(6, false)); + orderCouponNo.setGoodsVpdKey(orderCoupon.getGoodsVpdKey()); + orderCouponNo.setGoodsVpdSource(orderCoupon.getGoodsVpdSource()); orderCouponNo.setExpireStatus(false); orderCouponNo.setExceptionStatus(false); orderCouponNo.setStatus(OrderCouponNoStatusEnum.status1.getCode()); 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 b62f544..80ffda1 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -40,6 +40,8 @@ import java.util.List; public class OrderPaySuccessService { Logger log = LoggerFactory.getLogger(OrderPaySuccessService.class); @Resource + private BsOrderService orderService; + @Resource private BsOrderGoodsService bsOrderGoodsService; @Resource private BsOrderCouponService orderCouponService; @@ -179,6 +181,8 @@ public class OrderPaySuccessService { couponNo.setGoodsVpdSourceCouNo(object.getString("couponCode")); orderCouponNoService.editData(couponNo); } + + } catch (Exception e) { couponNo.setExceptionStatus(true); orderCouponService.editData(orderCoupon); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java index 385074b..4be4581 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderChildServiceImpl.java @@ -11,6 +11,7 @@ import com.hfkj.model.order.OrderChildModel; import com.hfkj.service.goods.BsOrderGoodsService; import com.hfkj.service.goods.GoodsUserAddressService; import com.hfkj.service.order.BsOrderChildService; +import com.hfkj.sysenum.order.OrderChildStatusEnum; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -88,4 +89,11 @@ public class BsOrderChildServiceImpl implements BsOrderChildService { } return orderChildModelList; } + + @Override + public long getUndoneChildOrder(String orderNo) { + BsOrderChildExample example = new BsOrderChildExample(); + example.createCriteria().andOrderNoEqualTo(orderNo).andStatusNotEqualTo(OrderChildStatusEnum.status3.getCode()); + return orderChildMapper.countByExample(example); + } } diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index 676a197..e319291 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -379,6 +379,31 @@ public class BsOrderServiceImpl implements BsOrderService { return order; } + @Override + public void childOrderComplete(String childOrderNo) { + BsOrderChild orderChild = orderChildService.getDetail(childOrderNo); + if (orderChild == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 删除缓存 + cacheDelete(orderChild.getOrderNo()); + + orderChild.setFinishTime(new Date()); + orderChild.setStatus(OrderChildStatusEnum.status3.getCode()); + orderChildService.editData(orderChild); + + // 查询未完成的子订单数量 + long count = orderChildService.getUndoneChildOrder(orderChild.getOrderNo()); + if (count == 0) { + BsOrder order = getOrder(orderChild.getOrderNo()); + if (order != null) { + order.setOrderStatus(OrderStatusEnum.status3.getCode()); + order.setFinishTime(new Date()); + editData(order); + } + } + } + @Override public void orderPaySuccessHandle(OrderModel order) { order.setPayTime(order.getPayTime()==null?new Date():order.getPayTime());