Commit 8b0f3e522d38366091ecf90d7729a97f1cbf0c39
1 parent
74508e5d
买家 卖家注册
Showing
6 changed files
with
44 additions
and
2 deletions
myapp-web/src/main/java/com/b2c/myapp/api/BuyerInfoApi.java
... | ... | @@ -51,7 +51,7 @@ public class BuyerInfoApi extends BaseRestFulApi { |
51 | 51 | CommonUtils.throwDataError(CollectionUtils.isNotEmpty(buyerInfos), ResultCode.USER_REGISTERED,val.getMobilePhone(),"账户已注册"); |
52 | 52 | |
53 | 53 | BuyerInfo buyerInfo = BeanConver.copeBean(val,BuyerInfo.class); |
54 | - buyerInfoService.saveOrUpdate(buyerInfo); | |
54 | + buyerInfoService.register(buyerInfo); | |
55 | 55 | output.setData(BeanConver.copeBean(buyerInfo,BuyerInfoOutput.class)); |
56 | 56 | } catch (Exception e) { |
57 | 57 | handleException(output, e); |
... | ... |
myapp-web/src/main/java/com/b2c/myapp/api/SellerInfoApi.java
... | ... | @@ -51,7 +51,7 @@ public class SellerInfoApi extends BaseRestFulApi { |
51 | 51 | CommonUtils.throwDataError(CollectionUtils.isNotEmpty(sellerInfos), ResultCode.USER_REGISTERED,val.getMobilePhone(),"账户已注册"); |
52 | 52 | |
53 | 53 | SellerInfo sellerInfo = BeanConver.copeBean(val,SellerInfo.class); |
54 | - sellerInfoService.saveOrUpdate(sellerInfo); | |
54 | + sellerInfoService.register(sellerInfo); | |
55 | 55 | output.setData(BeanConver.copeBean(sellerInfo,SellerInfoOutput.class)); |
56 | 56 | } catch (Exception e) { |
57 | 57 | handleException(output, e); |
... | ... |
myapp-web/src/main/java/com/b2c/myapp/service/BuyerInfoService.java
myapp-web/src/main/java/com/b2c/myapp/service/SellerInfoService.java
... | ... | @@ -8,6 +8,13 @@ import com.b2c.myapp.domain.SellerInfo; |
8 | 8 | * @author template |
9 | 9 | */ |
10 | 10 | public interface SellerInfoService extends BaseService<SellerInfo, Long> { |
11 | + | |
12 | + /** | |
13 | + * 注册 | |
14 | + * @param sellerInfo | |
15 | + * @return | |
16 | + */ | |
17 | + SellerInfo register(SellerInfo sellerInfo); | |
11 | 18 | /** |
12 | 19 | * @comment 根据卖家手机号获取卖家信息 |
13 | 20 | * @param mobilePhone 卖家手机号 |
... | ... |
myapp-web/src/main/java/com/b2c/myapp/service/impl/BuyerInfoServiceImpl.java
... | ... | @@ -39,6 +39,19 @@ public class BuyerInfoServiceImpl extends BaseServiceImpl<BuyerInfo, Long> imple |
39 | 39 | return ":buyerInfo"; |
40 | 40 | } |
41 | 41 | |
42 | + @Override | |
43 | + @Transactional | |
44 | + public BuyerInfo register(BuyerInfo buyerInfo) { | |
45 | + if(saveOrUpdate(buyerInfo)>0){ | |
46 | + buyerInfo.setAccountName("buyer_"+buyerInfo.getId()); | |
47 | + } | |
48 | + BuyerInfo buyer = new BuyerInfo(); | |
49 | + buyer.setMobilePhone(buyerInfo.getMobilePhone()); | |
50 | + buyer.setAccountName(buyerInfo.getAccountName()); | |
51 | + update(buyer); | |
52 | + return buyerInfo; | |
53 | + } | |
54 | + | |
42 | 55 | /** |
43 | 56 | * 更新当前绑定的shopId |
44 | 57 | * |
... | ... |
myapp-web/src/main/java/com/b2c/myapp/service/impl/SellerInfoServiceImpl.java
... | ... | @@ -12,6 +12,7 @@ import org.slf4j.Logger; |
12 | 12 | import org.slf4j.LoggerFactory; |
13 | 13 | import org.springframework.beans.factory.annotation.Autowired; |
14 | 14 | import org.springframework.stereotype.Service; |
15 | +import org.springframework.transaction.annotation.Transactional; | |
15 | 16 | |
16 | 17 | import java.util.List; |
17 | 18 | |
... | ... | @@ -35,6 +36,25 @@ public class SellerInfoServiceImpl extends BaseServiceImpl<SellerInfo, Long> imp |
35 | 36 | return ":sellerInfo"; |
36 | 37 | } |
37 | 38 | |
39 | + /** | |
40 | + * 注册 | |
41 | + * | |
42 | + * @param sellerInfo | |
43 | + * @return | |
44 | + */ | |
45 | + @Override | |
46 | + @Transactional | |
47 | + public SellerInfo register(SellerInfo sellerInfo) { | |
48 | + if(saveOrUpdate(sellerInfo)>0){ | |
49 | + sellerInfo.setAccountName("seller_"+sellerInfo.getId()); | |
50 | + } | |
51 | + SellerInfo seller = new SellerInfo(); | |
52 | + seller.setMobilePhone(sellerInfo.getMobilePhone()); | |
53 | + seller.setAccountName(sellerInfo.getAccountName()); | |
54 | + update(seller); | |
55 | + return sellerInfo; | |
56 | + } | |
57 | + | |
38 | 58 | @Override |
39 | 59 | public SellerInfo getSellerInfoByMobilePhone(String mobilePhone) { |
40 | 60 | return null; |
... | ... |