|
@@ -25,6 +25,7 @@ import org.springblade.modules.business.service.IShopService;
|
|
|
import org.springblade.modules.business.vo.ShopVO;
|
|
|
import org.springblade.modules.business.wrapper.ShopWrapper;
|
|
|
import org.springblade.modules.system.service.IUserMerchantService;
|
|
|
+import org.springblade.modules.system.vo.UserMerchantVO;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -48,8 +49,21 @@ public class ApiShopController extends BaseController {
|
|
|
@ApiOperationSupport(order = 1)
|
|
|
@ApiOperation(value = "添加门店", notes = "传入shop")
|
|
|
public R<Void> save(@Valid @RequestBody Shop shop) {
|
|
|
- shop.setMerchantId(AuthUtil.getUserId());
|
|
|
- return R.status(iShopService.save(shop));
|
|
|
+
|
|
|
+ if (!isMerchant()) {//子账号添加门店,将门店归与主账号下并给子账号授权
|
|
|
+ UserMerchantVO userMerchantVO = iUserMerchantService.getByUserId(AuthUtil.getUserId());
|
|
|
+ Assert.notNull(userMerchantVO, "请先绑定商户");
|
|
|
+ shop.setMerchantId(userMerchantVO.getId());
|
|
|
+ status(iShopService.save(shop));
|
|
|
+
|
|
|
+ userMerchantVO.setAuthShop(userMerchantVO.getAuthShop()+","+shop.getId());
|
|
|
+ iUserMerchantService.updateById(userMerchantVO);
|
|
|
+ return R.success("添加成功");
|
|
|
+ } else {
|
|
|
+ shop.setMerchantId(AuthUtil.getUserId());
|
|
|
+ return R.status(iShopService.save(shop));
|
|
|
+ }
|
|
|
+
|
|
|
//添加设备门店关联
|
|
|
// List<Facility> facilityList = iFacilityService.lambdaQuery()
|
|
|
// .in(Facility::getId, Func.toLongList(shop.getFacilityIds()))
|