店铺配置
This commit is contained in:
parent
d7c8581bdd
commit
6ef91e7506
|
@ -21,16 +21,12 @@ public class StoreBO extends Store {
|
||||||
bo.setAddress(getAddress());
|
bo.setAddress(getAddress());
|
||||||
bo.setLng(getLng());
|
bo.setLng(getLng());
|
||||||
bo.setLat(getLat());
|
bo.setLat(getLat());
|
||||||
bo.setBusinessTimeStart(getBusinessTimeStart());
|
|
||||||
bo.setBusinessTimeEnd(getBusinessTimeEnd());
|
|
||||||
bo.setProvince(getProvince());
|
bo.setProvince(getProvince());
|
||||||
bo.setCity(getCity());
|
bo.setCity(getCity());
|
||||||
bo.setCounty(getCounty());
|
bo.setCounty(getCounty());
|
||||||
bo.setType(getType());
|
bo.setType(getType());
|
||||||
bo.setContactName(getContactName());
|
bo.setContactName(getContactName());
|
||||||
bo.setContactMobile(getContactMobile());
|
bo.setContactMobile(getContactMobile());
|
||||||
bo.setShow(getShow());
|
|
||||||
bo.setUseOutTime(getUseOutTime());
|
|
||||||
return bo;
|
return bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,4 +104,18 @@ public class StoreBO extends Store {
|
||||||
bo.setUseOutTime(getUseOutTime());
|
bo.setUseOutTime(getUseOutTime());
|
||||||
return bo;
|
return bo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户配置店铺
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public StoreBO filterConfigByApp() {
|
||||||
|
StoreBO bo = new StoreBO();
|
||||||
|
bo.setStoreId(getStoreId());
|
||||||
|
bo.setBusinessTimeStart(getBusinessTimeStart());
|
||||||
|
bo.setBusinessTimeEnd(getBusinessTimeEnd());
|
||||||
|
bo.setShow(getShow());
|
||||||
|
bo.setUseOutTime(getUseOutTime());
|
||||||
|
return bo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.ruoyi.ss.store.service;
|
||||||
|
|
||||||
import com.ruoyi.common.core.domain.ValidateResult;
|
import com.ruoyi.common.core.domain.ValidateResult;
|
||||||
import com.ruoyi.ss.store.domain.Store;
|
import com.ruoyi.ss.store.domain.Store;
|
||||||
|
import com.ruoyi.ss.store.domain.StoreBO;
|
||||||
import com.ruoyi.ss.store.domain.StoreVo;
|
import com.ruoyi.ss.store.domain.StoreVo;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
@ -98,4 +99,9 @@ public interface StoreValidator {
|
||||||
* 判断是否在营业时间内
|
* 判断是否在营业时间内
|
||||||
*/
|
*/
|
||||||
boolean isBusinessTime(StoreVo store, LocalTime time);
|
boolean isBusinessTime(StoreVo store, LocalTime time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后校验
|
||||||
|
*/
|
||||||
|
void afterCheck(StoreVo vo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.ruoyi.ss.store.domain.enums.StoreStatus;
|
||||||
import com.ruoyi.ss.store.mapper.StoreMapper;
|
import com.ruoyi.ss.store.mapper.StoreMapper;
|
||||||
import com.ruoyi.ss.store.service.StoreAssembler;
|
import com.ruoyi.ss.store.service.StoreAssembler;
|
||||||
import com.ruoyi.ss.store.service.StoreService;
|
import com.ruoyi.ss.store.service.StoreService;
|
||||||
|
import com.ruoyi.ss.store.service.StoreValidator;
|
||||||
import com.ruoyi.ss.storeApply.domain.enums.StoreApplyType;
|
import com.ruoyi.ss.storeApply.domain.enums.StoreApplyType;
|
||||||
import com.ruoyi.ss.storeApply.service.StoreApplyConverter;
|
import com.ruoyi.ss.storeApply.service.StoreApplyConverter;
|
||||||
import com.ruoyi.ss.storeApply.service.StoreApplyService;
|
import com.ruoyi.ss.storeApply.service.StoreApplyService;
|
||||||
|
@ -56,6 +57,9 @@ public class StoreServiceImpl implements StoreService
|
||||||
@Autowired
|
@Autowired
|
||||||
private StoreApplyConverter storeApplyConverter;
|
private StoreApplyConverter storeApplyConverter;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StoreValidator storeValidator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询店铺
|
* 查询店铺
|
||||||
*
|
*
|
||||||
|
@ -97,6 +101,10 @@ public class StoreServiceImpl implements StoreService
|
||||||
int i = storeMapper.insertSmStore(store);
|
int i = storeMapper.insertSmStore(store);
|
||||||
ServiceUtil.assertion(i != 1, "新增店铺失败");
|
ServiceUtil.assertion(i != 1, "新增店铺失败");
|
||||||
|
|
||||||
|
// 后校验
|
||||||
|
StoreVo vo = this.selectSmStoreById(store.getStoreId());
|
||||||
|
storeValidator.afterCheck(vo);
|
||||||
|
|
||||||
// 如果没有默认店铺,则将其设为默认店铺
|
// 如果没有默认店铺,则将其设为默认店铺
|
||||||
if (this.selectDefaultStore(store.getUserId()) == null) {
|
if (this.selectDefaultStore(store.getUserId()) == null) {
|
||||||
this.setDefault(store.getUserId(), store.getStoreId());
|
this.setDefault(store.getUserId(), store.getStoreId());
|
||||||
|
@ -117,7 +125,20 @@ public class StoreServiceImpl implements StoreService
|
||||||
{
|
{
|
||||||
store.setUpdateTime(DateUtils.getNowDate());
|
store.setUpdateTime(DateUtils.getNowDate());
|
||||||
store.setUpdateBy(SecurityUtils.getUsername());
|
store.setUpdateBy(SecurityUtils.getUsername());
|
||||||
return storeMapper.updateSmStore(store);
|
|
||||||
|
Integer result = transactionTemplate.execute(status -> {
|
||||||
|
// 更新
|
||||||
|
int update = storeMapper.updateSmStore(store);
|
||||||
|
ServiceUtil.assertion(update != 1, "修改店铺失败,请刷新后重试");
|
||||||
|
|
||||||
|
// 后校验
|
||||||
|
StoreVo vo = this.selectSmStoreById(store.getStoreId());
|
||||||
|
storeValidator.afterCheck(vo);
|
||||||
|
|
||||||
|
return update;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result == null ? 0 : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.ruoyi.ss.store.service.impl;
|
||||||
import com.ruoyi.common.core.domain.BaseValidator;
|
import com.ruoyi.common.core.domain.BaseValidator;
|
||||||
import com.ruoyi.common.core.domain.ValidateResult;
|
import com.ruoyi.common.core.domain.ValidateResult;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.common.utils.ServiceUtil;
|
||||||
import com.ruoyi.common.utils.collection.CollectionUtils;
|
import com.ruoyi.common.utils.collection.CollectionUtils;
|
||||||
import com.ruoyi.ss.device.domain.DeviceQuery;
|
import com.ruoyi.ss.device.domain.DeviceQuery;
|
||||||
import com.ruoyi.ss.device.service.DeviceService;
|
import com.ruoyi.ss.device.service.DeviceService;
|
||||||
|
@ -328,6 +329,16 @@ public class StoreValidatorImpl extends BaseValidator implements StoreValidator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterCheck(StoreVo vo) {
|
||||||
|
if (vo == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServiceUtil.assertion(this.validateBusinessTime(vo.getBusinessTimeStart(), vo.getBusinessTimeEnd()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验时间是符合规则
|
* 校验时间是符合规则
|
||||||
|
|
|
@ -68,11 +68,26 @@ public class AppStoreController extends BaseController {
|
||||||
@ApiOperation("申请修改店铺信息")
|
@ApiOperation("申请修改店铺信息")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult edit(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
|
public AjaxResult edit(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
|
||||||
|
StoreVo store = storeService.selectSmStoreById(data.getStoreId());
|
||||||
|
if (!storeValidator.isStoreBelongUser(store, getUserId())) {
|
||||||
|
return error("这不是您的店铺,无法修改");
|
||||||
|
}
|
||||||
data = data.filterUpdateByApp();
|
data = data.filterUpdateByApp();
|
||||||
ServiceUtil.assertion(storeValidator.preUpdateByApp(data));
|
ServiceUtil.assertion(storeValidator.preUpdateByApp(data));
|
||||||
return toAjax(storeService.updateApply(data));
|
return toAjax(storeService.updateApply(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("修改店铺配置")
|
||||||
|
@PutMapping("/config")
|
||||||
|
public AjaxResult configStore(@RequestBody @Validated(ValidGroup.FrontUpdate.class) StoreBO data) {
|
||||||
|
StoreVo store = storeService.selectSmStoreById(data.getStoreId());
|
||||||
|
if (!storeValidator.isStoreBelongUser(store, getUserId())) {
|
||||||
|
return error("这不是您的店铺,无法修改");
|
||||||
|
}
|
||||||
|
data = data.filterConfigByApp();
|
||||||
|
return toAjax(storeService.updateSmStore(data));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除店铺信息
|
* 删除店铺信息
|
||||||
* @param storeId
|
* @param storeId
|
||||||
|
|
Loading…
Reference in New Issue
Block a user