Commit 798a8b4960c50c00fb92df2904d5a40e3543b1f7

Authored by jiangchengyong
1 parent 9c1727e7

店铺update

mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/shop/CreateShopReq.java
1 1 package com.diligrp.mobsite.getway.domain.protocol.shop;
2 2  
3 3 import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
4   -import com.diligrp.mobsite.getway.domain.protocol.Category;
5 4 import io.swagger.annotations.ApiModelProperty;
6 5  
7 6 import java.util.List;
... ... @@ -30,7 +29,7 @@ public class CreateShopReq extends BaseReq {
30 29 private String shopLogo;
31 30  
32 31 @ApiModelProperty(value = "主营类目")
33   - private List<Category> categories;
  32 + private List<Long> categorieIds;
34 33  
35 34  
36 35  
... ... @@ -56,6 +55,9 @@ public class CreateShopReq extends BaseReq {
56 55 @ApiModelProperty(value = "送货时间段")
57 56 private List<String> deliveryTime;
58 57  
  58 + @ApiModelProperty(value = "上货市场")
  59 + private Long marketId;
  60 +
59 61  
60 62  
61 63 public Long getCityCode() {
... ... @@ -90,13 +92,12 @@ public class CreateShopReq extends BaseReq {
90 92 this.shopLogo = shopLogo;
91 93 }
92 94  
93   -
94   - public List<Category> getCategories() {
95   - return categories;
  95 + public List<Long> getCategorieIds() {
  96 + return categorieIds;
96 97 }
97 98  
98   - public void setCategories(List<Category> categories) {
99   - this.categories = categories;
  99 + public void setCategorieIds(List<Long> categorieIds) {
  100 + this.categorieIds = categorieIds;
100 101 }
101 102  
102 103 public Integer getProductDisplayWay() {
... ... @@ -154,4 +155,13 @@ public class CreateShopReq extends BaseReq {
154 155 public void setPhone(String phone) {
155 156 this.phone = phone;
156 157 }
  158 +
  159 + @Override
  160 + public Long getMarketId() {
  161 + return marketId;
  162 + }
  163 +
  164 + public void setMarketId(Long marketId) {
  165 + this.marketId = marketId;
  166 + }
157 167 }
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/shop/CreateShopResp.java
... ... @@ -17,13 +17,13 @@ public class CreateShopResp extends BaseResp {
17 17 * 店铺code
18 18 */
19 19 @ApiModelProperty(value = "店铺分享码" )
20   - private Integer shopAuthCode;
  20 + private Long shopAuthCode;
21 21  
22   - public Integer getShopAuthCode() {
  22 + public Long getShopAuthCode() {
23 23 return shopAuthCode;
24 24 }
25 25  
26   - public void setShopAuthCode(Integer shopAuthCode) {
  26 + public void setShopAuthCode(Long shopAuthCode) {
27 27 this.shopAuthCode = shopAuthCode;
28 28 }
29 29 }
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/shop/GetShopInfoResp.java
1 1 package com.diligrp.mobsite.getway.domain.protocol.shop;
2 2  
3 3 import com.diligrp.mobsite.getway.domain.protocol.BaseResp;
4   -import com.diligrp.mobsite.getway.domain.protocol.Category;
5 4 import io.swagger.annotations.ApiModelProperty;
6 5  
7 6 import java.util.List;
... ... @@ -26,7 +25,7 @@ public class GetShopInfoResp extends BaseResp {
26 25 private String shopLogo;
27 26  
28 27 @ApiModelProperty(value = "主营类目")
29   - private List<Category> categories;
  28 + private List<Long> categories;
30 29  
31 30  
32 31  
... ... @@ -49,10 +48,6 @@ public class GetShopInfoResp extends BaseResp {
49 48 @ApiModelProperty(value = "店铺公告")
50 49 private String shopNotices;
51 50  
52   - @ApiModelProperty(value = "送货时间段")
53   - private List<String> deliveryTime;
54   -
55   -
56 51 public Long getShopId() {
57 52 return shopId;
58 53 }
... ... @@ -94,11 +89,11 @@ public class GetShopInfoResp extends BaseResp {
94 89 }
95 90  
96 91  
97   - public List<Category> getCategories() {
  92 + public List<Long> getCategories() {
98 93 return categories;
99 94 }
100 95  
101   - public void setCategories(List<Category> categories) {
  96 + public void setCategories(List<Long> categories) {
102 97 this.categories = categories;
103 98 }
104 99  
... ... @@ -134,14 +129,6 @@ public class GetShopInfoResp extends BaseResp {
134 129 this.shopNotices = shopNotices;
135 130 }
136 131  
137   - public List<String> getDeliveryTime() {
138   - return deliveryTime;
139   - }
140   -
141   - public void setDeliveryTime(List<String> deliveryTime) {
142   - this.deliveryTime = deliveryTime;
143   - }
144   -
145 132 public String getShopAddr() {
146 133 return shopAddr;
147 134 }
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/shop/GetShowStyleResp.java
... ... @@ -6,4 +6,4 @@ import com.diligrp.mobsite.getway.domain.base.BaseListResp;
6 6 * Created by xxxzzz on 2016/12/27.
7 7 */
8 8 public class GetShowStyleResp extends BaseListResp {
9 9 -}
  10 +}
10 11 \ No newline at end of file
... ...
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/shop/UpdateShopReq.java
1 1 package com.diligrp.mobsite.getway.domain.protocol.shop;
2 2  
3 3 import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
4   -import com.diligrp.mobsite.getway.domain.protocol.Category;
5 4 import io.swagger.annotations.ApiModelProperty;
6 5  
  6 +import javax.validation.constraints.NotNull;
7 7 import java.util.List;
8 8  
9 9 /**
... ... @@ -17,7 +17,8 @@ public class UpdateShopReq extends BaseReq {
17 17  
18 18  
19 19  
20   - @ApiModelProperty(value = "店铺Id")
  20 + @ApiModelProperty(value = "店铺Id",required = true)
  21 + @NotNull(message="店铺ID不能为空")
21 22 private Long shopId;
22 23  
23 24 @ApiModelProperty(value = "城市code")
... ... @@ -33,7 +34,7 @@ public class UpdateShopReq extends BaseReq {
33 34 private String shopLogo;
34 35  
35 36 @ApiModelProperty(value = "主营类目")
36   - private List<Category> categories;
  37 + private List<Long> categorieIds;
37 38  
38 39  
39 40  
... ... @@ -59,6 +60,9 @@ public class UpdateShopReq extends BaseReq {
59 60 @ApiModelProperty(value = "送货时间段")
60 61 private List<String> deliveryTime;
61 62  
  63 + @ApiModelProperty(value = "上货市场")
  64 + private Long marketId;
  65 +
62 66  
63 67 public Long getShopId() {
64 68 return shopId;
... ... @@ -100,13 +104,12 @@ public class UpdateShopReq extends BaseReq {
100 104 this.shopLogo = shopLogo;
101 105 }
102 106  
103   -
104   - public List<Category> getCategories() {
105   - return categories;
  107 + public List<Long> getCategorieIds() {
  108 + return categorieIds;
106 109 }
107 110  
108   - public void setCategories(List<Category> categories) {
109   - this.categories = categories;
  111 + public void setCategorieIds(List<Long> categorieIds) {
  112 + this.categorieIds = categorieIds;
110 113 }
111 114  
112 115 public Integer getProductDisplayWay() {
... ... @@ -164,4 +167,13 @@ public class UpdateShopReq extends BaseReq {
164 167 public void setPhone(String phone) {
165 168 this.phone = phone;
166 169 }
  170 +
  171 + @Override
  172 + public Long getMarketId() {
  173 + return marketId;
  174 + }
  175 +
  176 + public void setMarketId(Long marketId) {
  177 + this.marketId = marketId;
  178 + }
167 179 }
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/ShopRPC.java
... ... @@ -4,12 +4,6 @@ import com.b2c.myapp.common.api.shop.input.ShopListInput;
4 4 import com.b2c.myapp.common.api.shop.input.ShopSaveInput;
5 5 import com.b2c.myapp.common.api.shop.input.ShopUpdateInput;
6 6 import com.b2c.myapp.common.api.shop.output.ShopOutput;
7   -import com.b2c.myapp.common.utils.BaseOutput;
8   -import com.diligrp.mobsite.getway.domain.protocol.ProductCategory;
9   -import com.diligrp.mobsite.getway.domain.protocol.ShopIntroduction;
10   -import com.diligrp.mobsite.getway.domain.protocol.shop.model.ShopInfo;
11   -
12   -import java.util.List;
13 7  
14 8 /**
15 9 * <BDescription</B <br /
... ... @@ -17,7 +11,7 @@ import java.util.List;
17 11 * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /
18 12 * <BCompany</B 地利集团
19 13 * @createTime 2015年6月10日 下午1:40:21
20   - * @author zhangshirui
  14 + * @author jcy
21 15 */
22 16 public interface ShopRPC {
23 17  
... ... @@ -25,11 +19,11 @@ public interface ShopRPC {
25 19 /**
26 20 * @comment 创建店铺
27 21 * @param shopSaveInput 店铺基本信息
28   - * @return Integer
  22 + * @return ShopOutput
29 23 * @author kelan
30 24 * @time 2016/11/29 19:03
31 25 */
32   - public Integer createShopInfo(ShopSaveInput shopSaveInput);
  26 + public ShopOutput createShopInfo(ShopSaveInput shopSaveInput);
33 27 /**
34 28 * @comment 通过卖家id获取店铺信息
35 29 * @param sellerId 卖家id
... ...
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/ShopRPCImpl.java
... ... @@ -8,16 +8,12 @@ import com.b2c.myapp.common.utils.BaseOutput;
8 8 import com.b2c.myapp.sdk.MyAppClient;
9 9 import com.diligrp.mobsite.getway.domain.common.ResultCode;
10 10 import com.diligrp.mobsite.getway.domain.except.ServiceException;
11   -import com.diligrp.mobsite.getway.domain.protocol.ProductCategory;
12   -import com.diligrp.mobsite.getway.domain.protocol.ShopIntroduction;
13   -import com.diligrp.mobsite.getway.domain.protocol.shop.model.ShopInfo;
14 11 import com.diligrp.mobsite.getway.rpc.ShopRPC;
15 12 import org.slf4j.Logger;
16 13 import org.slf4j.LoggerFactory;
17 14 import org.springframework.stereotype.Service;
18 15  
19 16 import javax.annotation.Resource;
20   -import java.util.List;
21 17  
22 18 /**
23 19 * <B>Description</B> <br />
... ... @@ -36,14 +32,14 @@ public class ShopRPCImpl implements ShopRPC {
36 32 private MyAppClient myAppClient;
37 33 /**
38 34 * @param shopSaveInput 店铺基本信息
39   - * @return Integer
  35 + * @return ShopOutput
40 36 * @comment 创建店铺
41 37 * @author jiangchengyong
42 38 * @time 2016/11/29 19:03
43 39 */
44 40 @Override
45   - public Integer createShopInfo(ShopSaveInput shopSaveInput) {
46   - BaseOutput<Integer> output = null;
  41 + public ShopOutput createShopInfo(ShopSaveInput shopSaveInput) {
  42 + BaseOutput<ShopOutput> output = null;
47 43 try{
48 44 output = myAppClient.getShopInfoService().createShopInfo(shopSaveInput);
49 45 if(output.getCode().equals(200)){
... ...
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/SellerShopService.java
... ... @@ -27,5 +27,5 @@ public interface SellerShopService {
27 27  
28 28 DelShopDeliveryTimeResp delShopDeliveryTime(DelShopDeliveryTimeReq req);
29 29  
30   - CreateShopResp updateShop(UpdateShopReq req);
  30 + UpdateShopResp updateShop(UpdateShopReq req) throws Exception;
31 31 }
... ...
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/impl/SellerShopServiceImpl.java
1 1 package com.diligrp.mobsite.getway.service.seller.impl;
2 2  
  3 +import com.b2c.myapp.common.api.shop.input.ShopSaveInput;
  4 +import com.b2c.myapp.common.api.shop.input.ShopUpdateInput;
  5 +import com.b2c.myapp.common.api.shop.output.ShopOutput;
  6 +import com.diligrp.mobsite.getway.domain.except.ServiceException;
3 7 import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
4 8 import com.diligrp.mobsite.getway.domain.protocol.GetShopDeliveryTimeReq;
5 9 import com.diligrp.mobsite.getway.domain.protocol.GetShopDeliveryTimeResp;
6 10 import com.diligrp.mobsite.getway.domain.protocol.shop.*;
  11 +import com.diligrp.mobsite.getway.rpc.ShopRPC;
7 12 import com.diligrp.mobsite.getway.service.seller.SellerShopService;
  13 +import org.apache.commons.lang.StringUtils;
  14 +import org.springframework.beans.factory.annotation.Autowired;
8 15 import org.springframework.stereotype.Service;
9 16  
  17 +import java.util.ArrayList;
  18 +import java.util.List;
  19 +
10 20  
11 21 /**
12 22 * <B>Description</B> 卖家用户信息 <br />
... ... @@ -18,15 +28,50 @@ import org.springframework.stereotype.Service;
18 28 */
19 29 @Service
20 30 public class SellerShopServiceImpl implements SellerShopService {
  31 + @Autowired
  32 + private ShopRPC shopRPC;
21 33  
22 34 @Override
23 35 public CreateShopResp createShop(CreateShopReq req) {
24   - return null;
  36 + ShopSaveInput shopSaveInput = new ShopSaveInput();
  37 + shopSaveInput.setAddressId(req.getCityCode());
  38 + shopSaveInput.setAddressDetail(req.getShopAddr());
  39 + shopSaveInput.setMarketId(req.getMarketId());
  40 + shopSaveInput.setSellerId(req.getToken().getUserId());
  41 + shopSaveInput.setServiceTel(req.getPhone());
  42 + shopSaveInput.setShopLogo(req.getShopLogo());
  43 + shopSaveInput.setShopName(req.getShopName());
  44 + shopSaveInput.setBusinessCategoryIds(StringUtils.join(req.getCategorieIds(),","));
  45 + ShopOutput shopOutput = shopRPC.createShopInfo(shopSaveInput);
  46 +
  47 + CreateShopResp createShopResp = new CreateShopResp();
  48 + createShopResp.setShopAuthCode(shopOutput.getPromoCode());
  49 + return createShopResp;
25 50 }
26 51  
27 52 @Override
28 53 public GetShopInfoResp getShopInfo(BaseReq req) {
29   - return null;
  54 + GetShopInfoResp getShopInfoResp = new GetShopInfoResp();
  55 + ShopOutput shopOutput = shopRPC.getShopBySellerId(req.getToken().getUserId());
  56 + getShopInfoResp.setShopName(shopOutput.getShopName());
  57 + getShopInfoResp.setShopLogo(shopOutput.getShopLogo());
  58 + String[] categoryIds = shopOutput.getBusinessCategoryIds().split(",");
  59 + List<Long> categoryList = new ArrayList<>();
  60 + for (String categoryId:categoryIds
  61 + ) {
  62 + categoryList.add(Long.valueOf(categoryId));
  63 + }
  64 + getShopInfoResp.setCategories(categoryList);
  65 + getShopInfoResp.setCityCode(shopOutput.getAddressId());
  66 + getShopInfoResp.setCityName(shopOutput.getAddressText());
  67 + getShopInfoResp.setFreeShippingPrice(shopOutput.getFreeShippingPrice());
  68 + getShopInfoResp.setPhone(shopOutput.getServiceTel());
  69 + getShopInfoResp.setPostage(shopOutput.getPostage());
  70 + getShopInfoResp.setProductDisplayWay(shopOutput.getProductDisplayWay());
  71 + getShopInfoResp.setShopAddr(shopOutput.getAddressDetail());
  72 + getShopInfoResp.setShopId(shopOutput.getId());
  73 + getShopInfoResp.setShopNotices(shopOutput.getShopNotices());
  74 + return getShopInfoResp;
30 75 }
31 76  
32 77 @Override
... ... @@ -50,7 +95,21 @@ public class SellerShopServiceImpl implements SellerShopService {
50 95 }
51 96  
52 97 @Override
53   - public CreateShopResp updateShop(UpdateShopReq req) {
54   - return null;
  98 + public UpdateShopResp updateShop(UpdateShopReq req) {
  99 + UpdateShopResp updateShopResp = new UpdateShopResp();
  100 + ShopUpdateInput shopUpdateInput = new ShopUpdateInput();
  101 + shopUpdateInput.setAddressId(req.getCityCode());
  102 + shopUpdateInput.setAddressDetail(req.getShopAddr());
  103 + shopUpdateInput.setMarketId(req.getMarketId());
  104 + shopUpdateInput.setSellerId(req.getToken().getUserId());
  105 + shopUpdateInput.setServiceTel(req.getPhone());
  106 + shopUpdateInput.setShopLogo(req.getShopLogo());
  107 + shopUpdateInput.setShopName(req.getShopName());
  108 + shopUpdateInput.setBusinessCategoryIds(StringUtils.join(req.getCategorieIds(),","));
  109 + Boolean result = shopRPC.modifyShopBasicInfo(shopUpdateInput);
  110 + if(!result){
  111 + throw new ServiceException("修改店铺信息失败");
  112 + }
  113 + return updateShopResp;
55 114 }
56 115 }
... ...
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/seller/shop/SellerShopController.java
... ... @@ -6,6 +6,7 @@ import com.diligrp.mobsite.getway.domain.protocol.GetShopDeliveryTimeResp;
6 6 import com.diligrp.mobsite.getway.domain.protocol.shop.*;
7 7 import com.diligrp.mobsite.getway.service.seller.SellerShopService;
8 8 import com.diligrp.mobsite.getway.web.api.base.BaseApiController;
  9 +import com.diligrp.mobsite.getway.web.utils.BeanValidator;
9 10 import io.swagger.annotations.Api;
10 11 import io.swagger.annotations.ApiOperation;
11 12 import org.slf4j.Logger;
... ... @@ -24,7 +25,7 @@ import javax.annotation.Resource;
24 25 @Controller
25 26 @RequestMapping("/mobsiteApp/seller/shop")
26 27 @Api(value = "/mobsiteApp-shop-seller", description = "店铺接口-卖家")
27   -public class SellerShopController extends BaseApiController{
  28 +public class SellerShopController extends BaseApiController {
28 29  
29 30 private Logger log = LoggerFactory.getLogger(getClass());
30 31 @Resource
... ... @@ -40,7 +41,7 @@ public class SellerShopController extends BaseApiController{
40 41 public void createShop(@RequestBody CreateShopReq temp) {
41 42 CreateShopReq req = getRequest(CreateShopReq.class);
42 43 try {
43   - //BeanValidator.validator(req);
  44 + BeanValidator.validator(req);
44 45 CreateShopResp resp = sellerShopService.createShop(req);
45 46 sendSuccessResp(resp);
46 47 }
... ... @@ -60,8 +61,8 @@ public class SellerShopController extends BaseApiController{
60 61 public void updateShop(@RequestBody UpdateShopReq temp) {
61 62 UpdateShopReq req = getRequest(UpdateShopReq.class);
62 63 try {
63   - //BeanValidator.validator(req);
64   - CreateShopResp resp = sellerShopService.updateShop(req);
  64 + BeanValidator.validator(req);
  65 + UpdateShopResp resp = sellerShopService.updateShop(req);
65 66 sendSuccessResp(resp);
66 67 }
67 68 catch(Exception e) {
... ... @@ -81,7 +82,6 @@ public class SellerShopController extends BaseApiController{
81 82 public void getShopInfo() {
82 83 BaseReq req = getRequest(BaseReq.class);
83 84 try {
84   - //BeanValidator.validator(req);
85 85 GetShopInfoResp resp = sellerShopService.getShopInfo(req);
86 86 sendSuccessResp(resp);
87 87 }catch(Exception e) {
... ...