'提交代码'

dev-discount
199901012 4 years ago
parent dfe1c8a124
commit 8c4ce3d92c
  1. 41
      hai-service/src/main/java/com/hai/dao/HighCouponCodeMapper.java
  2. 30
      hai-service/src/main/java/com/hai/dao/HighCouponCodeSqlProvider.java
  3. 34
      hai-service/src/main/java/com/hai/entity/HighCouponCode.java
  4. 108
      hai-service/src/main/java/com/hai/entity/HighCouponCodeExample.java
  5. 21
      hai-service/src/main/java/com/hai/service/HighCouponCodeService.java
  6. 26
      hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java
  7. 25
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  8. 10
      hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java

@ -40,19 +40,21 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt {
@Insert({
"insert into high_coupon_code (coupon_id, merchant_id, ",
"order_id, sales_code, ",
"sales_end_time, use_end_time, ",
"create_time, receive_time, ",
"consume_time, `status`, ",
"operator_id, operator_name, ",
"ext_1, ext_2, ext_3)",
"store_id, child_order_id, ",
"sales_code, sales_end_time, ",
"use_end_time, create_time, ",
"receive_time, consume_time, ",
"`status`, operator_id, ",
"operator_name, ext_1, ",
"ext_2, ext_3)",
"values (#{couponId,jdbcType=BIGINT}, #{merchantId,jdbcType=BIGINT}, ",
"#{orderId,jdbcType=BIGINT}, #{salesCode,jdbcType=VARCHAR}, ",
"#{salesEndTime,jdbcType=TIMESTAMP}, #{useEndTime,jdbcType=TIMESTAMP}, ",
"#{createTime,jdbcType=TIMESTAMP}, #{receiveTime,jdbcType=TIMESTAMP}, ",
"#{consumeTime,jdbcType=TIMESTAMP}, #{status,jdbcType=INTEGER}, ",
"#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ",
"#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
"#{storeId,jdbcType=BIGINT}, #{childOrderId,jdbcType=BIGINT}, ",
"#{salesCode,jdbcType=VARCHAR}, #{salesEndTime,jdbcType=TIMESTAMP}, ",
"#{useEndTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, ",
"#{receiveTime,jdbcType=TIMESTAMP}, #{consumeTime,jdbcType=TIMESTAMP}, ",
"#{status,jdbcType=INTEGER}, #{operatorId,jdbcType=BIGINT}, ",
"#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ",
"#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})"
})
@Options(useGeneratedKeys=true,keyProperty="id")
int insert(HighCouponCode record);
@ -66,7 +68,8 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt {
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT),
@Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT),
@Result(column="sales_code", property="salesCode", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_end_time", property="salesEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@ -84,9 +87,9 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt {
@Select({
"select",
"id, coupon_id, merchant_id, order_id, sales_code, sales_end_time, use_end_time, ",
"create_time, receive_time, consume_time, `status`, operator_id, operator_name, ",
"ext_1, ext_2, ext_3",
"id, coupon_id, merchant_id, store_id, child_order_id, sales_code, sales_end_time, ",
"use_end_time, create_time, receive_time, consume_time, `status`, operator_id, ",
"operator_name, ext_1, ext_2, ext_3",
"from high_coupon_code",
"where id = #{id,jdbcType=BIGINT}"
})
@ -94,7 +97,8 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt {
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT),
@Result(column="merchant_id", property="merchantId", jdbcType=JdbcType.BIGINT),
@Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT),
@Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT),
@Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT),
@Result(column="sales_code", property="salesCode", jdbcType=JdbcType.VARCHAR),
@Result(column="sales_end_time", property="salesEndTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="use_end_time", property="useEndTime", jdbcType=JdbcType.TIMESTAMP),
@ -123,7 +127,8 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt {
"update high_coupon_code",
"set coupon_id = #{couponId,jdbcType=BIGINT},",
"merchant_id = #{merchantId,jdbcType=BIGINT},",
"order_id = #{orderId,jdbcType=BIGINT},",
"store_id = #{storeId,jdbcType=BIGINT},",
"child_order_id = #{childOrderId,jdbcType=BIGINT},",
"sales_code = #{salesCode,jdbcType=VARCHAR},",
"sales_end_time = #{salesEndTime,jdbcType=TIMESTAMP},",
"use_end_time = #{useEndTime,jdbcType=TIMESTAMP},",

@ -36,8 +36,12 @@ public class HighCouponCodeSqlProvider {
sql.VALUES("merchant_id", "#{merchantId,jdbcType=BIGINT}");
}
if (record.getOrderId() != null) {
sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}");
if (record.getStoreId() != null) {
sql.VALUES("store_id", "#{storeId,jdbcType=BIGINT}");
}
if (record.getChildOrderId() != null) {
sql.VALUES("child_order_id", "#{childOrderId,jdbcType=BIGINT}");
}
if (record.getSalesCode() != null) {
@ -100,7 +104,8 @@ public class HighCouponCodeSqlProvider {
}
sql.SELECT("coupon_id");
sql.SELECT("merchant_id");
sql.SELECT("order_id");
sql.SELECT("store_id");
sql.SELECT("child_order_id");
sql.SELECT("sales_code");
sql.SELECT("sales_end_time");
sql.SELECT("use_end_time");
@ -142,8 +147,12 @@ public class HighCouponCodeSqlProvider {
sql.SET("merchant_id = #{record.merchantId,jdbcType=BIGINT}");
}
if (record.getOrderId() != null) {
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
if (record.getStoreId() != null) {
sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}");
}
if (record.getChildOrderId() != null) {
sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}");
}
if (record.getSalesCode() != null) {
@ -205,7 +214,8 @@ public class HighCouponCodeSqlProvider {
sql.SET("id = #{record.id,jdbcType=BIGINT}");
sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}");
sql.SET("merchant_id = #{record.merchantId,jdbcType=BIGINT}");
sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}");
sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}");
sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}");
sql.SET("sales_code = #{record.salesCode,jdbcType=VARCHAR}");
sql.SET("sales_end_time = #{record.salesEndTime,jdbcType=TIMESTAMP}");
sql.SET("use_end_time = #{record.useEndTime,jdbcType=TIMESTAMP}");
@ -236,8 +246,12 @@ public class HighCouponCodeSqlProvider {
sql.SET("merchant_id = #{merchantId,jdbcType=BIGINT}");
}
if (record.getOrderId() != null) {
sql.SET("order_id = #{orderId,jdbcType=BIGINT}");
if (record.getStoreId() != null) {
sql.SET("store_id = #{storeId,jdbcType=BIGINT}");
}
if (record.getChildOrderId() != null) {
sql.SET("child_order_id = #{childOrderId,jdbcType=BIGINT}");
}
if (record.getSalesCode() != null) {

@ -28,10 +28,15 @@ public class HighCouponCode implements Serializable {
*/
private Long merchantId;
/**
* (消核门店) 门店id
*/
private Long storeId;
/**
* 订单id
*/
private Long orderId;
private Long childOrderId;
/**
* 销售码
@ -64,7 +69,7 @@ public class HighCouponCode implements Serializable {
private Date consumeTime;
/**
* 状态1.待销售 2.未使用 3.已使用
* 状态1.待销售 2.未使用 3.已使用 99.预支付
*/
private Integer status;
@ -110,12 +115,20 @@ public class HighCouponCode implements Serializable {
this.merchantId = merchantId;
}
public Long getOrderId() {
return orderId;
public Long getStoreId() {
return storeId;
}
public void setStoreId(Long storeId) {
this.storeId = storeId;
}
public Long getChildOrderId() {
return childOrderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
public void setChildOrderId(Long childOrderId) {
this.childOrderId = childOrderId;
}
public String getSalesCode() {
@ -229,7 +242,8 @@ public class HighCouponCode implements Serializable {
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId()))
&& (this.getMerchantId() == null ? other.getMerchantId() == null : this.getMerchantId().equals(other.getMerchantId()))
&& (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId()))
&& (this.getStoreId() == null ? other.getStoreId() == null : this.getStoreId().equals(other.getStoreId()))
&& (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId()))
&& (this.getSalesCode() == null ? other.getSalesCode() == null : this.getSalesCode().equals(other.getSalesCode()))
&& (this.getSalesEndTime() == null ? other.getSalesEndTime() == null : this.getSalesEndTime().equals(other.getSalesEndTime()))
&& (this.getUseEndTime() == null ? other.getUseEndTime() == null : this.getUseEndTime().equals(other.getUseEndTime()))
@ -251,7 +265,8 @@ public class HighCouponCode implements Serializable {
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode());
result = prime * result + ((getMerchantId() == null) ? 0 : getMerchantId().hashCode());
result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode());
result = prime * result + ((getStoreId() == null) ? 0 : getStoreId().hashCode());
result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode());
result = prime * result + ((getSalesCode() == null) ? 0 : getSalesCode().hashCode());
result = prime * result + ((getSalesEndTime() == null) ? 0 : getSalesEndTime().hashCode());
result = prime * result + ((getUseEndTime() == null) ? 0 : getUseEndTime().hashCode());
@ -276,7 +291,8 @@ public class HighCouponCode implements Serializable {
sb.append(", id=").append(id);
sb.append(", couponId=").append(couponId);
sb.append(", merchantId=").append(merchantId);
sb.append(", orderId=").append(orderId);
sb.append(", storeId=").append(storeId);
sb.append(", childOrderId=").append(childOrderId);
sb.append(", salesCode=").append(salesCode);
sb.append(", salesEndTime=").append(salesEndTime);
sb.append(", useEndTime=").append(useEndTime);

@ -305,63 +305,123 @@ public class HighCouponCodeExample {
return (Criteria) this;
}
public Criteria andOrderIdIsNull() {
addCriterion("order_id is null");
public Criteria andStoreIdIsNull() {
addCriterion("store_id is null");
return (Criteria) this;
}
public Criteria andOrderIdIsNotNull() {
addCriterion("order_id is not null");
public Criteria andStoreIdIsNotNull() {
addCriterion("store_id is not null");
return (Criteria) this;
}
public Criteria andOrderIdEqualTo(Long value) {
addCriterion("order_id =", value, "orderId");
public Criteria andStoreIdEqualTo(Long value) {
addCriterion("store_id =", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdNotEqualTo(Long value) {
addCriterion("order_id <>", value, "orderId");
public Criteria andStoreIdNotEqualTo(Long value) {
addCriterion("store_id <>", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdGreaterThan(Long value) {
addCriterion("order_id >", value, "orderId");
public Criteria andStoreIdGreaterThan(Long value) {
addCriterion("store_id >", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdGreaterThanOrEqualTo(Long value) {
addCriterion("order_id >=", value, "orderId");
public Criteria andStoreIdGreaterThanOrEqualTo(Long value) {
addCriterion("store_id >=", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdLessThan(Long value) {
addCriterion("order_id <", value, "orderId");
public Criteria andStoreIdLessThan(Long value) {
addCriterion("store_id <", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdLessThanOrEqualTo(Long value) {
addCriterion("order_id <=", value, "orderId");
public Criteria andStoreIdLessThanOrEqualTo(Long value) {
addCriterion("store_id <=", value, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdIn(List<Long> values) {
addCriterion("order_id in", values, "orderId");
public Criteria andStoreIdIn(List<Long> values) {
addCriterion("store_id in", values, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdNotIn(List<Long> values) {
addCriterion("order_id not in", values, "orderId");
public Criteria andStoreIdNotIn(List<Long> values) {
addCriterion("store_id not in", values, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdBetween(Long value1, Long value2) {
addCriterion("order_id between", value1, value2, "orderId");
public Criteria andStoreIdBetween(Long value1, Long value2) {
addCriterion("store_id between", value1, value2, "storeId");
return (Criteria) this;
}
public Criteria andOrderIdNotBetween(Long value1, Long value2) {
addCriterion("order_id not between", value1, value2, "orderId");
public Criteria andStoreIdNotBetween(Long value1, Long value2) {
addCriterion("store_id not between", value1, value2, "storeId");
return (Criteria) this;
}
public Criteria andChildOrderIdIsNull() {
addCriterion("child_order_id is null");
return (Criteria) this;
}
public Criteria andChildOrderIdIsNotNull() {
addCriterion("child_order_id is not null");
return (Criteria) this;
}
public Criteria andChildOrderIdEqualTo(Long value) {
addCriterion("child_order_id =", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdNotEqualTo(Long value) {
addCriterion("child_order_id <>", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdGreaterThan(Long value) {
addCriterion("child_order_id >", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdGreaterThanOrEqualTo(Long value) {
addCriterion("child_order_id >=", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdLessThan(Long value) {
addCriterion("child_order_id <", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdLessThanOrEqualTo(Long value) {
addCriterion("child_order_id <=", value, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdIn(List<Long> values) {
addCriterion("child_order_id in", values, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdNotIn(List<Long> values) {
addCriterion("child_order_id not in", values, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdBetween(Long value1, Long value2) {
addCriterion("child_order_id between", value1, value2, "childOrderId");
return (Criteria) this;
}
public Criteria andChildOrderIdNotBetween(Long value1, Long value2) {
addCriterion("child_order_id not between", value1, value2, "childOrderId");
return (Criteria) this;
}

@ -28,6 +28,20 @@ public interface HighCouponCodeService {
**/
void insertList(List<HighCouponCode> list);
/**
* @Author 胡锐
* @Description xiug
* @Date 2021/3/27 1:20
**/
void updateCouponCode(HighCouponCode highCouponCode);
/**
* @Author 胡锐
* @Description 根据订单id查询
* @Date 2021/3/27 1:25
**/
HighCouponCode getCouponCodeByOrderId(Long childOrderId);
/**
*
* @Title: getStockCountByCoupon
@ -39,6 +53,13 @@ public interface HighCouponCodeService {
**/
Integer getStockCountByCoupon(Long couponId);
/**
* @Author 胡锐
* @Description 查询未销售的卡卷码
* @Date 2021/3/27 1:16
**/
List<HighCouponCode> getNoSaleCode(Long couponId);
/**
* @Author 胡锐
* @Description 查询销售码

@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -38,6 +39,23 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
highCouponCodeMapperExt.insertList(list);
}
@Override
public void updateCouponCode(HighCouponCode highCouponCode) {
highCouponCodeMapper.updateByPrimaryKey(highCouponCode);
}
@Override
public HighCouponCode getCouponCodeByOrderId(Long childOrderId) {
HighCouponCodeExample example = new HighCouponCodeExample();
example.createCriteria().andChildOrderIdEqualTo(childOrderId);
List<HighCouponCode> codes = highCouponCodeMapper.selectByExample(example);
if (codes != null && codes.size() > 0) {
return codes.get(0);
}
return null;
}
@Override
public Integer getStockCountByCoupon(Long couponId) {
HighCouponCodeExample example = new HighCouponCodeExample();
@ -45,6 +63,14 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService {
return highCouponCodeMapper.selectByExample(example).size();
}
@Override
public List<HighCouponCode> getNoSaleCode(Long couponId) {
Map<String, Object> map = new HashMap<>();
map.put("couponId", couponId);
map.put("status", 1);
return getCouponCodeList(map);
}
@Override
public List<HighCouponCode> getCouponCodeList(Map<String, Object> map) {
HighCouponCodeExample example = new HighCouponCodeExample();

@ -1,11 +1,12 @@
package com.hai.service.impl;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.dao.HighChildOrderMapper;
import com.hai.dao.HighOrderMapper;
import com.hai.entity.HighChildOrder;
import com.hai.entity.HighChildOrderExample;
import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderExample;
import com.hai.entity.*;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,6 +32,9 @@ public class HighOrderServiceImpl implements HighOrderService {
@Resource
private HighChildOrderMapper highChildOrderMapper;
@Resource
private HighCouponCodeService highCouponCodeService;
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertOrder(HighOrder highOrder) {
@ -38,6 +43,18 @@ public class HighOrderServiceImpl implements HighOrderService {
for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) {
childOrder.setOrderId(highOrder.getId());
highChildOrderMapper.insert(childOrder);
// 商品类型 1:卡卷
if (childOrder.getGoodsType() == 1) {
// 查询待销售
List<HighCouponCode> list = highCouponCodeService.getNoSaleCode(childOrder.getGoodsId());
if (list == null || list.size() == 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COUPON_STOCK_INSUFFICIENT, "");
}
list.get(0).setChildOrderId(childOrder.getId());
list.get(0).setStatus(99); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
highCouponCodeService.updateCouponCode(list.get(0));
}
}
}

@ -5,7 +5,9 @@ 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.HighCouponCode;
import com.hai.entity.HighOrder;
import com.hai.service.HighCouponCodeService;
import com.hai.service.HighOrderService;
import com.hai.service.pay.PayService;
import org.apache.commons.lang3.StringUtils;
@ -28,6 +30,9 @@ public class GoodsOrderServiceImpl implements PayService {
@Resource
private HighOrderService highOrderService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
@ -49,6 +54,11 @@ public class GoodsOrderServiceImpl implements PayService {
for (HighChildOrder highChildOrder : order.getHighChildOrderList()) {
highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
// 商品类型 1:卡卷
if (highChildOrder.getGoodsType() == 1) {
// highCouponCodeService.getCouponCodeById(highChildOrder.get)
}
}
highOrderService.updateOrder(order);

Loading…
Cancel
Save