Commit dcec6f3d4f2ec6ad122a330611c70cbff71529df

Authored by kangtian
1 parent c60bcbd2

店铺运费设置修改

etrade-shop/src/main/java/com/diligrp/etrade/shop/constant/Constant.java
@@ -79,4 +79,9 @@ public interface Constant { @@ -79,4 +79,9 @@ public interface Constant {
79 * 库存配置百分比默认值 79 * 库存配置百分比默认值
80 */ 80 */
81 BigDecimal STOCK_CONFIG_JMSF_DEFAULT = BigDecimal.valueOf(100.00); 81 BigDecimal STOCK_CONFIG_JMSF_DEFAULT = BigDecimal.valueOf(100.00);
  82 +
  83 + /**
  84 + * 店铺包邮时间间隔 /小时
  85 + */
  86 + Integer SHOP_EXPRESS_FREE_TIME_PERIOD = 24;
82 } 87 }
etrade-shop/src/main/java/com/diligrp/etrade/shop/domain/request/ShopExpressCo.java
@@ -2,6 +2,8 @@ package com.diligrp.etrade.shop.domain.request; @@ -2,6 +2,8 @@ package com.diligrp.etrade.shop.domain.request;
2 2
3 import com.diligrp.etrade.core.util.JsonUtils; 3 import com.diligrp.etrade.core.util.JsonUtils;
4 import com.diligrp.etrade.shop.model.ShopExpressSetting; 4 import com.diligrp.etrade.shop.model.ShopExpressSetting;
  5 +import jakarta.validation.constraints.NotNull;
  6 +import jakarta.validation.constraints.Size;
