权限 暂时 关闭
This commit is contained in:
parent
449db66e2c
commit
f9aa237f98
|
|
@ -14,6 +14,7 @@ import com.czg.validator.group.InsertGroup;
|
||||||
import com.czg.validator.group.UpdateGroup;
|
import com.czg.validator.group.UpdateGroup;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
*
|
*
|
||||||
* @author ww
|
* @author ww
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/admin/coupon")
|
@RequestMapping("/admin/coupon")
|
||||||
public class ACouponController {
|
public class ACouponController {
|
||||||
|
|
@ -36,7 +38,7 @@ public class ACouponController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@OperationLog("优惠券列表-分页")
|
@OperationLog("优惠券列表-分页")
|
||||||
@SaAdminCheckPermission("coupon:page")
|
// @SaAdminCheckPermission("coupon:page")
|
||||||
public CzgResult<Page<ShopCouponDTO>> getCouponPage(ShopCouponDTO param) {
|
public CzgResult<Page<ShopCouponDTO>> getCouponPage(ShopCouponDTO param) {
|
||||||
Page<ShopCouponDTO> data = shopCouponService.getCouponPage(param);
|
Page<ShopCouponDTO> data = shopCouponService.getCouponPage(param);
|
||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
|
|
@ -49,7 +51,7 @@ public class ACouponController {
|
||||||
*/
|
*/
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@OperationLog("优惠券-详情")
|
@OperationLog("优惠券-详情")
|
||||||
@SaAdminCheckPermission("coupon:info")
|
// @SaAdminCheckPermission("coupon:info")
|
||||||
public CzgResult<ShopCouponDTO> getCouponById(@PathVariable("id") Long id) {
|
public CzgResult<ShopCouponDTO> getCouponById(@PathVariable("id") Long id) {
|
||||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||||
ShopCouponDTO data = shopCouponService.getCouponById(id);
|
ShopCouponDTO data = shopCouponService.getCouponById(id);
|
||||||
|
|
@ -61,12 +63,13 @@ public class ACouponController {
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@OperationLog("优惠券-新增")
|
@OperationLog("优惠券-新增")
|
||||||
@SaAdminCheckPermission("coupon:add")
|
// @SaAdminCheckPermission("coupon:add")
|
||||||
public CzgResult<Void> addCoupon(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
public CzgResult<Void> addCoupon(@RequestBody @Validated({InsertGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
dto.setShopId(shopId);
|
dto.setShopId(shopId);
|
||||||
|
dto.setLeftNum(dto.getGiveNum());
|
||||||
shopCouponService.addCoupon(dto);
|
shopCouponService.addCoupon(dto);
|
||||||
asyncToBranchShop(dto.getId(),1);
|
asyncToBranchShop(dto.getId(), 1);
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,12 +78,12 @@ public class ACouponController {
|
||||||
*/
|
*/
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@OperationLog("优惠券-修改")
|
@OperationLog("优惠券-修改")
|
||||||
@SaAdminCheckPermission("coupon:update")
|
// @SaAdminCheckPermission("coupon:update")
|
||||||
public CzgResult<Void> updateCoupon(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
public CzgResult<Void> updateCoupon(@RequestBody @Validated({UpdateGroup.class, DefaultGroup.class}) ShopCouponDTO dto) {
|
||||||
Long shopId = StpKit.USER.getShopId(0L);
|
Long shopId = StpKit.USER.getShopId(0L);
|
||||||
dto.setShopId(shopId);
|
dto.setShopId(shopId);
|
||||||
shopCouponService.updateCouponById(dto);
|
shopCouponService.updateCouponById(dto);
|
||||||
asyncToBranchShop(dto.getId(),2);
|
asyncToBranchShop(dto.getId(), 2);
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,18 +92,19 @@ public class ACouponController {
|
||||||
*/
|
*/
|
||||||
@DeleteMapping("{id}")
|
@DeleteMapping("{id}")
|
||||||
@OperationLog("优惠券-删除")
|
@OperationLog("优惠券-删除")
|
||||||
@SaAdminCheckPermission("prodGroup:delete")
|
// @SaAdminCheckPermission("prodGroup:delete")
|
||||||
public CzgResult<Void> deleteCoupon(@PathVariable("id") Long id) {
|
public CzgResult<Void> deleteCoupon(@PathVariable("id") Long id) {
|
||||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||||
shopCouponService.deleteCoupon(id);
|
shopCouponService.deleteCoupon(id);
|
||||||
asyncToBranchShop(id,3);
|
asyncToBranchShop(id, 3);
|
||||||
return CzgResult.success();
|
return CzgResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void asyncToBranchShop(Long id,Integer type) {
|
private void asyncToBranchShop(Long id, Integer type) {
|
||||||
long shopId = StpKit.USER.getShopId(0L);
|
long shopId = StpKit.USER.getShopId(0L);
|
||||||
|
log.info("优惠券同步,优惠券id:{},类型:{}", id, type);
|
||||||
ThreadUtil.execAsync(() -> {
|
ThreadUtil.execAsync(() -> {
|
||||||
shopSyncService.syncCouponBySourceShop(shopId, id,type);
|
shopSyncService.syncCouponBySourceShop(shopId, id, type);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ public class ShopCouponDTO implements Serializable {
|
||||||
private String useShops;
|
private String useShops;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可使用类型:堂食/自取/配送/快递
|
* 可使用类型:dine堂食/pickup自取/deliv配送/express快递
|
||||||
*/
|
*/
|
||||||
private String useType;
|
private String useType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public class ShopCoupon implements Serializable {
|
||||||
private String useShops;
|
private String useShops;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 可使用类型:堂食/自取/配送/快递
|
* 可使用类型:dine堂食/pickup自取/deliv配送/express快递
|
||||||
*/
|
*/
|
||||||
private String useType;
|
private String useType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class ShopCouponServiceImpl extends ServiceImpl<ShopCouponMapper, ShopCou
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<ShopCouponDTO> getCouponPage(ShopCouponDTO param) {
|
public Page<ShopCouponDTO> getCouponPage(ShopCouponDTO param) {
|
||||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
QueryWrapper queryWrapper = new QueryWrapper();
|
||||||
queryWrapper.eq(ShopCoupon::getShopId, param.getShopId())
|
queryWrapper.eq(ShopCoupon::getShopId, param.getShopId())
|
||||||
.eq(ShopCoupon::getCouponType, param.getCouponType())
|
.eq(ShopCoupon::getCouponType, param.getCouponType())
|
||||||
.orderBy(ShopCoupon::getCreateTime).desc();
|
.orderBy(ShopCoupon::getCreateTime).desc();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue