diff --git a/hai-bweb/src/main/java/com/bweb/excelListener/ImportCouponListener.java b/hai-bweb/src/main/java/com/bweb/excelListener/ImportCouponListener.java index 712c1218..0f3abc0b 100644 --- a/hai-bweb/src/main/java/com/bweb/excelListener/ImportCouponListener.java +++ b/hai-bweb/src/main/java/com/bweb/excelListener/ImportCouponListener.java @@ -55,9 +55,19 @@ public class ImportCouponListener extends AnalysisEventListener codeList = allCouponCode.stream().filter(o -> o.getCodeKey().equals(importCouponModel.getCodeKey())).collect(Collectors.toList()); + if (codeList.size() > 0) { + importCouponModel.setErrorMessage("卡券编号id已存在"); + errorData.add(importCouponModel); + return; + } + } + highCouponCode = new HighCouponCode(); highCouponCode.setCouponId(highCoupon.getId()); highCouponCode.setMerchantId(highCoupon.getMerchantId()); + highCouponCode.setCodeKey(importCouponModel.getCodeKey()); highCouponCode.setSalesCode(importCouponModel.getSalesCode()); highCouponCode.setIsAssignAgent(false); diff --git a/hai-bweb/src/main/java/com/bweb/model/ImportCouponModel.java b/hai-bweb/src/main/java/com/bweb/model/ImportCouponModel.java index 76a687f8..04bec506 100644 --- a/hai-bweb/src/main/java/com/bweb/model/ImportCouponModel.java +++ b/hai-bweb/src/main/java/com/bweb/model/ImportCouponModel.java @@ -10,6 +10,9 @@ import com.alibaba.excel.annotation.format.DateTimeFormat; */ public class ImportCouponModel { + @ExcelProperty("卡券编号Id") + private String codeKey; + @ExcelProperty("卡券销售码") private String salesCode; @@ -23,6 +26,14 @@ public class ImportCouponModel { // 错误消息 private String errorMessage; + public String getCodeKey() { + return codeKey; + } + + public void setCodeKey(String codeKey) { + this.codeKey = codeKey; + } + public String getSalesCode() { return salesCode; } diff --git a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java index 3820c9d4..325eedea 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java +++ b/hai-schedule/src/main/java/com/hai/schedule/SynchronizeCNPC.java @@ -39,7 +39,7 @@ public class SynchronizeCNPC { @Resource private SecSinopecConfigService secSinopecConfigService; - @Scheduled(cron="0 0/5 * * * ?") //每1分钟执行一次 + @Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次 public void certification() { List sinopecConfig = secSinopecConfigService.getListSinopecConfig(new HashMap<>()); @@ -61,7 +61,7 @@ public class SynchronizeCNPC { Map bodyMap = new HashMap<>(); bodyMap.put("appId", config.getAppId()); bodyMap.put("pageNo", 1); - bodyMap.put("pageSize", 100); + bodyMap.put("pageSize", 2000); bodyMap.put("startTime", instance.getTime()); bodyMap.put("endTime", new Date()); bodyMap.put("customerCode", config.getCode()); diff --git a/hai-schedule/src/main/resources/dev/application.yml b/hai-schedule/src/main/resources/dev/application.yml index 481490a2..ff2ce013 100644 --- a/hai-schedule/src/main/resources/dev/application.yml +++ b/hai-schedule/src/main/resources/dev/application.yml @@ -9,8 +9,8 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 - username: hfkj + url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8 + username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.jdbc.Driver diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapper.java index 14f98a4f..c0c27890 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeMapper.java @@ -42,21 +42,21 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { "insert into high_coupon_code (coupon_id, merchant_id, ", "is_assign_agent, agent_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)", + "code_key, 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}, ", "#{isAssignAgent,jdbcType=BIT}, #{agentId,jdbcType=BIGINT}, ", "#{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})" + "#{codeKey,jdbcType=VARCHAR}, #{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); @@ -74,6 +74,7 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), + @Result(column="code_key", property="codeKey", jdbcType=JdbcType.VARCHAR), @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), @@ -92,8 +93,8 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { @Select({ "select", "id, coupon_id, merchant_id, is_assign_agent, agent_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", + "code_key, 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}" }) @@ -105,6 +106,7 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="store_id", property="storeId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), + @Result(column="code_key", property="codeKey", jdbcType=JdbcType.VARCHAR), @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), @@ -137,6 +139,7 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { "agent_id = #{agentId,jdbcType=BIGINT},", "store_id = #{storeId,jdbcType=BIGINT},", "child_order_id = #{childOrderId,jdbcType=BIGINT},", + "code_key = #{codeKey,jdbcType=VARCHAR},", "sales_code = #{salesCode,jdbcType=VARCHAR},", "sales_end_time = #{salesEndTime,jdbcType=TIMESTAMP},", "use_end_time = #{useEndTime,jdbcType=TIMESTAMP},", @@ -152,4 +155,4 @@ public interface HighCouponCodeMapper extends HighCouponCodeMapperExt { "where id = #{id,jdbcType=BIGINT}" }) int updateByPrimaryKey(HighCouponCode record); -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeSqlProvider.java index 8836bc57..fcc462cf 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeSqlProvider.java @@ -52,6 +52,10 @@ public class HighCouponCodeSqlProvider { sql.VALUES("child_order_id", "#{childOrderId,jdbcType=BIGINT}"); } + if (record.getCodeKey() != null) { + sql.VALUES("code_key", "#{codeKey,jdbcType=VARCHAR}"); + } + if (record.getSalesCode() != null) { sql.VALUES("sales_code", "#{salesCode,jdbcType=VARCHAR}"); } @@ -116,6 +120,7 @@ public class HighCouponCodeSqlProvider { sql.SELECT("agent_id"); sql.SELECT("store_id"); sql.SELECT("child_order_id"); + sql.SELECT("code_key"); sql.SELECT("sales_code"); sql.SELECT("sales_end_time"); sql.SELECT("use_end_time"); @@ -173,6 +178,10 @@ public class HighCouponCodeSqlProvider { sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}"); } + if (record.getCodeKey() != null) { + sql.SET("code_key = #{record.codeKey,jdbcType=VARCHAR}"); + } + if (record.getSalesCode() != null) { sql.SET("sales_code = #{record.salesCode,jdbcType=VARCHAR}"); } @@ -236,6 +245,7 @@ public class HighCouponCodeSqlProvider { sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); sql.SET("store_id = #{record.storeId,jdbcType=BIGINT}"); sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}"); + sql.SET("code_key = #{record.codeKey,jdbcType=VARCHAR}"); 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}"); @@ -282,6 +292,10 @@ public class HighCouponCodeSqlProvider { sql.SET("child_order_id = #{childOrderId,jdbcType=BIGINT}"); } + if (record.getCodeKey() != null) { + sql.SET("code_key = #{codeKey,jdbcType=VARCHAR}"); + } + if (record.getSalesCode() != null) { sql.SET("sales_code = #{salesCode,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCode.java b/hai-service/src/main/java/com/hai/entity/HighCouponCode.java index f742d178..3ccbdd74 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCode.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCode.java @@ -48,6 +48,11 @@ public class HighCouponCode implements Serializable { */ private Long childOrderId; + /** + * 码key + */ + private String codeKey; + /** * 销售码 */ @@ -157,6 +162,14 @@ public class HighCouponCode implements Serializable { this.childOrderId = childOrderId; } + public String getCodeKey() { + return codeKey; + } + + public void setCodeKey(String codeKey) { + this.codeKey = codeKey; + } + public String getSalesCode() { return salesCode; } @@ -272,6 +285,7 @@ public class HighCouponCode implements Serializable { && (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) && (this.getStoreId() == null ? other.getStoreId() == null : this.getStoreId().equals(other.getStoreId())) && (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) + && (this.getCodeKey() == null ? other.getCodeKey() == null : this.getCodeKey().equals(other.getCodeKey())) && (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())) @@ -297,6 +311,7 @@ public class HighCouponCode implements Serializable { result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); result = prime * result + ((getStoreId() == null) ? 0 : getStoreId().hashCode()); result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode()); + result = prime * result + ((getCodeKey() == null) ? 0 : getCodeKey().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()); @@ -325,6 +340,7 @@ public class HighCouponCode implements Serializable { sb.append(", agentId=").append(agentId); sb.append(", storeId=").append(storeId); sb.append(", childOrderId=").append(childOrderId); + sb.append(", codeKey=").append(codeKey); sb.append(", salesCode=").append(salesCode); sb.append(", salesEndTime=").append(salesEndTime); sb.append(", useEndTime=").append(useEndTime); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeExample.java index 063972a3..88b0b2ae 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeExample.java @@ -545,6 +545,76 @@ public class HighCouponCodeExample { return (Criteria) this; } + public Criteria andCodeKeyIsNull() { + addCriterion("code_key is null"); + return (Criteria) this; + } + + public Criteria andCodeKeyIsNotNull() { + addCriterion("code_key is not null"); + return (Criteria) this; + } + + public Criteria andCodeKeyEqualTo(String value) { + addCriterion("code_key =", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyNotEqualTo(String value) { + addCriterion("code_key <>", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyGreaterThan(String value) { + addCriterion("code_key >", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyGreaterThanOrEqualTo(String value) { + addCriterion("code_key >=", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyLessThan(String value) { + addCriterion("code_key <", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyLessThanOrEqualTo(String value) { + addCriterion("code_key <=", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyLike(String value) { + addCriterion("code_key like", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyNotLike(String value) { + addCriterion("code_key not like", value, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyIn(List values) { + addCriterion("code_key in", values, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyNotIn(List values) { + addCriterion("code_key not in", values, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyBetween(String value1, String value2) { + addCriterion("code_key between", value1, value2, "codeKey"); + return (Criteria) this; + } + + public Criteria andCodeKeyNotBetween(String value1, String value2) { + addCriterion("code_key not between", value1, value2, "codeKey"); + return (Criteria) this; + } + public Criteria andSalesCodeIsNull() { addCriterion("sales_code is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java index afd91cdc..18348d56 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponCodeService.java @@ -1,7 +1,6 @@ package com.hai.service; import com.hai.entity.HighCouponCode; -import com.hai.model.HighCouponCodeModel; import com.hai.model.UserInfoModel; import java.util.Date; @@ -45,10 +44,10 @@ public interface HighCouponCodeService { /** * @Author 胡锐 - * @Description 中石化回调已使用的消核码 + * @Description 中石化回调已使用的码key * @Date 2021/4/19 21:53 **/ - void cnpcCallbackCouponCode(String salesCode,Date useTime); + void cnpcCallbackCouponCode(String codeKey,Date useTime); /** * @Author 胡锐 @@ -62,7 +61,14 @@ public interface HighCouponCodeService { * @Description 根据销售码查询 * @Date 2021/3/27 12:39 **/ - HighCouponCode getCouponCodeBySalesCode(String code); + HighCouponCode getCouponCodeBySalesCode(String code); + + /** + * @Author 胡锐 + * @Description 根据销售码key查询 + * @Date 2021/4/21 20:30 + **/ + HighCouponCode getCouponCodeByKey(String codeKey); /** * @Author 胡锐 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java index 9d9f3fb7..06df95ca 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponCodeServiceImpl.java @@ -124,8 +124,8 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { @Override @Transactional - public void cnpcCallbackCouponCode(String salesCode, Date useTime) { - HighCouponCode code = getCouponCodeBySalesCode(salesCode); + public void cnpcCallbackCouponCode(String codeKey, Date useTime) { + HighCouponCode code = getCouponCodeByKey(codeKey); if (code != null && code.getStatus() != 3) { code.setStatus(3); code.setConsumeTime(useTime); @@ -137,13 +137,11 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { List list = highUserCouponService.getUserCouponList(map); if (list.size() > 0) { for (HighUserCoupon userCoupon : list) { - userCoupon.setStatus(2); - userCoupon.setConsumeTime(useTime); HighChildOrder order = highOrderService.getChildOrderByUserGoods(userCoupon.getUserId(), 1, userCoupon.getCouponId()); if (order == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单"); } - userCoupon.setConsumeTime(new Date()); + userCoupon.setConsumeTime(useTime); userCoupon.setStatus(2); // 状态 0:已过期 1:未使用 2:已使用 highUserCouponService.updateUserCoupon(userCoupon); highOrderService.childOrderComplete(order.getId()); @@ -175,6 +173,17 @@ public class HighCouponCodeServiceImpl implements HighCouponCodeService { return null; } + @Override + public HighCouponCode getCouponCodeByKey(String codeKey) { + HighCouponCodeExample example = new HighCouponCodeExample(); + example.createCriteria().andCodeKeyEqualTo(codeKey); + List codes = highCouponCodeMapper.selectByExample(example); + if (codes != null && codes.size() > 0) { + return codes.get(0); + } + return null; + } + @Override public HighCouponCode getCouponCodeById(Long id) { return highCouponCodeMapper.selectByPrimaryKey(id);