5 import org.springframework.format.annotation.DateTimeFormat; 7 import org.springframework.format.annotation.DateTimeFormat;
6 8
7 import java.io.Serializable; 9 import java.io.Serializable;
@@ -26,10 +28,12 @@ public class ShopExpressCo implements Serializable { @@ -26,10 +28,12 @@ public class ShopExpressCo implements Serializable {
26 /** 28 /**
27 * 配送方式 29 * 配送方式
28 */ 30 */
  31 + @Size(min = 1, message = "至少选择一种配送方式!")
29 private List<Integer> type; 32 private List<Integer> type;
30 /** 33 /**
31 * 固定运费 34 * 固定运费
32 */ 35 */
  36 + @NotNull(message = "fee should not be null")
33 private BigDecimal fee; 37 private BigDecimal fee;
34 /** 38 /**
35 * 包邮条件 39 * 包邮条件
etrade-shop/src/main/java/com/diligrp/etrade/shop/service/impl/ShopExpressSettingServiceImpl.java
1 package com.diligrp.etrade.shop.service.impl; 1 package com.diligrp.etrade.shop.service.impl;
2 2
  3 +import com.diligrp.etrade.shop.constant.Constant;
3 import com.diligrp.etrade.shop.dao.ShopExpressSettingDao; 4 import com.diligrp.etrade.shop.dao.ShopExpressSettingDao;
4 import com.diligrp.etrade.shop.domain.request.ShopExpressCo; 5 import com.diligrp.etrade.shop.domain.request.ShopExpressCo;
5 import com.diligrp.etrade.shop.domain.request.ShopExpressQueryCo; 6 import com.diligrp.etrade.shop.domain.request.ShopExpressQueryCo;
@@ -33,7 +34,7 @@ public class ShopExpressSettingServiceImpl implements ShopExpressSettingService @@ -33,7 +34,7 @@ public class ShopExpressSettingServiceImpl implements ShopExpressSettingService
33 ShopExpressVo shopExpressVo = shopExpressSettingDao.selectByShopId(shopExpressCo.getShopId()); 34 ShopExpressVo shopExpressVo = shopExpressSettingDao.selectByShopId(shopExpressCo.getShopId());
34 if (shopExpressVo == null) { 35 if (shopExpressVo == null) {
35 ShopExpressSetting shopExpressSetting = shopExpressCo.toShopExpressSetting(); 36 ShopExpressSetting shopExpressSetting = shopExpressCo.toShopExpressSetting();
36 - shopExpressSetting.setPeriod(24); 37 + shopExpressSetting.setPeriod(Constant.SHOP_EXPRESS_FREE_TIME_PERIOD);
37 int insert = shopExpressSettingDao.insert(shopExpressSetting); 38 int insert = shopExpressSettingDao.insert(shopExpressSetting);
38 return insert > 0; 39 return insert > 0;
39 } else { 40 } else {
etrade-shop/src/main/java/com/diligrp/etrade/shop/type/ExpressCondition.java 0 → 100644
  1 +package com.diligrp.etrade.shop.type;
  2 +
  3 +import com.diligrp.etrade.core.type.IEnumType;
  4 +
  5 +import java.util.Arrays;
  6 +import java.util.List;
  7 +import java.util.Optional;
  8 +import java.util.stream.Stream;
  9 +
  10 +public enum ExpressCondition implements IEnumType {
  11 +
  12 +
  13 + MONEY("满金额包邮", 1),
  14 + LOGIC("满逻辑包邮", 2),
  15 +
  16 + ;
  17 + private final String name;
  18 + private final int code;
  19 +
  20 + private ExpressCondition(String name, int code) {
  21 + this.name = name;
  22 + this.code = code;
  23 + }
  24 +
  25 + public static Optional<ExpressCondition> get(int code) {
  26 + Stream<ExpressCondition> stream = Arrays.stream(values());
  27 + return stream.filter((gender) -> {
  28 + return gender.getCode() == code;
  29 + }).findFirst();
  30 + }
  31 +
  32 + public static String getName(int code) {
  33 + Stream<ExpressCondition> stream = Arrays.stream(values());
  34 + Optional<String> result = stream.filter((gender) -> {
  35 + return gender.getCode() == code;
  36 + }).map(ExpressCondition::getName).findFirst();
  37 + return result.isPresent() ? (String) result.get() : null;
  38 + }
  39 +
  40 + public static List<ExpressCondition> getList() {
  41 + return Arrays.asList(values());
  42 + }
  43 +
  44 + public String getName() {
  45 + return this.name;
  46 + }
  47 +
  48 + public int getCode() {
  49 + return this.code;
  50 + }
  51 +
  52 + public String toString() {
  53 + return this.name;
  54 + }
  55 +}
0 \ No newline at end of file 56 \ No newline at end of file
etrade-shop/src/main/java/com/diligrp/etrade/shop/type/ExpressType.java 0 → 100644
  1 +package com.diligrp.etrade.shop.type;
  2 +
  3 +import com.diligrp.etrade.core.type.IEnumType;
  4 +
  5 +import java.util.Arrays;
  6 +import java.util.List;
  7 +import java.util.Optional;
  8 +import java.util.stream.Stream;
  9 +
  10 +public enum ExpressType implements IEnumType {
  11 +
  12 +
  13 + PICK_UP("到店自提", 1),
  14 + DELIVERY("物流配送", 2),
  15 +
  16 + ;
  17 + private final String name;
  18 + private final int code;
  19 +
  20 + private ExpressType(String name, int code) {
  21 + this.name = name;
  22 + this.code = code;
  23 + }
  24 +
  25 + public static Optional<ExpressType> get(int code) {
  26 + Stream<ExpressType> stream = Arrays.stream(values());
  27 + return stream.filter((gender) -> {
  28 + return gender.getCode() == code;
  29 + }).findFirst();
  30 + }
  31 +
  32 + public static String getName(int code) {
  33 + Stream<ExpressType> stream = Arrays.stream(values());
  34 + Optional<String> result = stream.filter((gender) -> {
  35 + return gender.getCode() == code;
  36 + }).map(ExpressType::getName).findFirst();
  37 + return result.isPresent() ? (String) result.get() : null;
  38 + }
  39 +
  40 + public static List<ExpressType> getList() {
  41 + return Arrays.asList(values());
  42 + }
  43 +
  44 + public String getName() {
  45 + return this.name;
  46 + }
  47 +
  48 + public int getCode() {
  49 + return this.code;
  50 + }
  51 +
  52 + public String toString() {
  53 + return this.name;
  54 + }
  55 +}
0 \ No newline at end of file 56 \ No newline at end of file
etrade-shop/src/main/resources/com/diligrp/etrade/dao/mapper/ShopExpressSettingDao.xml
@@ -44,11 +44,8 @@ @@ -44,11 +44,8 @@
44 <update id="update" parameterType="com.diligrp.etrade.shop.model.ShopExpressSetting"> 44 <update id="update" parameterType="com.diligrp.etrade.shop.model.ShopExpressSetting">
45 update shop_express_setting 45 update shop_express_setting
46 <set> 46 <set>
47 - <if test="shopId != null">  
48 - shop_id = #{shopId,jdbcType=BIGINT},  
49 - </if>  
50 <if test="type != null"> 47 <if test="type != null">
51 - `type` = #{type,jdbcType=TINYINT}, 48 + `type` = #{type,jdbcType=OTHER},
52 </if> 49 </if>
53 <if test="fee != null"> 50 <if test="fee != null">
54 fee = #{fee,jdbcType=DECIMAL}, 51 fee = #{fee,jdbcType=DECIMAL},
@@ -65,12 +62,6 @@ @@ -65,12 +62,6 @@
65 <if test="period != null"> 62 <if test="period != null">
66 period = #{period,jdbcType=INTEGER}, 63 period = #{period,jdbcType=INTEGER},
67 </if> 64 </if>
68 - <if test="creater != null">  
69 - creater = #{creater,jdbcType=VARCHAR},  
70 - </if>  
71 - <if test="createrId != null">  
72 - creater_id = #{createrId,jdbcType=BIGINT},  
73 - </if>  
74 <if test="modifier != null"> 65 <if test="modifier != null">
75 modifier = #{modifier,jdbcType=VARCHAR}, 66 modifier = #{modifier,jdbcType=VARCHAR},
76 </if> 67 </if>
@@ -78,7 +69,7 @@ @@ -78,7 +69,7 @@
78 modifier_id = #{modifierId,jdbcType=BIGINT}, 69 modifier_id = #{modifierId,jdbcType=BIGINT},
79 </if> 70 </if>
80 </set> 71 </set>
81 - where id = #{id,jdbcType=BIGINT} 72 + where shop_id = #{shopId,jdbcType=BIGINT}
82 </update> 73 </update>
83 74
84 </mapper> 75 </mapper>
85 \ No newline at end of file 76 \ No newline at end of file