Browse Source

[商户商铺][商铺][添加ShopNumber惟一约束]

release_toaliyun_real
gongbiao 7 years ago
parent
commit
ed28d31124
4 changed files with 33 additions and 1 deletions
  1. +11
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java
  2. +2
    -0
      mallinkService/src/main/java/com/simple/service/WxShopService.java
  3. +4
    -0
      mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java
  4. +16
    -1
      mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java

+ 11
- 0
mallinkAdmin/src/main/java/com/simple/controller/WxShopController.java View File

@@ -83,5 +83,16 @@ public class WxShopController extends BaseController {
return wxShopService.getMerchantShopByShopId(getTenantId(), shopId);
}

@ApiOperation("查询商铺号是否存在")
@GetMapping("hasShopNumber")

@ApiImplicitParams({
@ApiImplicitParam(name = "shopNumber", value = "shopNumber", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query")})
public ResultData hasShopNumber(String shopNumber,Long id) {
return wxShopService.hasShopNumber(getTenantId(), shopNumber,id);
}



}

+ 2
- 0
mallinkService/src/main/java/com/simple/service/WxShopService.java View File

@@ -46,4 +46,6 @@ public interface WxShopService {

ResultData getMerchantShopByShopId(String tenantId, String shopId);

ResultData hasShopNumber(String tenantId, String shopNumber, Long id);

}

+ 4
- 0
mallinkService/src/main/java/com/simple/service/impl/WxMerchantServiceImpl.java View File

@@ -334,6 +334,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {
if(paycount==1){//12
WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setId(idWorker.nextId());
wxBillRent.setShopId(wxshop.getId());
wxBillRent.setPayStatus(0);
wxBillRent.setPay(new BigDecimal(0));
wxBillRent.setTenantId(wxshop.getTenantId());
@@ -365,6 +366,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setId(idWorker.nextId());
wxBillRent.setShopId(wxshop.getId());
wxBillRent.setPayStatus(0);
wxBillRent.setPay(new BigDecimal(0));
wxBillRent.setTenantId(wxshop.getTenantId());
@@ -397,6 +399,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setId(idWorker.nextId());
wxBillRent.setShopId(wxshop.getId());
wxBillRent.setPayStatus(0);
wxBillRent.setPay(new BigDecimal(0));
wxBillRent.setTenantId(wxshop.getTenantId());
@@ -428,6 +431,7 @@ public class WxMerchantServiceImpl implements WxMerchantService {

WxBillRent wxBillRent = new WxBillRent();
wxBillRent.setId(idWorker.nextId());
wxBillRent.setShopId(wxshop.getId());
wxBillRent.setPayStatus(0);
wxBillRent.setPay(new BigDecimal(0));
wxBillRent.setTenantId(wxshop.getTenantId());


+ 16
- 1
mallinkService/src/main/java/com/simple/service/impl/WxShopServiceImpl.java View File

@@ -1,6 +1,8 @@
package com.simple.service.impl;

import java.util.*;
import java.util.stream.Collectors;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.simple.common.ResultData;
@@ -41,7 +43,6 @@ public class WxShopServiceImpl implements WxShopService {
public void saveOrUpdate(WxShop record) {

if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setStatus(0);
@@ -78,5 +79,19 @@ public class WxShopServiceImpl implements WxShopService {
return new ResultData(ResultData.SUCCESS,"",map);
}

@Override
public ResultData hasShopNumber(String tenantId, String shopNumber, Long id) {
WxShop wxShop = new WxShop();
wxShop.setTenantId(tenantId);
wxShop.setShopNumber(shopNumber);
List<WxShop> list = wxShopMapper.findList(wxShop);
if(id!=null){
List<WxShop> collect = list.stream().filter(s -> !s.getId().equals(id)?true:false).collect(Collectors.toList());
return new ResultData(ResultData.SUCCESS,"查询成功",collect.size()>0?true:false);
}

return new ResultData(ResultData.SUCCESS,"查询成功",list.size()>0?true:false);
}


}

Loading…
Cancel
Save