Commit dcec6f3d4f2ec6ad122a330611c70cbff71529df
1 parent
c60bcbd2
店铺运费设置修改
Showing
6 changed files
with
123 additions
and
12 deletions
etrade-shop/src/main/java/com/diligrp/etrade/shop/constant/Constant.java
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 | 2 | |
3 | 3 | import com.diligrp.etrade.core.util.JsonUtils; |
4 | 4 | import com.diligrp.etrade.shop.model.ShopExpressSetting; |
5 | +import jakarta.validation.constraints.NotNull; | |
6 | +import jakarta.validation.constraints.Size; | |
5 | 7 | import org.springframework.format.annotation.DateTimeFormat; |
6 | 8 | |
7 | 9 | import java.io.Serializable; |
... | ... | @@ -26,10 +28,12 @@ public class ShopExpressCo implements Serializable { |
26 | 28 | /** |
27 | 29 | * 配送方式 |
28 | 30 | */ |
31 | + @Size(min = 1, message = "至少选择一种配送方式!") | |
29 | 32 | private List<Integer> type; |
30 | 33 | /** |
31 | 34 | * 固定运费 |
32 | 35 | */ |
36 | + @NotNull(message = "fee should not be null") | |
33 | 37 | private BigDecimal fee; |
34 | 38 | /** |
35 | 39 | * 包邮条件 | ... | ... |
etrade-shop/src/main/java/com/diligrp/etrade/shop/service/impl/ShopExpressSettingServiceImpl.java
1 | 1 | package com.diligrp.etrade.shop.service.impl; |
2 | 2 | |
3 | +import com.diligrp.etrade.shop.constant.Constant; | |
3 | 4 | import com.diligrp.etrade.shop.dao.ShopExpressSettingDao; |
4 | 5 | import com.diligrp.etrade.shop.domain.request.ShopExpressCo; |
5 | 6 | import com.diligrp.etrade.shop.domain.request.ShopExpressQueryCo; |
... | ... | @@ -33,7 +34,7 @@ public class ShopExpressSettingServiceImpl implements ShopExpressSettingService |
33 | 34 | ShopExpressVo shopExpressVo = shopExpressSettingDao.selectByShopId(shopExpressCo.getShopId()); |
34 | 35 | if (shopExpressVo == null) { |
35 | 36 | ShopExpressSetting shopExpressSetting = shopExpressCo.toShopExpressSetting(); |
36 | - shopExpressSetting.setPeriod(24); | |
37 | + shopExpressSetting.setPeriod(Constant.SHOP_EXPRESS_FREE_TIME_PERIOD); | |
37 | 38 | int insert = shopExpressSettingDao.insert(shopExpressSetting); |
38 | 39 | return insert > 0; |
39 | 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 | 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 | 56 | \ No newline at end of file | ... | ... |
etrade-shop/src/main/resources/com/diligrp/etrade/dao/mapper/ShopExpressSettingDao.xml
... | ... | @@ -44,11 +44,8 @@ |
44 | 44 | <update id="update" parameterType="com.diligrp.etrade.shop.model.ShopExpressSetting"> |
45 | 45 | update shop_express_setting |
46 | 46 | <set> |
47 | - <if test="shopId != null"> | |
48 | - shop_id = #{shopId,jdbcType=BIGINT}, | |
49 | - </if> | |
50 | 47 | <if test="type != null"> |
51 | - `type` = #{type,jdbcType=TINYINT}, | |
48 | + `type` = #{type,jdbcType=OTHER}, | |
52 | 49 | </if> |
53 | 50 | <if test="fee != null"> |
54 | 51 | fee = #{fee,jdbcType=DECIMAL}, |
... | ... | @@ -65,12 +62,6 @@ |
65 | 62 | <if test="period != null"> |
66 | 63 | period = #{period,jdbcType=INTEGER}, |
67 | 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 | 65 | <if test="modifier != null"> |
75 | 66 | modifier = #{modifier,jdbcType=VARCHAR}, |
76 | 67 | </if> |
... | ... | @@ -78,7 +69,7 @@ |
78 | 69 | modifier_id = #{modifierId,jdbcType=BIGINT}, |
79 | 70 | </if> |
80 | 71 | </set> |
81 | - where id = #{id,jdbcType=BIGINT} | |
72 | + where shop_id = #{shopId,jdbcType=BIGINT} | |
82 | 73 | </update> |
83 | 74 | |
84 | 75 | </mapper> |
85 | 76 | \ No newline at end of file | ... | ... |