diff --git a/hai-order/src/main/java/com/web/controller/OrderBWebController.java b/hai-order/src/main/java/com/web/controller/OrderBWebController.java index c290a9ed..d3851a9e 100644 --- a/hai-order/src/main/java/com/web/controller/OrderBWebController.java +++ b/hai-order/src/main/java/com/web/controller/OrderBWebController.java @@ -102,6 +102,23 @@ public class OrderBWebController { } } + @RequestMapping(value="/getCouponOrderDetail",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询卡券订单详情") + public ResponseData getCouponOrderDetail(@RequestParam(name = "orderNo", required = false) String orderNo) { + try { + + Map param = new HashMap<>(); + param.put("order", orderService.getOrderDetailByNo(orderNo)); + + return ResponseMsgUtil.success(param); + + } catch (Exception e) { + log.error("OrderExtController -> getCouponOrderDetail() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getGasOrderList",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询油站订单列表") diff --git a/hai-order/src/main/java/com/web/controller/TestController.java b/hai-order/src/main/java/com/web/controller/TestController.java index 20db0f9b..26f9fbf9 100644 --- a/hai-order/src/main/java/com/web/controller/TestController.java +++ b/hai-order/src/main/java/com/web/controller/TestController.java @@ -1 +1 @@ -package com.web.controller; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.*; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderService; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.integration.support.MessageBuilder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private RocketMQTemplate rocketMQTemplate; @Resource private OrderService orderService; @Resource private RedisUtil redisUtil; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value = "/q", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData q() { try { JSONObject order = HuiLianTongConfig.getPayOrderByCouNo("3D3F3D3D3F373F36373836373D3F3A37383C3F"); if (order != null){ return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(order.getString("data"))); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rocketMq", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup, @RequestParam(name = "body", required = true) String body) { try { long startTime = System.currentTimeMillis(); // org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); CreateOrderModel createOrder = new CreateOrderModel(); //发送对象消息 HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class); System.out.println("订单号:" + order.getOrderNo()); // SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000); /*List list = new LinkedList<>(); for (int i = 0; i <= 100;i++) { list.add(orderService.getDetailByOrderNo("HF2022080918014365701")); *//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//* *//* updateUserWithRedisLock("coupon_" + couponKey, i+""); new Thread(() -> {*//* *//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i); System.out.println("加入数据" + i);*//* // redisTemplate.delete("coupon" + couponKey); // System.out.println("释放数据" + index); *//* });*//* }*/ System.out.println(System.currentTimeMillis() - startTime); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException { // 占分布式锁,去redis占坑 // 1. 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value); if(lock) { //加锁成功... // todo business System.out.println("加锁成功: " + value); redisTemplate.delete("coupon" + couponKey); //删除key,释放锁 } else { System.out.println("加锁失败"); /* Thread.sleep(100); // 加锁失败,重试 updateUserWithRedisLock("sysUser");*/ } } } \ No newline at end of file +package com.web.controller; import com.alibaba.fastjson.JSONObject; import com.hai.common.utils.*; import com.hai.config.HuiLianTongConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.entity.HighOrder; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderStatus; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.rocketmq.client.producer.SendCallback; import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.common.message.Message; import org.apache.rocketmq.spring.core.RocketMQTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.integration.support.MessageBuilder; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Date; import java.util.LinkedList; import java.util.List; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class TestController { private static Logger log = LoggerFactory.getLogger(TestController.class); @Autowired private RocketMQTemplate rocketMQTemplate; @Resource private OrderService orderService; @Resource private RedisUtil redisUtil; @Autowired private RedisTemplate redisTemplate; @RequestMapping(value = "/q", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData q(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = orderService.getOrderDetailByNo(orderNo); if (order != null) { orderService.refundOrder(orderNo, DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss")); // order.setRefundTime(new Date()); // orderService.updateOrderData(order); return ResponseMsgUtil.success("修改成功"); } return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rocketMq", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "") public ResponseData rocketMq(@RequestParam(name = "topicGroup", required = true) String topicGroup, @RequestParam(name = "body", required = true) String body) { try { long startTime = System.currentTimeMillis(); // org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build(); CreateOrderModel createOrder = new CreateOrderModel(); //发送对象消息 HighOrder order = rocketMQTemplate.sendAndReceive("order-topic:create", createOrder, HighOrder.class); System.out.println("订单号:" + order.getOrderNo()); // SendResult sendResult = rocketMQTemplate.syncSend("order-topic:create", message, 3000); /*List list = new LinkedList<>(); for (int i = 0; i <= 100;i++) { list.add(orderService.getDetailByOrderNo("HF2022080918014365701")); *//* list.add(orderService.getDetailByOrderNo("HF2022080918014365701"));*//* *//* updateUserWithRedisLock("coupon_" + couponKey, i+""); new Thread(() -> {*//* *//* redisTemplate.opsForValue().setIfAbsent("coupon_" + couponKey, i); System.out.println("加入数据" + i);*//* // redisTemplate.delete("coupon" + couponKey); // System.out.println("释放数据" + index); *//* });*//* }*/ System.out.println(System.currentTimeMillis() - startTime); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighUserCardController --> rocketMq() error!", e); return ResponseMsgUtil.exception(e); } } public void updateUserWithRedisLock(String couponKey, String value) throws InterruptedException { // 占分布式锁,去redis占坑 // 1. 分布式锁占坑 Boolean lock = redisTemplate.opsForValue().setIfAbsent("coupon" + couponKey, value); if(lock) { //加锁成功... // todo business System.out.println("加锁成功: " + value); redisTemplate.delete("coupon" + couponKey); //删除key,释放锁 } else { System.out.println("加锁失败"); /* Thread.sleep(100); // 加锁失败,重试 updateUserWithRedisLock("sysUser");*/ } } } \ No newline at end of file diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java index c56ce369..a648d288 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java @@ -60,11 +60,12 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "gas_salesman_id, gas_salesman_name, ", "gas_agent_id, gas_agent_name, ", "gas_org_id, gas_org_name, ", - "`status`, create_time, ", - "cancel_time, pay_time, ", - "refund_time, refund_remarks, ", - "ext_1, ext_2, ext_3, ", - "ext_4, ext_5, ext_6)", + "pay_type, `status`, ", + "create_time, cancel_time, ", + "pay_time, refund_time, ", + "refund_remarks, ext_1, ", + "ext_2, ext_3, ext_4, ", + "ext_5, ext_6)", "values (#{orderNo,jdbcType=VARCHAR}, #{childOrderNo,jdbcType=VARCHAR}, ", "#{channelType,jdbcType=INTEGER}, #{channelOrderNo,jdbcType=VARCHAR}, ", "#{memId,jdbcType=BIGINT}, #{memPhone,jdbcType=VARCHAR}, ", @@ -86,11 +87,12 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "#{gasSalesmanId,jdbcType=BIGINT}, #{gasSalesmanName,jdbcType=VARCHAR}, ", "#{gasAgentId,jdbcType=BIGINT}, #{gasAgentName,jdbcType=VARCHAR}, ", "#{gasOrgId,jdbcType=BIGINT}, #{gasOrgName,jdbcType=VARCHAR}, ", - "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{cancelTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, ", - "#{refundTime,jdbcType=TIMESTAMP}, #{refundRemarks,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", - "#{ext4,jdbcType=VARCHAR}, #{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" + "#{payType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ", + "#{payTime,jdbcType=TIMESTAMP}, #{refundTime,jdbcType=TIMESTAMP}, ", + "#{refundRemarks,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR}, ", + "#{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGasOrder record); @@ -145,6 +147,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="gas_agent_name", property="gasAgentName", jdbcType=JdbcType.VARCHAR), @Result(column="gas_org_id", property="gasOrgId", jdbcType=JdbcType.BIGINT), @Result(column="gas_org_name", property="gasOrgName", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), @@ -170,8 +173,8 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "gas_discount, gas_oil_subsidy, gas_liters_preferences, gas_price_preferences, ", "gas_class_group_id, gas_class_group_name, gas_class_group_task_id, gas_staff_id, ", "gas_staff_name, gas_salesman_id, gas_salesman_name, gas_agent_id, gas_agent_name, ", - "gas_org_id, gas_org_name, `status`, create_time, cancel_time, pay_time, refund_time, ", - "refund_remarks, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", + "gas_org_id, gas_org_name, pay_type, `status`, create_time, cancel_time, pay_time, ", + "refund_time, refund_remarks, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", "from high_gas_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -220,6 +223,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="gas_agent_name", property="gasAgentName", jdbcType=JdbcType.VARCHAR), @Result(column="gas_org_id", property="gasOrgId", jdbcType=JdbcType.BIGINT), @Result(column="gas_org_name", property="gasOrgName", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_type", property="payType", jdbcType=JdbcType.INTEGER), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="cancel_time", property="cancelTime", jdbcType=JdbcType.TIMESTAMP), @@ -289,6 +293,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "gas_agent_name = #{gasAgentName,jdbcType=VARCHAR},", "gas_org_id = #{gasOrgId,jdbcType=BIGINT},", "gas_org_name = #{gasOrgName,jdbcType=VARCHAR},", + "pay_type = #{payType,jdbcType=INTEGER},", "`status` = #{status,jdbcType=INTEGER},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "cancel_time = #{cancelTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java index bc2068f0..52908b0b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java @@ -200,6 +200,10 @@ public class HighGasOrderSqlProvider { sql.VALUES("gas_org_name", "#{gasOrgName,jdbcType=VARCHAR}"); } + if (record.getPayType() != null) { + sql.VALUES("pay_type", "#{payType,jdbcType=INTEGER}"); + } + if (record.getStatus() != null) { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } @@ -301,6 +305,7 @@ public class HighGasOrderSqlProvider { sql.SELECT("gas_agent_name"); sql.SELECT("gas_org_id"); sql.SELECT("gas_org_name"); + sql.SELECT("pay_type"); sql.SELECT("`status`"); sql.SELECT("create_time"); sql.SELECT("cancel_time"); @@ -506,6 +511,10 @@ public class HighGasOrderSqlProvider { sql.SET("gas_org_name = #{record.gasOrgName,jdbcType=VARCHAR}"); } + if (record.getPayType() != null) { + sql.SET("pay_type = #{record.payType,jdbcType=INTEGER}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } @@ -606,6 +615,7 @@ public class HighGasOrderSqlProvider { sql.SET("gas_agent_name = #{record.gasAgentName,jdbcType=VARCHAR}"); sql.SET("gas_org_id = #{record.gasOrgId,jdbcType=BIGINT}"); sql.SET("gas_org_name = #{record.gasOrgName,jdbcType=VARCHAR}"); + sql.SET("pay_type = #{record.payType,jdbcType=INTEGER}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("cancel_time = #{record.cancelTime,jdbcType=TIMESTAMP}"); @@ -800,6 +810,10 @@ public class HighGasOrderSqlProvider { sql.SET("gas_org_name = #{gasOrgName,jdbcType=VARCHAR}"); } + if (record.getPayType() != null) { + sql.SET("pay_type = #{payType,jdbcType=INTEGER}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java index 89c02664..5c3a5b4e 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java @@ -234,6 +234,11 @@ public class HighGasOrder implements Serializable { */ private String gasOrgName; + /** + * 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通工会卡 5:银联 + */ + private Integer payType; + /** * 订单状态: 1. 待支付 @@ -636,6 +641,14 @@ public class HighGasOrder implements Serializable { this.gasOrgName = gasOrgName; } + public Integer getPayType() { + return payType; + } + + public void setPayType(Integer payType) { + this.payType = payType; + } + public Integer getStatus() { return status; } @@ -788,6 +801,7 @@ public class HighGasOrder implements Serializable { && (this.getGasAgentName() == null ? other.getGasAgentName() == null : this.getGasAgentName().equals(other.getGasAgentName())) && (this.getGasOrgId() == null ? other.getGasOrgId() == null : this.getGasOrgId().equals(other.getGasOrgId())) && (this.getGasOrgName() == null ? other.getGasOrgName() == null : this.getGasOrgName().equals(other.getGasOrgName())) + && (this.getPayType() == null ? other.getPayType() == null : this.getPayType().equals(other.getPayType())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCancelTime() == null ? other.getCancelTime() == null : this.getCancelTime().equals(other.getCancelTime())) @@ -850,6 +864,7 @@ public class HighGasOrder implements Serializable { result = prime * result + ((getGasAgentName() == null) ? 0 : getGasAgentName().hashCode()); result = prime * result + ((getGasOrgId() == null) ? 0 : getGasOrgId().hashCode()); result = prime * result + ((getGasOrgName() == null) ? 0 : getGasOrgName().hashCode()); + result = prime * result + ((getPayType() == null) ? 0 : getPayType().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCancelTime() == null) ? 0 : getCancelTime().hashCode()); @@ -915,6 +930,7 @@ public class HighGasOrder implements Serializable { sb.append(", gasAgentName=").append(gasAgentName); sb.append(", gasOrgId=").append(gasOrgId); sb.append(", gasOrgName=").append(gasOrgName); + sb.append(", payType=").append(payType); sb.append(", status=").append(status); sb.append(", createTime=").append(createTime); sb.append(", cancelTime=").append(cancelTime); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java index ddecc6e7..53b7c9eb 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java @@ -2906,6 +2906,66 @@ public class HighGasOrderExample { return (Criteria) this; } + public Criteria andPayTypeIsNull() { + addCriterion("pay_type is null"); + return (Criteria) this; + } + + public Criteria andPayTypeIsNotNull() { + addCriterion("pay_type is not null"); + return (Criteria) this; + } + + public Criteria andPayTypeEqualTo(Integer value) { + addCriterion("pay_type =", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeNotEqualTo(Integer value) { + addCriterion("pay_type <>", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeGreaterThan(Integer value) { + addCriterion("pay_type >", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeGreaterThanOrEqualTo(Integer value) { + addCriterion("pay_type >=", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeLessThan(Integer value) { + addCriterion("pay_type <", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeLessThanOrEqualTo(Integer value) { + addCriterion("pay_type <=", value, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeIn(List values) { + addCriterion("pay_type in", values, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeNotIn(List values) { + addCriterion("pay_type not in", values, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeBetween(Integer value1, Integer value2) { + addCriterion("pay_type between", value1, value2, "payType"); + return (Criteria) this; + } + + public Criteria andPayTypeNotBetween(Integer value1, Integer value2) { + addCriterion("pay_type not between", value1, value2, "payType"); + return (Criteria) this; + } + public Criteria andStatusIsNull() { addCriterion("`status` is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java new file mode 100644 index 00000000..262a751c --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/service/OrderRefundHandleService.java @@ -0,0 +1,27 @@ +package com.hai.order.service; + +import com.hai.entity.HighChildOrder; + +/** + * 退款订单-业务处理 + * @className: CreateOrderCheckService + * @author: HuRui + * @date: 2022/8/25 + **/ +public interface OrderRefundHandleService { + + /** + * 卡券业务 + * @param childOrder 子订单 + * @return + * @throws Exception + */ + void couponHandle(HighChildOrder childOrder) ; + + /** + * 加油业务 + * @param childOrder + */ + void oilHandle(HighChildOrder childOrder) ; + +} diff --git a/hai-service/src/main/java/com/hai/order/service/OrderService.java b/hai-service/src/main/java/com/hai/order/service/OrderService.java index de180b51..33c15897 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderService.java @@ -1,5 +1,6 @@ package com.hai.order.service; +import com.alicp.jetcache.anno.CacheUpdate; import com.hai.entity.HighChildOrder; import com.hai.entity.HighOrder; import com.hai.order.model.CreateOrderModel; diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index b766f9bf..2ec159a5 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -137,9 +137,9 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { integralHandle(order,childOrder); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE3.getNumber())) { - oilHandle(order,childOrder); order.setOrderStatus(OrderStatus.STATUS3.getNumber()); order.setFinishTime(new Date()); + oilHandle(order,childOrder); orderService.updateOrderData(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE4.getNumber())) { @@ -218,6 +218,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { if (gasOrder != null) { gasOrder.setPayTime(new Date()); gasOrder.setStatus(OrderOilStatus.STATUS2.getNumber()); + gasOrder.setPayType(order.getPayType()); gasOrder.setPayPrice(order.getPayPrice()); gasOrderService.updateGasOrder(gasOrder); diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java new file mode 100644 index 00000000..d8475c51 --- /dev/null +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundHandleServiceImpl.java @@ -0,0 +1,46 @@ +package com.hai.order.service.impl; + +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighGasOrder; +import com.hai.order.service.OrderRefundHandleService; +import com.hai.order.type.OrderOilStatus; +import com.hai.service.HighGasOrderService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; + +/** + * @className: OrderRefundHandleServiceImpl + * @author: HuRui + * @date: 2022/9/23 + **/ +@Service("orderRefundHandleService") +public class OrderRefundHandleServiceImpl implements OrderRefundHandleService { + + @Resource + private HighGasOrderService gasOrderService; + + @Override + public void couponHandle(HighChildOrder childOrder) { + + } + + @Override + public void oilHandle(HighChildOrder childOrder) { + // 查询加油订单 + HighGasOrder gasOrder = gasOrderService.getDetailByChildOrderNo(childOrder.getChildOrderNo()); + if (gasOrder == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油订单"); + } + if (!gasOrder.getStatus().equals(OrderOilStatus.STATUS2.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "加油订单不处于已支付状态"); + } + gasOrder.setRefundTime(childOrder.getRefundTime()); + gasOrder.setStatus(OrderOilStatus.STATUS4.getNumber()); + gasOrderService.updateGasOrder(gasOrder); + } +} diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java index c7875b47..238d0958 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderRefundServiceImpl.java @@ -60,8 +60,8 @@ public class OrderRefundServiceImpl implements OrderRefundService { @Override public HighOrderRefund createOrderChildRefund(HighChildOrder orderChild,String refundNo,Integer refundGoodsCount, String remarks) throws Exception { - if (orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS2.getNumber()) - || orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS3.getNumber())){ + if (!orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS2.getNumber()) + && !orderChild.getChildOrderStatus().equals(OrderChildStatus.STATUS3.getNumber())){ throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "子订单状态错误"); } if (orderChild.getSurplusRefundIntegral() <= 0 diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index c0fb9c77..fb2562f7 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -77,6 +77,9 @@ public class OrderServiceImpl implements OrderService { @Resource private OrderCancelHandleService orderCancelHandleService; + @Resource + private OrderRefundHandleService orderRefundHandleService; + @Resource private OrderPaySuccessService paySuccessService; @@ -106,7 +109,7 @@ public class OrderServiceImpl implements OrderService { isolation = Isolation.READ_COMMITTED, timeout = 10, rollbackFor = Exception.class) - @Cached(cacheType = CacheType.BOTH, name="order:", key = "#createOrderModel.orderNo", expire = 3600*24*30) // 缓存一个月 + @Cached(cacheType = CacheType.REMOTE, name="order:", key = "#createOrderModel.orderNo", expire = 3600*24*30) // 缓存一个月 public HighOrder createOrder(CreateOrderModel createOrderModel) throws Exception { HighDiscountUserRel discountUserRel = null; @@ -136,6 +139,7 @@ public class OrderServiceImpl implements OrderService { order.setOrderStatus(OrderStatus.STATUS1.getNumber()); order.setWhetherCheck(false); order.setWhetherRebate(false); + order.setProfitSharingStatus(false); order.setExceptionStatus(false); order.setCreateTime(new Date()); order.setPayGold(0); @@ -287,7 +291,7 @@ public class OrderServiceImpl implements OrderService { // 积分金额小于应付金额 if (goldPrice.compareTo(order.getPayablePrice()) == -1) { // 扣除用户积分 - userService.goldHandle(order.getMemId(), order.getPayGold(), 2, 2, order.getId(), + userService.goldHandle(order.getMemId(), createOrderModel.getPayGold(), 2, 2, order.getId(), "抵扣积分订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); } @@ -306,18 +310,22 @@ public class OrderServiceImpl implements OrderService { throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); } // 扣除用户积分 - userService.goldHandle(order.getMemId(), order.getPayGold(), 2, 2, order.getId(), + userService.goldHandle(order.getMemId(), createOrderModel.getPayGold(), 2, 2, order.getId(), "抵扣积分订单:" + order.getOrderNo() + ",使用积分:" + order.getPayGold()); order.setOrderStatus(OrderStatus.STATUS2.getNumber()); order.setPayRealPrice(order.getPayPrice()); order.setPayTime(new Date()); + order.setPayGold(createOrderModel.getPayGold()); for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrderStatus(OrderChildStatus.STATUS2.getNumber()); } } } + order.setSurplusRefundPrice(new BigDecimal("0")); + order.setSurplusRefundIntegral(0); + // 订单入库前处理 for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setOrderNo(order.getOrderNo()); @@ -339,6 +347,8 @@ public class OrderServiceImpl implements OrderService { } else { childOrder.setSurplusRefundIntegral(0); } + order.setSurplusRefundPrice(order.getSurplusRefundPrice().add(childOrder.getSurplusRefundPrice())); + order.setSurplusRefundIntegral(order.getSurplusRefundIntegral() + childOrder.getSurplusRefundIntegral()); } // 订单入库 @@ -351,7 +361,7 @@ public class OrderServiceImpl implements OrderService { } else if (orderData.getOrderStatus().equals(OrderStatus.STATUS2.getNumber())) { // 异步处理业务 - paySuccessService.orderPaySuccessHandle(orderData.getOrderNo(), null, null, new BigDecimal("0"), null); + paySuccessService.orderPaySuccessHandle(orderData.getOrderNo(), OrderPayType.PAY_TYPE3, null, new BigDecimal("0"), null); } return orderData; } @@ -419,7 +429,7 @@ public class OrderServiceImpl implements OrderService { public HighOrder refundOrder(String orderNo, String remarks) throws Exception { HighOrder order = getOrderDetailByNo(orderNo); if (!order.getOrderStatus().equals(OrderStatus.STATUS2.getNumber()) - || !order.getOrderStatus().equals(OrderStatus.STATUS3.getNumber())) { + && !order.getOrderStatus().equals(OrderStatus.STATUS3.getNumber())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 订单是否异常,订单没异常则需要校验产品业务是否支持退款 @@ -435,20 +445,26 @@ public class OrderServiceImpl implements OrderService { // 创建退款 order = orderRefundService.createOrderRefund(order, remarks); - // todo 退款金额,原路返回 - - - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - childOrder.setRefundRemarks(remarks); - childOrder.setRefundTime(new Date()); - childOrder.setChildOrderStatus(OrderChildStatus.STATUS4.getNumber()); + if (childOrder.getGiveawayType() == false) { + childOrder.setRefundRemarks(remarks); + childOrder.setRefundTime(new Date()); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS4.getNumber()); + + if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE3.getNumber())) { + orderRefundHandleService.oilHandle(childOrder); + } + } } order.setSurplusRefundIntegral(0); order.setSurplusRefundPrice(new BigDecimal("0")); order.setRefundTime(new Date()); order.setOrderStatus(OrderStatus.STATUS4.getNumber()); + + // todo 退款金额,原路返回 + + return updateOrderData(order); } @@ -510,7 +526,7 @@ public class OrderServiceImpl implements OrderService { } @Override - @Cached(cacheType = CacheType.BOTH,name="order:", key = "#orderNo",expire = 3600*24*30) + @Cached(cacheType = CacheType.REMOTE,name="order:", key = "#orderNo",expire = 3600*24*30) public HighOrder getOrderDetailByNo(String orderNo) { HighOrderExample orderExample = new HighOrderExample(); orderExample.createCriteria().andOrderNoEqualTo(orderNo); diff --git a/hai-service/src/main/java/com/hai/order/type/OrderPayType.java b/hai-service/src/main/java/com/hai/order/type/OrderPayType.java index e46c9fd5..95a25155 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderPayType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderPayType.java @@ -11,8 +11,7 @@ import java.util.Objects; public enum OrderPayType { PAY_TYPE1(1, "支付宝"), PAY_TYPE2(2, "微信"), - @Deprecated - PAY_TYPE3(3, "金币"), + PAY_TYPE3(3, "积分抵扣"), PAY_TYPE4(4, "贵州汇联通工会卡"), PAY_TYPE5(5, "银联"), PAY_TYPE6(6, "银联分期"), diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java index 457921b0..f11608de 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java @@ -104,7 +104,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站"); } - // 是否是加油站 + // 是否是加油站· if (!store.getType().equals(1)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油站"); }