会员 mainShopId
This commit is contained in:
@@ -2,11 +2,10 @@ package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.shopuser.*;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.AShopUserService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.vo.ShopUserFlowVO;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.enums.ShopUserFlowBizEnum;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
@@ -29,7 +28,7 @@ import java.math.BigDecimal;
|
||||
public class ShopUserController {
|
||||
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
private AShopUserService shopUserService;
|
||||
@Resource
|
||||
private ShopUserFlowService shopUserFlowService;
|
||||
|
||||
@@ -43,7 +42,7 @@ public class ShopUserController {
|
||||
@GetMapping("/summary")
|
||||
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
|
||||
public CzgResult<ShopUserSummaryDTO> summary(Integer isVip) {
|
||||
return CzgResult.success(shopUserService.getSummary(StpKit.USER.getUsableShopId(), isVip));
|
||||
return CzgResult.success(shopUserService.getSummary(StpKit.USER.getHeadShopIdBySession(), isVip));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +66,7 @@ public class ShopUserController {
|
||||
@GetMapping("/flow")
|
||||
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
|
||||
public CzgResult<Page<ShopUserFlowVO>> flow(Integer userId, String bizCode, String startTime, String endTime) {
|
||||
return CzgResult.success(shopUserFlowService.pageInfo(StpKit.USER.getUsableShopId(), userId, bizCode, startTime, endTime));
|
||||
return CzgResult.success(shopUserFlowService.pageInfo(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +82,7 @@ public class ShopUserController {
|
||||
@GetMapping("/flow/download")
|
||||
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
|
||||
public void flowDownload(Integer userId, String bizCode, String startTime, String endTime, HttpServletResponse response) throws IOException {
|
||||
shopUserFlowService.flowDownload(StpKit.USER.getUsableShopId(), userId, bizCode, startTime, endTime, response);
|
||||
shopUserFlowService.flowDownload(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime, response);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,7 +124,7 @@ public class ShopUserController {
|
||||
@SaAdminCheckPermission(value = "shopUser:add", name = "店铺用户添加")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
|
||||
return CzgResult.success(shopUserService.add(StpKit.USER.getUsableShopId(), shopUserAddDTO));
|
||||
return CzgResult.success(shopUserService.add(StpKit.USER.getHeadShopIdBySession(), shopUserAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +136,7 @@ public class ShopUserController {
|
||||
@SaAdminCheckPermission(value = "shopUser:edit", name = "店铺用户修改")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) {
|
||||
return CzgResult.success(shopUserService.updateInfo(StpKit.USER.getUsableShopId(), shopUserEditDTO));
|
||||
return CzgResult.success(shopUserService.updateInfo(StpKit.USER.getHeadShopIdBySession(), shopUserEditDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,7 +149,7 @@ public class ShopUserController {
|
||||
@PutMapping("/money")
|
||||
public CzgResult<Boolean> editMoney(@RequestBody @Validated ShopUserMoneyEditDTO shopUserMoneyEditDTO) {
|
||||
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.ADMIN_IN);
|
||||
return CzgResult.success(shopUserService.updateMoney(StpKit.USER.getUsableShopId(), shopUserMoneyEditDTO) > 0L);
|
||||
return CzgResult.success(shopUserService.updateMoney(StpKit.USER.getHeadShopIdBySession(), shopUserMoneyEditDTO) > 0L);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ import com.czg.account.entity.MemberPointsLog;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.ShopUserFlow;
|
||||
import com.czg.account.service.MemberPointsLogService;
|
||||
import com.czg.account.service.PointsExchangeRecordService;
|
||||
import com.czg.account.service.ShopUserFlowService;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UShopUserService;
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
@@ -29,12 +28,10 @@ import org.springframework.web.bind.annotation.*;
|
||||
@RequestMapping("/user/shopUser")
|
||||
public class UShopUserController {
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
private UShopUserService shopUserService;
|
||||
@Resource
|
||||
private ShopUserFlowService shopUserFlowService;
|
||||
@Resource
|
||||
private PointsExchangeRecordService pointsExchangeRecordService;
|
||||
@Resource
|
||||
private MemberPointsLogService memberPointsLogService;
|
||||
|
||||
/**
|
||||
@@ -45,7 +42,7 @@ public class UShopUserController {
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<ShopUserDetailDTO> get(Long shopId) {
|
||||
return CzgResult.success(shopUserService.getInfo(shopId == null ? StpKit.USER.getUsableShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
|
||||
return CzgResult.success(shopUserService.getInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +62,7 @@ public class UShopUserController {
|
||||
*/
|
||||
@GetMapping("/code")
|
||||
public CzgResult<String> code(Long shopId) {
|
||||
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), shopId == null ? StpKit.USER.getUsableShopId() : shopId);
|
||||
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), shopId == null ? StpKit.USER.getShopId() : shopId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +73,7 @@ public class UShopUserController {
|
||||
@PostMapping
|
||||
@Debounce("#shopUserAddDTO.phone")
|
||||
public CzgResult<Boolean> join(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
|
||||
return CzgResult.success(shopUserService.join(StpKit.USER.getUsableShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO));
|
||||
return CzgResult.success(shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +104,7 @@ public class UShopUserController {
|
||||
*/
|
||||
@GetMapping("/pointsRecord")
|
||||
public CzgResult<Page<MemberPointsLog>> getPointsRecord() {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getUserId, StpKit.USER.getLoginIdAsLong()));
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(memberPointsLogService.page(PageUtil.buildPage(), new QueryWrapper().eq(MemberPointsLog::getShopId, StpKit.USER.getShopId())
|
||||
.eq(MemberPointsLog::getShopUserId, shopUser.getId()).orderBy(MemberPointsLog::getId, false)));
|
||||
}
|
||||
@@ -119,13 +116,8 @@ public class UShopUserController {
|
||||
*/
|
||||
@GetMapping("/pointsRecord/detail")
|
||||
public CzgResult<MemberPointsLog> getPointsRecordDetail(@RequestParam Long id) {
|
||||
ShopUser shopUser = shopUserService.getOne(new QueryWrapper().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getUserId, StpKit.USER.getLoginIdAsLong()));
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong());
|
||||
return CzgResult.success(memberPointsLogService.getOne(new QueryWrapper().eq(MemberPointsLog::getShopId, StpKit.USER.getShopId())
|
||||
.eq(MemberPointsLog::getShopUserId, shopUser.getId()).eq(MemberPointsLog::getId, id)));
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,14 +69,4 @@ public class UserAuthorizationController {
|
||||
"shopName", shopInfo.getShopName()
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
* @return 登录信息
|
||||
*/
|
||||
@PostMapping("/test")
|
||||
public CzgResult<String> login(@RequestParam long id) {
|
||||
StpKit.USER.login(id, "2342", null, "", MyStpLogic.LoginType.USER, false, "");
|
||||
return CzgResult.success(StpKit.USER.getTokenValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.annotation.SaStaffCheckPermission;
|
||||
import com.czg.config.RabbitPublisher;
|
||||
import com.czg.exception.CzgException;
|
||||
@@ -49,6 +51,8 @@ public class ProductController {
|
||||
private ShopSyncService shopSyncService;
|
||||
@Resource
|
||||
private UProductService uProductService;
|
||||
@Resource
|
||||
private ShopInfoService shopInfoService;
|
||||
|
||||
/**
|
||||
* 商品-分页
|
||||
@@ -104,7 +108,7 @@ public class ProductController {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
productService.addProduct(dto);
|
||||
asyncToBranchShop(dto.getId());
|
||||
asyncProductToShop(dto.getId());
|
||||
ThreadUtil.execAsync(() -> {
|
||||
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||
});
|
||||
@@ -133,7 +137,7 @@ public class ProductController {
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
dto.setShopId(shopId);
|
||||
productService.updateProduct(dto);
|
||||
asyncToBranchShop(dto.getId());
|
||||
asyncProductToShop(dto.getId());
|
||||
ThreadUtil.execAsync(() -> {
|
||||
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||
});
|
||||
@@ -168,7 +172,7 @@ public class ProductController {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
productService.deleteProduct(shopId, id);
|
||||
asyncToBranchShop(id);
|
||||
asyncProductToShop(id);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
|
||||
});
|
||||
@@ -217,7 +221,7 @@ public class ProductController {
|
||||
//@SaAdminCheckPermission("product:bind")
|
||||
public CzgResult<Void> bindCons(@RequestBody @Validated({DefaultGroup.class}) ProdConsBindDTO param) {
|
||||
prodConsRelationService.saveProdConsRelation(param);
|
||||
asyncToBranchShop2(param.getId());
|
||||
asyncConsProToShop(param.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@@ -229,7 +233,7 @@ public class ProductController {
|
||||
//@SaAdminCheckPermission("product:update")
|
||||
public CzgResult<Void> refundToStock(@RequestBody @Validated({DefaultGroup.class}) ProdRefundToStockParam param) {
|
||||
productService.refundToStock(param);
|
||||
asyncToBranchShop(param.getId());
|
||||
asyncProductToShop(param.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@@ -293,36 +297,34 @@ public class ProductController {
|
||||
//@SaAdminCheckPermission("product:sync")
|
||||
public CzgResult<Void> sync() {
|
||||
long shopId = StpKit.USER.getShopId(0L);
|
||||
long sysUserId = StpKit.USER.getLoginIdAsLong();
|
||||
boolean isEnableSync = StpKit.USER.isEnableSync(shopId);
|
||||
long headShopId = StpKit.USER.getHeadShopId();
|
||||
if (!isEnableSync) {
|
||||
throw new CzgException("主店未开启商品资料同步功能");
|
||||
ShopInfo shopInfo = shopInfoService.getById(shopId);
|
||||
if (shopInfo == null) {
|
||||
throw new CzgException("店铺不存在");
|
||||
}
|
||||
if (shopId == headShopId) {
|
||||
AssertUtil.isNotEqual(shopInfo.getIsEnableProdSync(), 1, "主店未开启商品资料同步功能");
|
||||
|
||||
if (shopInfo.getMainId() == null || shopId == shopInfo.getMainId()) {
|
||||
throw new CzgException("不存在主子店铺关系,无需同步商品信息");
|
||||
}
|
||||
ThreadUtil.execAsync(() -> {
|
||||
shopSyncService.sync(headShopId, shopId, sysUserId);
|
||||
shopSyncService.sync(shopInfo.getMainId(), shopId, shopId);
|
||||
});
|
||||
CzgResult<Void> ret = CzgResult.success();
|
||||
ret.setMsg("操作成功,数据正在后台同步中...");
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void asyncToBranchShop(Long id) {
|
||||
private void asyncProductToShop(Long id) {
|
||||
long shopId = StpKit.USER.getShopId(0L);
|
||||
long sysUserId = StpKit.USER.getLoginIdAsLong();
|
||||
ThreadUtil.execAsync(() -> {
|
||||
shopSyncService.syncProductBySourceShop(shopId, id, sysUserId);
|
||||
shopSyncService.syncProductBySourceShop(shopId, id, shopId);
|
||||
});
|
||||
}
|
||||
|
||||
private void asyncToBranchShop2(Long id) {
|
||||
private void asyncConsProToShop(Long id) {
|
||||
long shopId = StpKit.USER.getShopId(0L);
|
||||
long sysUserId = StpKit.USER.getLoginIdAsLong();
|
||||
ThreadUtil.execAsync(() -> {
|
||||
shopSyncService.syncConsProBySourceShop(shopId, id, sysUserId);
|
||||
shopSyncService.syncConsProBySourceShop(shopId, id, shopId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user