|
|
|
|
@@ -14,6 +14,7 @@ import com.czg.validator.group.InsertGroup;
|
|
|
|
|
import com.czg.validator.group.UpdateGroup;
|
|
|
|
|
import com.mybatisflex.core.paginate.Page;
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
*
|
|
|
|
|
* @author ww
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/admin/coupon")
|
|
|
|
|
public class ACouponController {
|
|
|
|
|
@@ -36,7 +38,7 @@ public class ACouponController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("page")
|
|
|
|
|
@OperationLog("优惠券列表-分页")
|
|
|
|
|
@SaAdminCheckPermission("coupon:page")
|
|
|
|
|
// @SaAdminCheckPermission("coupon:page")
|
|
|
|
|
public CzgResult<Page<ShopCouponDTO>> getCouponPage(ShopCouponDTO param) {
|
|
|
|
|
Page<ShopCouponDTO> data = shopCouponService.getCouponPage(param);
|
|
|
|
|
return CzgResult.success(data);
|
|
|
|
|
@@ -49,7 +51,7 @@ public class ACouponController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping("{id}")
|
|
|
|
|
@OperationLog("优惠券-详情")
|
|
|
|
|
@SaAdminCheckPermission("coupon:info")
|
|
|
|
|
// @SaAdminCheckPermission("coupon:info")
|
|
|
|
|
public CzgResult<ShopCouponDTO> getCouponById(@PathVariable("id") Long id) {
|
|
|
|
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
|
|
|
|
ShopCouponDTO data = shopCouponService.getCouponById(id);
|
|
|
|
|
@@ -61,12 +63,13 @@ public class ACouponController {
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping
|
|
|
|
|
@OperationLog("优惠券-新增")
|
|
|
|
|
@SaAdminCheckPermission("coupon:add")
|
|
|
|
|
// @SaAdminCheckPermission("coupon:add")
|
|
|
|
|
public CzgResult<Void> addCoupon(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
|
|
|
|
Long shopId = StpKit.USER.getShopId(0L);
|
|
|
|
|
dto.setShopId(shopId);
|
|
|
|
|
dto.setLeftNum(dto.getGiveNum());
|
|
|
|
|
shopCouponService.addCoupon(dto);
|
|
|
|
|
asyncToBranchShop(dto.getId(),1);
|
|
|
|
|
asyncToBranchShop(dto.getId(), 1);
|
|
|
|
|
return CzgResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -75,12 +78,12 @@ public class ACouponController {
|
|
|
|
|
*/
|
|
|
|
|
@PutMapping
|
|
|
|
|
@OperationLog("优惠券-修改")
|
|
|
|
|
@SaAdminCheckPermission("coupon:update")
|
|
|
|
|
// @SaAdminCheckPermission("coupon:update")
|
|
|
|
|
public CzgResult<Void> updateCoupon(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
|
|
|
|
Long shopId = StpKit.USER.getShopId(0L);
|
|
|
|
|
dto.setShopId(shopId);
|
|
|
|
|
shopCouponService.updateCouponById(dto);
|
|
|
|
|
asyncToBranchShop(dto.getId(),2);
|
|
|
|
|
asyncToBranchShop(dto.getId(), 2);
|
|
|
|
|
return CzgResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -89,18 +92,19 @@ public class ACouponController {
|
|
|
|
|
*/
|
|
|
|
|
@DeleteMapping("{id}")
|
|
|
|
|
@OperationLog("优惠券-删除")
|
|
|
|
|
@SaAdminCheckPermission("prodGroup:delete")
|
|
|
|
|
// @SaAdminCheckPermission("prodGroup:delete")
|
|
|
|
|
public CzgResult<Void> deleteCoupon(@PathVariable("id") Long id) {
|
|
|
|
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
|
|
|
|
shopCouponService.deleteCoupon(id);
|
|
|
|
|
asyncToBranchShop(id,3);
|
|
|
|
|
asyncToBranchShop(id, 3);
|
|
|
|
|
return CzgResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void asyncToBranchShop(Long id,Integer type) {
|
|
|
|
|
private void asyncToBranchShop(Long id, Integer type) {
|
|
|
|
|
long shopId = StpKit.USER.getShopId(0L);
|
|
|
|
|
log.info("优惠券同步,优惠券id:{},类型:{}", id, type);
|
|
|
|
|
ThreadUtil.execAsync(() -> {
|
|
|
|
|
shopSyncService.syncCouponBySourceShop(shopId, id,type);
|
|
|
|
|
shopSyncService.syncCouponBySourceShop(shopId, id, type);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|