1 Commits

Author SHA1 Message Date
1661483f39 钩子损坏1 2026-06-30 09:50:00 +08:00
625 changed files with 9764 additions and 27871 deletions

1
.gitignore vendored
View File

@@ -61,4 +61,3 @@ build/
/cash-api/product-server/src/main/resources/application-zs.yml
/cash-api/system-server/src/main/resources/application-zs.yml
/cash-service/code-generator/src/main/java/com/czg/Main.java
/cash-api/product-server/logs/

View File

@@ -147,4 +147,32 @@ public class NotifyController {
}
return resultMap;
}
public static void main(String[] args) {
String str = "<xml><ToUserName><![CDATA[gh_11fc27b7ef34]]></ToUserName><FromUserName><![CDATA[owWHW7Tzeh2gx3WmFsFSxBq2JUTk]]></FromUserName><CreateTime>1761095747</CreateTime><MsgType><![CDATA[event]]></MsgType><Event><![CDATA[subscribe]]></Event><EventKey><![CDATA[qrscene_275]]></EventKey><Ticket><![CDATA[gQGF8DwAAAAAAAAAAS5odHRwOi8vd2VpeGluLnFxLmNvbS9xLzAyUTZDVHRTMXhmbUoxYUlYdk5GY2sAAgSsLvhoAwQAjScA]]></Ticket></xml>";
// 2. 解析 XML 为 Map便于获取字段
Map<String, String> messageMap = new HashMap<>();
try {
messageMap = parseXmlToMap(str);
} catch (DocumentException e) {
log.error("XML 解析失败,", e);
}
log.info("微信 POST 消息内容: {}", messageMap);
//携带参数
String eventKey = messageMap.get("EventKey");
Long userId = null;
if (eventKey != null && eventKey.startsWith("qrscene_")) {
try {
// 截取 "qrscene_" 前缀后的字符串(长度为 8并转为 Long
String numberStr = eventKey.substring("qrscene_".length());
userId = Long.parseLong(numberStr);
} catch (NumberFormatException e) {
log.error("EventKey 后缀不是有效数字eventKey: {}", eventKey, e);
}
}
System.out.println("userId: " + userId);
}
}

View File

@@ -0,0 +1,39 @@
package com.czg.controller;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserFlowService;
import com.czg.account.service.ShopUserService;
import com.czg.account.service.TestService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author GYJoker
*/
@RestController
@RequestMapping("/test")
public class TestController {
@Resource
private ShopUserFlowService shopUserFlowService;
@Resource
private ShopInfoService shopInfoService;
@Resource
private ShopUserService shopUserService;
@Resource
private TestService testService;
@RequestMapping("/hello")
public String hello() {
shopUserFlowService.list().forEach(item -> {
ShopUser shopUserInfo = shopUserService.getShopUserInfo(item.getShopId(), item.getUserId());
if (shopUserInfo != null) {
item.setShopUserId(shopUserInfo.getId());
shopUserFlowService.updateById(item);
}
});
// return testService.insertData();
return "";
}
}

View File

@@ -1,18 +1,27 @@
package com.czg.controller.admin;
import cn.hutool.http.server.HttpServerRequest;
import cn.hutool.http.server.HttpServerResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.czg.account.dto.SysLoginDTO;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.SysUser;
import com.czg.account.service.AuthorizationService;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.SysUserService;
import com.czg.account.service.*;
import com.czg.account.vo.LoginVO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
@@ -26,9 +35,11 @@ public class AuthorizationController {
@Resource
private AuthorizationService authorizationService;
@Resource
private PermissionService permissionService;
@Resource
private ShopInfoService shopInfoService;
@Resource
private SysUserService sysUserService;
private ShopStaffService shopStaffService;
/**
@@ -66,6 +77,27 @@ public class AuthorizationController {
return CzgResult.success(StpKit.USER.getPermissionList());
}
@Resource
RabbitPublisher rabbitPublisher;
@Resource
ShopTableService shopTableService;
@GetMapping("test")
public CzgResult<?> login(HttpServletRequest request, HttpServletResponse response) throws IOException {
// shopTableService.createQrCode(1L, 1, response, request);
// rabbitPublisher.sendOrderPrintMsg("552");
// printMqListener.orderPrint("1");
// return CzgResult.success(Map.of("token", StpKit.USER.getShopId()));
return CzgResult.success(StpKit.USER.getLoginId());
}
@GetMapping("test1")
public CzgResult<?> login1() throws IOException {
authorizationService.switchTo(86L);
return CzgResult.success(StpKit.USER.getLoginId());
}
/**
* 核销获取 信息使用
@@ -73,11 +105,14 @@ public class AuthorizationController {
*/
@GetMapping("/userInfo")
public CzgResult<Map<String, Object>> getUserInfo() {
String account = StpKit.USER.getAccount();
ShopInfo shopInfo = shopInfoService.queryChain()
.select(ShopInfo::getId, ShopInfo::getShopName)
.eq(ShopInfo::getId, StpKit.USER.getShopId()).one();
SysUser one = sysUserService.queryChain().eq(SysUser::getId, StpKit.USER.getShopId()).one();
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", one.getAccount());
if (account.contains("@")) {
account = account.split("@")[1];
}
Map<String, Object> map = Map.of("shopId", shopInfo.getId(), "shopName", shopInfo.getShopName(), "account", account);
return CzgResult.success(map);
}
}

View File

@@ -7,11 +7,11 @@ import com.czg.account.service.HandoverRecordService;
import com.czg.account.vo.HandoverProductListVo;
import com.czg.account.vo.HandoverTotalVo;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.excel.ExcelExportUtil;
import com.czg.enums.YesNoEnum;
import com.czg.log.annotation.OperationLog;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.paginate.Page;
import jakarta.servlet.http.HttpServletResponse;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
@@ -37,6 +37,7 @@ public class HandoverRecordController {
* @param endDate 结束时间 格式yyyy-MM-dd
*/
@GetMapping("page")
@OperationLog("交班记录-分页")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:page", name = "交班记录-分页")
public CzgResult<Page<HandoverRecordDTO>> page(@RequestParam(required = false) String beginDate, @RequestParam(required = false) String endDate) {
Page<HandoverRecordDTO> page = handoverRecordService.getHandoverRecordPage(beginDate, endDate);
@@ -44,51 +45,38 @@ public class HandoverRecordController {
}
/**
* 交班记录-详情
*
* @param id 交班记录ID
*/
@GetMapping("/detail/{id}")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
public CzgResult<HandoverRecordDTO> detail(@PathVariable Long id) {
HandoverRecord entity = handoverRecordService.getById(id);
HandoverRecordDTO data = BeanUtil.copyProperties(entity, HandoverRecordDTO.class);
return CzgResult.success(data);
}
/**
* 交班记录-商品详情
* 交班记录-查看
*
* @param id 交班记录ID
*/
@GetMapping("{id}")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
@OperationLog("交班记录-查看")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:info", name = "交班记录-查看")
public CzgResult<List<HandoverProductListVo>> info(@PathVariable Long id) {
List<HandoverProductListVo> data = handoverRecordService.getHandoverProductListById(id);
return CzgResult.success(data);
}
/**
* 交班记录-商品详情导出
* 交班记录-导出
*
* @param id 交班记录ID
*/
@ResponseExcel(name = "交班售出商品明细")
@GetMapping("/export/{id}")
@OperationLog("交班记录-导出")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:export", name = "交班记录-导出")
public void export(@PathVariable Long id, HttpServletResponse response) {
List<HandoverProductListVo> list = handoverRecordService.getHandoverProductListById(id);
ExcelExportUtil.exportToResponse(list, HandoverProductListVo.class, "交班售出商品明细", response);
public List<HandoverProductListVo> export(@PathVariable Long id) {
return handoverRecordService.getHandoverProductListById(id);
}
/**
* 收银机-实时交班数据
* 收银机-交班数据统计
*/
@GetMapping("total")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:realTime", name = "收银机-实时交班数据")
public CzgResult<HandoverTotalVo> realTime() {
@OperationLog("收银机-交班数据统计")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:total", name = "收银机-交班数据统计")
public CzgResult<HandoverTotalVo> total() {
HandoverTotalVo data = handoverRecordService.totalHandoverData();
return CzgResult.success(data);
}
@@ -102,8 +90,36 @@ public class HandoverRecordController {
@OperationLog("收银机-交班/关班")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:handover", name = "收银机-交班/关班")
public CzgResult<Long> handover(@RequestParam Integer isPrint) {
HandoverRecord handoverRecord = handoverRecordService.handover();
handoverRecordService.printHandoverReceipt(handoverRecord, isPrint);
return CzgResult.success(handoverRecord.getId());
Long id = handoverRecordService.handover();
return CzgResult.success(id);
}
/**
* 收银机-交班/关班-网络打印机打印交班小票
*
* @param id 交班记录id
*/
@PostMapping("/network/print/{id}")
@OperationLog("收银机-交班/关班-网络打印机打印交班小票")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:networkPrint", name = "收银机-交班/关班-网络打印机打印交班小票")
public CzgResult<Void> handover(@PathVariable Long id) {
handoverRecordService.printHandoverReceipt(id, YesNoEnum.YES.value());
return CzgResult.success();
}
/**
* 交班记录-详情
*
* @param id 交班记录ID
*/
@GetMapping("/detail/{id}")
@OperationLog("交班记录-详情")
@SaAdminCheckPermission(parentName = "交班记录", value = "handoverRecord:detail", name = "交班记录-详情")
public CzgResult<HandoverRecordDTO> detail(@PathVariable Long id) {
HandoverRecord entity = handoverRecordService.getById(id);
HandoverRecordDTO data = BeanUtil.copyProperties(entity, HandoverRecordDTO.class);
return CzgResult.success(data);
}
}

View File

@@ -4,18 +4,14 @@ import com.czg.account.dto.menu.MenuAddDTO;
import com.czg.account.dto.menu.MenuDelDTO;
import com.czg.account.dto.menu.MenuEditDTO;
import com.czg.account.entity.CashMenu;
import com.czg.account.entity.QuickMenu;
import com.czg.account.entity.SysMenu;
import com.czg.account.service.QuickMenuService;
import com.czg.account.service.SysMenuService;
import com.czg.account.vo.MenuVO;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaAdminCheckRole;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -23,7 +19,6 @@ import java.util.List;
/**
* 菜单管理
*
* @author zs
*/
@RestController
@@ -32,12 +27,9 @@ public class MenuController {
@Resource
private SysMenuService menuService;
@Resource
private QuickMenuService quickMenuService;
/**
* 获取当前用户菜单列表
*
* @return 菜单结构
*/
@GetMapping
@@ -48,7 +40,6 @@ public class MenuController {
/**
* 收银机菜单
*
* @return 所有菜单
*/
@GetMapping("/list/cash")
@@ -58,7 +49,6 @@ public class MenuController {
/**
* 获取所有菜单
*
* @return 菜单结构
*/
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:list", name = "菜单列表")
@@ -72,7 +62,6 @@ public class MenuController {
/**
* 菜单详情
*
* @return 菜单结构
*/
@SaAdminCheckRole("管理员")
@@ -84,7 +73,6 @@ public class MenuController {
/**
* 菜单添加
*
* @return 是否成功
*/
@SaAdminCheckRole("管理员")
@@ -96,7 +84,6 @@ public class MenuController {
/**
* 菜单修改
*
* @return 是否成功
*/
@SaAdminCheckRole("管理员")
@@ -108,15 +95,12 @@ public class MenuController {
/**
* 菜单删除
*
* @return 是否成功
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:del", name = "菜单删除")
@DeleteMapping()
@Transactional
public CzgResult<Boolean> edit(@RequestBody @Validated MenuDelDTO menuDelDTO) {
quickMenuService.remove(QueryWrapper.create().eq(QuickMenu::getMenuId, menuDelDTO.getId()));
return CzgResult.success(menuService.removeById(menuDelDTO.getId()));
}

View File

@@ -1,7 +1,11 @@
package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.czg.account.dto.print.PrinterAddDTO;
import com.czg.account.dto.print.PrinterDelDTO;
import com.czg.account.dto.print.PrinterEditDTO;
import com.czg.account.dto.print.PrinterOrderDTO;
import com.czg.account.entity.PrintMachine;
import com.czg.account.service.PrintMachineService;
import com.czg.annotation.SaAdminCheckPermission;
@@ -44,30 +48,15 @@ public class PrintMachineController {
}
if (StrUtil.isNotBlank(subType)) {
queryWrapper.eq(PrintMachine::getPrintType, subType);
queryWrapper.eq(PrintMachine::getSubType, subType);
}
queryWrapper.orderBy(PrintMachine::getSort, true).orderBy(PrintMachine::getId, false);
Page<PrintMachine> page = printMachineService.page(PageUtil.buildPage(), queryWrapper);
return CzgResult.success(page);
page.getRecords().forEach(item -> {
if (StrUtil.isNotBlank(item.getCategoryIds())) {
item.setCategoryList(JSONArray.parse(item.getCategoryIds()));
}
/**
* 打印机列表
* @param name 名称
* @return 打印机列表
*/
@GetMapping("/getPrintLocal")
public CzgResult<Page<PrintMachine>> getPrintLocal(String name, String subType) {
QueryWrapper queryWrapper = new QueryWrapper().eq(PrintMachine::getShopId, StpKit.USER.getShopId());
if (StrUtil.isNotBlank(name)) {
queryWrapper.like(PrintMachine::getName, name);
}
queryWrapper.in(PrintMachine::getConnectionType, "USB", "局域网");
if (StrUtil.isNotBlank(subType)) {
queryWrapper.eq(PrintMachine::getPrintType, subType);
}
queryWrapper.orderBy(PrintMachine::getSort, true).orderBy(PrintMachine::getId, false);
Page<PrintMachine> page = printMachineService.page(PageUtil.buildPage(), queryWrapper);
});
return CzgResult.success(page);
}
@@ -80,6 +69,9 @@ public class PrintMachineController {
@GetMapping("/detail")
public CzgResult<PrintMachine> detail(@RequestParam Integer id) {
PrintMachine printMachine = printMachineService.getOne(new QueryWrapper().eq(PrintMachine::getId, id).eq(PrintMachine::getShopId, StpKit.USER.getShopId()));
if (printMachine != null && StrUtil.isNotBlank(printMachine.getCategoryIds())) {
printMachine.setCategoryList(JSONArray.parse(printMachine.getCategoryIds()));
}
return CzgResult.success(printMachine);
}
@@ -90,7 +82,7 @@ public class PrintMachineController {
*/
@SaAdminCheckPermission(parentName = "打印机管理", value = "printer:add", name = "打印机新增")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated PrintMachine printerAddDTO) {
public CzgResult<Boolean> add(@RequestBody @Validated PrinterAddDTO printerAddDTO) {
return CzgResult.success(printMachineService.add(StpKit.USER.getShopId(), printerAddDTO));
}
@@ -100,7 +92,7 @@ public class PrintMachineController {
*/
@SaAdminCheckPermission(parentName = "打印机管理", value = "printer:edit", name = "打印机编辑")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated PrintMachine printerEditDTO) {
public CzgResult<Boolean> edit(@RequestBody @Validated PrinterEditDTO printerEditDTO) {
return CzgResult.success(printMachineService.edit(StpKit.USER.getShopId(), printerEditDTO));
}

View File

@@ -1,70 +0,0 @@
package com.czg.controller.admin;
import cn.hutool.core.collection.CollUtil;
import com.czg.account.entity.QuickMenu;
import com.czg.account.service.QuickMenuService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Set;
/**
* 悬浮窗/快捷菜单
*
* @author ww
* @description
*/
@RestController
@RequestMapping("/admin/quick")
@Slf4j
public class QuickMenuController {
@Resource
private QuickMenuService quickMenuService;
// @SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-列表")
@GetMapping
public CzgResult<List<QuickMenu>> getQuickList(@RequestParam(required = false) Integer status,
@RequestParam(required = false, defaultValue = "0") Integer isEdit) {
List<QuickMenu> list = quickMenuService.list(QueryWrapper.create()
.eq(QuickMenu::getShopId, StpKit.USER.getShopId())
.eq(QuickMenu::getStatus, status)
.orderBy(QuickMenu::getSort, true));
if (isEdit.equals(0)) {
if (CollUtil.isEmpty(list)) {
list = quickMenuService.list(QueryWrapper.create()
.eq(QuickMenu::getShopId, 1)
.eq(QuickMenu::getStatus, status)
.orderBy(QuickMenu::getSort, true));
}
}
return CzgResult.success(list);
}
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-新增")
@PostMapping
public CzgResult<Boolean> saveQuick(@RequestBody @Validated QuickMenu quickMenu) {
quickMenu.setShopId(StpKit.USER.getShopId());
return CzgResult.success(quickMenuService.save(quickMenu));
}
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-修改")
@PutMapping
public CzgResult<Boolean> updateQuick(@RequestBody @Validated QuickMenu quickMenu) {
return CzgResult.success(quickMenuService.update(quickMenu, QueryWrapper.create()
.eq(QuickMenu::getId, quickMenu.getId()).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
}
@SaAdminCheckPermission(parentName = "悬浮窗", value = "quick:list", name = "悬浮窗-删除")
@DeleteMapping
public CzgResult<Boolean> deleteQuick(@RequestBody Set<Long> ids) {
return CzgResult.success(quickMenuService.remove(QueryWrapper.create().in(QuickMenu::getId, ids).eq(QuickMenu::getShopId, StpKit.USER.getShopId())));
}
}

View File

@@ -34,7 +34,7 @@ public class RoleController {
* @param pageDTO 分页信息
* @return 分页数据
*/
@SaAdminCheckPermission(parentName = "角色管理接口", value = "role:list", name = "角色列表")
@SaAdminCheckPermission(parentName = "角色管理", value = "role:list", name = "角色列表")
@GetMapping("/list")
public CzgResult<Page<SysRole>> getList(PageDTO pageDTO, String key, String startTime, String endTime) {
return CzgResult.success(roleService.getList(StpKit.USER.getShopId(), pageDTO, key, startTime, endTime));
@@ -48,10 +48,10 @@ public class RoleController {
* @param type 0管理端 1收银机
* @return 分页数据
*/
@SaAdminCheckPermission(parentName = "角色管理接口", value = "role:menu", name = "角色菜单")
@SaAdminCheckPermission(parentName = "角色管理", value = "role:menu", name = "角色菜单")
@GetMapping("/menu")
public CzgResult<List<Long>> getRoleMenu(@RequestParam Integer id, @RequestParam Integer type) {
return CzgResult.success(roleService.getRoleMenu(StpKit.USER.getShopId(), id, type));
return CzgResult.success(roleService.getRoleMenu(StpKit.USER.getLoginIdAsLong(), id, type));
}
/**
@@ -61,7 +61,7 @@ public class RoleController {
* @param roleAddDTO 角色信息
* @return 是否成功
*/
@SaAdminCheckPermission(parentName = "角色管理接口", value = "role:add", name = "角色添加")
@SaAdminCheckPermission(parentName = "角色管理", value = "role:add", name = "角色添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated RoleAddDTO roleAddDTO) {
return CzgResult.success(roleService.add(roleAddDTO));
@@ -75,7 +75,7 @@ public class RoleController {
*/
@PutMapping("/permission")
public CzgResult<Boolean> editPermission(@RequestBody @Validated RolePermissionDTO rolePermissionDTO) {
return CzgResult.success(roleService.editPermission(StpKit.USER.getShopId(), rolePermissionDTO));
return CzgResult.success(roleService.editPermission(StpKit.USER.getLoginIdAsLong(), rolePermissionDTO));
}
/**
@@ -85,7 +85,7 @@ public class RoleController {
* @param roleEditDTO 角色信息
* @return 是否成功
*/
@SaAdminCheckPermission(parentName = "角色管理接口", value = "role:edit", name = "角色编辑")
@SaAdminCheckPermission(parentName = "角色管理", value = "role:edit", name = "角色编辑")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated RoleEditDTO roleEditDTO) {
return CzgResult.success(roleService.edit(roleEditDTO));
@@ -98,11 +98,11 @@ public class RoleController {
* @param roleRemoveDTO 角色信息
* @return 是否成功
*/
@SaAdminCheckPermission(parentName = "角色管理接口", value = "role:remove", name = "角色删除")
@SaAdminCheckPermission(parentName = "角色管理", value = "role:remove", name = "角色删除")
@DeleteMapping
public CzgResult<Boolean> remove(@RequestBody @Validated RoleRemoveDTO roleRemoveDTO) {
if (roleRemoveDTO.id() == 1L || roleRemoveDTO.id() == 2L || roleRemoveDTO.id() == 3L) {
return CzgResult.failure("默认角色不可删除");
if (roleRemoveDTO.id() == 1L || roleRemoveDTO.id() == 2L) {
return CzgResult.failure("超级管理员角色不可删除");
}
return CzgResult.success(roleService.removeById(roleRemoveDTO.id()));
}

View File

@@ -38,10 +38,10 @@ public class ShopInfoController {
* 权限标识: shopInfo:list
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "店铺管理接口", value = "shopInfo:list", name = "店铺列表")
@SaAdminCheckPermission(parentName = "店铺管理", value = "shopInfo:list", name = "店铺列表")
@GetMapping
public CzgResult<Page<ShopInfo>> get(PageDTO pageDTO, String profiles, String phone, String shopName, Integer status, Integer isHeadShop) {
return CzgResult.success(shopInfoService.get(pageDTO, profiles, phone, shopName, status, isHeadShop));
public CzgResult<Page<ShopInfo>> get(PageDTO pageDTO, String shopName, Integer status, Integer isHeadShop) {
return CzgResult.success(shopInfoService.get(pageDTO, shopName, status, isHeadShop));
}
/**
@@ -71,7 +71,7 @@ public class ShopInfoController {
* 权限标识: shopInfo:add
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "店铺管理接口", value = "shopInfo:add", name = "店铺添加")
@SaAdminCheckPermission(parentName = "店铺管理", value = "shopInfo:add", name = "店铺添加")
@PostMapping
public CzgResult<?> add(@RequestBody @Validated ShopInfoAddDTO shopInfoAddDTO) {
return CzgResult.success(shopInfoService.add(shopInfoAddDTO));
@@ -81,7 +81,7 @@ public class ShopInfoController {
* 店铺编辑
* 权限标识: shopInfo:edit
*/
@SaAdminCheckPermission(parentName = "店铺管理接口", value = "shopInfo:edit", name = "店铺编辑")
@SaAdminCheckPermission(parentName = "店铺管理", value = "shopInfo:edit", name = "店铺编辑")
@PutMapping
public CzgResult<?> edit(@RequestBody @Validated ShopInfoEditDTO shopInfoEditDTO) {
return CzgResult.success(shopInfoService.edit(shopInfoEditDTO));
@@ -92,7 +92,7 @@ public class ShopInfoController {
* 权限标识: shopInfo:del
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "店铺管理接口", value = "shopInfo:del", name = "店铺删除")
@SaAdminCheckPermission(parentName = "店铺管理", value = "shopInfo:del", name = "店铺删除")
@DeleteMapping
public CzgResult<?> delete(@RequestParam Integer id) {
return CzgResult.success(shopInfoService.remove(new QueryWrapper().eq(ShopInfo::getId, id)));

View File

@@ -1,19 +1,18 @@
package com.czg.controller.admin;
import com.czg.account.dto.merchant.ShopMerchantEditDTO;
import com.czg.account.entity.ShopMerchant;
import com.czg.account.service.ShopMerchantService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaAdminCheckRole;
import com.czg.constant.PayChannelCst;
import com.czg.exception.CzgException;
import com.czg.order.dto.ShopMerchantDTO;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 商户信息管理
*
* @author Administrator
*/
@RestController
@@ -25,39 +24,25 @@ public class ShopMerchantController {
/**
* 商户支付信息获取
* 权限标识: shopMerchant:detail
*
* @param shopId 店铺id
* @return 支付信息
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
@GetMapping
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
return CzgResult.success(shopMerchantService.detail(shopId));
}
/**
* 商户支付信息修改
* 权限标识: shopMerchant:edit
*
* @return 是否成功
*/
@SaAdminCheckRole("管理员")
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
if (shopMerchant != null && shopMerchant.getChannel() != null && shopMerchant.getChannel().equals(PayChannelCst.NATIVE)) {
throw new CzgException("原生支付渠道暂未开通");
}
return CzgResult.success(shopMerchantService.editEntry(shopMerchant, true));
}
/**
* 获取当前店铺的主店进件信息
*/
@SaAdminCheckRole("管理员")
@GetMapping("getMainMerchant")
public CzgResult<ShopDirectMerchant> getMainMerchant(Long shopId) {
return CzgResult.success(shopMerchantService.getMainMerchant(shopId));
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
}
}

View File

@@ -97,17 +97,6 @@ public class ShopUserController {
return CzgResult.success(shopUserService.getPage(key, isVip, amount));
}
/**
* 导出用户列表
*
* @param key 昵称或手机号
* @param isVip 0 非vip 1 vip
*/
@GetMapping("/export")
public void exportUserList(String key, Integer isVip, HttpServletResponse response) {
shopUserService.exportUserList(key, isVip, response);
}
@GetMapping("/getPage")
public CzgResult<Page<ShopUser>> getPage(@RequestParam(required = false)String key,@RequestParam(required = false) Integer isVip) {
return CzgResult.success(shopUserService.getPage(key, isVip));

View File

@@ -1,9 +1,7 @@
package com.czg.controller.user;
import cn.hutool.core.bean.BeanUtil;
import com.czg.account.dto.shopuser.ShopUserAddDTO;
import com.czg.account.dto.shopuser.ShopUserDetailDTO;
import com.czg.account.dto.shopuser.ShopUserEditDTO;
import com.czg.account.dto.shopuser.ShopUserVipCardDTO;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser;
@@ -77,19 +75,6 @@ public class UShopUserController {
return CzgResult.success(shopUserService.join(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong(), shopUserAddDTO));
}
/**
* 确认信息
* @return 是否成功
*/
@PostMapping("/confirm")
public CzgResult<Boolean> confirm(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) {
ShopUser shopUser = new ShopUser();
BeanUtil.copyProperties(shopUserEditDTO, shopUser);
shopUserService.getService().updateInfo(shopUser);
return CzgResult.success();
}
/**
* 获取余额余额明细

View File

@@ -37,6 +37,11 @@ public class UserAuthorizationController {
return CzgResult.success(userAuthorizationService.login(userAuthorizationLoginDTO));
}
@PostMapping("/test")
public CzgResult<String> test() {
return CzgResult.success(StpKit.USER.getTokenValue());
}
/**
* 获取手机号
* @param getPhoneDTO 获取手机号信息

View File

@@ -1 +0,0 @@
nacos=com.czg.config.FilteredNacosRegistryFactory

View File

@@ -39,7 +39,6 @@ dubbo:
port: 10101
seata:
application-id: account-server
tx-service-group: group_seata

View File

@@ -2,9 +2,9 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.42:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: root
password: Chaozg123.
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: cashier
password: Cashier@1@
data:
redis:

View File

@@ -1,61 +0,0 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.dto.MkCarouselDTO;
import com.czg.market.entity.MkCarousel;
import com.czg.market.service.MkCarouselService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 轮播图配置
*
* @author ww
*/
@RestController
@RequestMapping("/admin/carousel")
public class ACarouselController {
@Resource
private MkCarouselService mkCarouselService;
/**
* 轮播图配置
*/
@GetMapping
@SaAdminCheckPermission(parentName = "轮播图配置", value = "carousel:config", name = "轮播图-列表")
public CzgResult<List<MkCarousel>> getCarousels(MkCarouselDTO carouselDTO) {
carouselDTO.setShopId(StpKit.USER.getShopId());
return CzgResult.success(mkCarouselService.getCarousels(carouselDTO));
}
/**
* 轮播图配置:新增/修改
*/
@PostMapping
@SaAdminCheckPermission(parentName = "轮播图配置", value = "carousel:up", name = "轮播图-新增/修改")
public CzgResult<Boolean> editCarousel(@RequestBody @Validated MkCarousel carousel) {
carousel.setShopId(StpKit.USER.getShopId());
if (carousel.getId() == null) {
return CzgResult.success(mkCarouselService.save(carousel));
} else {
return CzgResult.success(mkCarouselService.updateById(carousel, false));
}
}
/**
* 轮播图配置:删除
*/
@DeleteMapping("/{id}")
@SaAdminCheckPermission(parentName = "轮播图配置", value = "carousel:up", name = "轮播图-新增/修改")
public CzgResult<Boolean> deleteCarousel(@PathVariable("id") Long id) {
return CzgResult.success(mkCarouselService.remove(QueryWrapper.create().eq(MkCarousel::getId, id).eq(MkCarousel::getShopId, StpKit.USER.getShopId())));
}
}

View File

@@ -1,47 +0,0 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.entity.MkDistributionGroup;
import com.czg.market.service.MkDistributionGroupService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
/**
* 全民股东群聊
*
* @author ww
*/
@RestController
@RequestMapping("/admin/disGroup")
public class ADisGroupController {
@Resource
private MkDistributionGroupService mkDistributionGroupService;
/**
* 全民股东群聊
*/
@GetMapping
@SaAdminCheckPermission(parentName = "全民股东群聊", value = "share:config", name = "全民股东群聊-配置")
public CzgResult<MkDistributionGroup> getShareBase() {
return CzgResult.success(mkDistributionGroupService.getById(StpKit.USER.getShopId()));
}
/**
* 全民股东群聊:新增/修改
*/
@PostMapping
@SaAdminCheckPermission(parentName = "全民股东群聊", value = "share:up", name = "全民股东群聊-新增/修改")
public CzgResult<Boolean> editShareBase(@RequestBody MkDistributionGroup group) {
group.setShopId(StpKit.USER.getShopId());
MkDistributionGroup share = mkDistributionGroupService.getById(group.getShopId());
if (share == null) {
return CzgResult.success(mkDistributionGroupService.save(group));
} else {
return CzgResult.success(mkDistributionGroupService.updateById(group));
}
}
}

View File

@@ -1,6 +1,6 @@
package com.czg.controller.admin;
import com.czg.PageQueryParam;
import com.czg.TimeQueryParam;
import com.czg.log.annotation.OperationLog;
import com.czg.market.dto.MkDiscountActivityDTO;
import com.czg.market.service.MkDiscountActivityService;
@@ -31,7 +31,7 @@ public class ADiscountActivityController {
* 分页
*/
@GetMapping("page")
public CzgResult<Page<MkDiscountActivityDTO>> getActivityPage(PageQueryParam param) {
public CzgResult<Page<MkDiscountActivityDTO>> getActivityPage(TimeQueryParam param) {
Page<MkDiscountActivityDTO> data = discountActivityService.getActivityPage(param, StpKit.USER.getShopId());
return CzgResult.success(data);
}

View File

@@ -1,6 +1,6 @@
package com.czg.controller.admin;
import com.czg.PageQueryParam;
import com.czg.TimeQueryParam;
import com.czg.log.annotation.OperationLog;
import com.czg.market.dto.MkLimitTimeDiscountDTO;
import com.czg.market.entity.MkLimitTimeDiscount;
@@ -31,7 +31,7 @@ public class ALimitTimeDiscountController {
* 限时折扣-分页
*/
@GetMapping("page")
public CzgResult<Page<MkLimitTimeDiscountDTO>> getLimitTimeDiscountPage(PageQueryParam param) {
public CzgResult<Page<MkLimitTimeDiscountDTO>> getLimitTimeDiscountPage(TimeQueryParam param) {
Page<MkLimitTimeDiscountDTO> data = limitTimeDiscountService.getLimitTimeDiscountPage(param, StpKit.USER.getShopId());
return CzgResult.success(data);
}

View File

@@ -1,48 +0,0 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.entity.MkShareBase;
import com.czg.market.service.MkShareBaseService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
/**
* 分享奖励基础
*
* @author ww
*/
@RestController
@RequestMapping("/admin/shareBase")
public class AShareBaseController {
@Resource
private MkShareBaseService mkShareBaseService;
/**
* 分享奖励基础
*/
@GetMapping
@SaAdminCheckPermission(parentName = "分享奖励基础", value = "share:config", name = "分享-配置")
public CzgResult<MkShareBase> getShareBase() {
return CzgResult.success(mkShareBaseService.getShareBase(StpKit.USER.getShopId()));
}
/**
* 分享奖励基础:新增/修改
*/
@PostMapping
@SaAdminCheckPermission(parentName = "分享奖励基础", value = "share:up", name = "分享-新增/修改")
public CzgResult<Boolean> editShareBase(@RequestBody MkShareBase shareBase) {
shareBase.setShopId(StpKit.USER.getShopId());
MkShareBase share = mkShareBaseService.getById(shareBase.getShopId());
if (share == null) {
return CzgResult.success(mkShareBaseService.save(shareBase));
} else {
shareBase.setCreateTime(share.getCreateTime());
return CzgResult.success(mkShareBaseService.updateById(shareBase, false));
}
}
}

View File

@@ -1,11 +1,8 @@
package com.czg.controller.admin;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.dto.MkBirthdayGiftDTO;
import com.czg.market.service.MkBirthdayGiftService;
import com.czg.market.vo.MkBirthdayGiftRecordSummaryVO;
import com.czg.market.vo.MkBirthdayGiftRecordVO;
import com.czg.market.vo.MkBirthdayGiftVO;
import com.czg.resp.CzgResult;
@@ -26,16 +23,6 @@ import java.time.LocalDateTime;
public class BirthdayGiftController {
@Resource
private MkBirthdayGiftService service;
/**
* 记录获取
* @return 是否成功
*/
@SaAdminCheckPermission(parentName = "生日有礼",value = "birthdayGift:summary", name = "生日有礼概述")
@GetMapping("/summary")
public CzgResult<MkBirthdayGiftRecordSummaryVO> summary(@RequestParam(required = false) String dateTime, @RequestParam(required = false) String key) {
return CzgResult.success(service.summary(StpKit.USER.getMainShopId(), key, StrUtil.isNotBlank(dateTime) ? DateUtil.parseLocalDateTime(dateTime) : null));
// return null;
}
/**
* 配置信息获取

View File

@@ -3,13 +3,16 @@ package com.czg.controller.admin;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.annotation.SaCheckMainShop;
import com.czg.market.dto.MkDistributionConfigDTO;
import com.czg.market.service.*;
import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.market.vo.*;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -35,6 +38,8 @@ public class DistributionController {
private MkDistributionFlowService distributionFlowService;
@Resource
private MkDistributionWithdrawFlowService withdrawFlowService;
@Resource
private AppWxServiceImpl appWxService;
/**
* 配置信息详情

View File

@@ -1,6 +1,5 @@
package com.czg.controller.admin;
import com.czg.annotation.Debounce;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.market.dto.MkDistributionUserDTO;
@@ -58,7 +57,6 @@ public class DistributionUserController {
*
* @return 是否成功
*/
@Debounce
@PostMapping
@OperationLog("分销员-添加")
@SaAdminCheckPermission(parentName = "分销相关",value = "distribution:user:add", name = "分销员添加")

View File

@@ -3,6 +3,7 @@ package com.czg.controller.admin;
import com.czg.exception.CzgException;
import com.czg.market.dto.MemberConfigDTO;
import com.czg.market.dto.MemberLevelDTO;
import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.service.MemberLevelConfigService;
import com.czg.market.service.MemberOrderService;
import com.czg.market.service.TbMemberConfigService;
@@ -12,6 +13,7 @@ import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.AssertUtil;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.validation.groups.Default;
import org.springframework.validation.annotation.Validated;
@@ -22,8 +24,6 @@ import java.util.Map;
/**
* 会员配置管理
*
* @author ww
*/
@RestController
@@ -39,7 +39,6 @@ public class MemberController {
/**
* 会员购买订单记录 分页
*
* @param startTime 开始时间
* @param endTime 结束时间
* @param key 用户id
@@ -50,7 +49,6 @@ public class MemberController {
@RequestParam(required = false) String endTime, @RequestParam(required = false) String key) {
return CzgResult.success(memberOrderService.pageInfo(startTime, endTime, key));
}
/**
* 配置信息获取
* 权限标识: activate:list
@@ -62,7 +60,6 @@ public class MemberController {
/**
* 配置信息修改
*
* @return 是否成功
*/
@PostMapping
@@ -74,7 +71,6 @@ public class MemberController {
/**
* 会员等级添加
*
* @return 是否成功
*/
@PostMapping("/level")
@@ -85,7 +81,6 @@ public class MemberController {
/**
* 会员等级修改
*
* @return 是否成功
*/
@PutMapping("/level")
@@ -96,18 +91,16 @@ public class MemberController {
/**
* 会员等级删除
*
* @return 是否成功
*/
@DeleteMapping("/level/{id}")
public CzgResult<Boolean> deleteLevel(@PathVariable Long id) {
AssertUtil.isTrue(!StpKit.USER.isMainShop(), "无权限操作");
return CzgResult.success(memberLevelConfigService.removeLevel(id, StpKit.USER.getShopId()));
return CzgResult.success(memberLevelConfigService.remove(new QueryWrapper().eq(MemberLevelConfig::getId, id).eq(MemberLevelConfig::getShopId, StpKit.USER.getShopId())));
}
/**
* 会员等级列表
*
* @return 是否成功
*/
@GetMapping("/level/list")
@@ -118,7 +111,6 @@ public class MemberController {
/**
* 会员等级详情
*
* @return 是否成功
*/
@PutMapping("/level/detail")

View File

@@ -5,7 +5,6 @@ import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.dto.MkPointsConfigDTO;
import com.czg.market.dto.MkPointsUserDTO;
import com.czg.market.entity.MkPointsConfig;
import com.czg.market.entity.MkPointsUser;
import com.czg.market.entity.MkPointsUserRecord;
import com.czg.market.service.MkPointsConfigService;
import com.czg.market.service.MkPointsUserRecordService;
@@ -13,16 +12,15 @@ import com.czg.market.service.MkPointsUserService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.CzgStrUtils;
import com.czg.validator.ValidatorUtil;
import com.czg.validator.group.DefaultGroup;
import com.czg.validator.group.InsertGroup;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.Pattern;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* 积分配置
@@ -90,23 +88,4 @@ public class PointsConfigController {
@RequestParam(required = false) Long id) {
return CzgResult.success(userRecordService.pageByPointsUserId(page, size, id));
}
/**
* 获取用户积分 包括配置信息
* {
* "pointsConfig": 配置信息,
* "pointsUser": 用户积分信息
* }
*/
@GetMapping("userPoints")
public CzgResult<Map<String, Object>> userPoints(@RequestParam(required = false) Long shopUserId) {
Long shopId = StpKit.USER.getShopId();
Map<String, Object> result = new HashMap<>(2);
MkPointsConfig pointsConfig = pointsConfigService.getById(shopId);
MkPointsUser pointsUser = pointsUserService.getOne(QueryWrapper.create().eq(MkPointsUser::getShopId, shopId).eq(MkPointsUser::getShopUserId, shopUserId));
result.put("pointsConfig", pointsConfig == null ? "" : pointsConfig);
result.put("pointsUser", pointsUser == null ? "" : pointsUser);
return CzgResult.success(result);
}
}

View File

@@ -3,7 +3,7 @@ package com.czg.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import com.czg.BaseQueryParam;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.constants.SystemConstants;
import com.czg.enums.DeleteEnum;
import com.czg.exception.CzgException;
import com.czg.market.dto.MkPointsGoodsDTO;
import com.czg.market.entity.MkPointsGoods;
@@ -62,7 +62,7 @@ public class PointsGoodsController {
dto.setShopId(StpKit.USER.getShopId());
if (dto.getCouponId() != null) {
ShopCoupon coupon = shopCouponService.getById(dto.getCouponId());
if (coupon == null || coupon.getIsDel() == SystemConstants.OneZero.ONE || coupon.getStatus() != 1) {
if (coupon == null || coupon.getIsDel() == DeleteEnum.DELETED.value() || coupon.getStatus() != 1) {
throw new CzgException("操作失败,优惠券已删除或未启用");
}
if ("custom".equals(coupon.getValidType())) {
@@ -88,7 +88,7 @@ public class PointsGoodsController {
@SaAdminCheckPermission(parentName = "积分相关", value = "points:goods:delete", name = "积分-商品-删除")
public CzgResult<Void> deletePointsGoodsSetting(@PathVariable("id") Long id) {
MkPointsGoods entity = pointsGoodsSettingService.getById(id);
entity.setDelFlag(SystemConstants.OneZero.ONE);
entity.setDelFlag(DeleteEnum.DELETED.value());
pointsGoodsSettingService.updateById(entity);
return CzgResult.success();
}

View File

@@ -1,143 +0,0 @@
package com.czg.controller.admin;
import com.alibaba.fastjson2.JSONObject;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.service.PpPackageOrderService;
import com.czg.market.service.PpPackageService;
import com.czg.market.vo.PpOrderListVO;
import com.czg.market.vo.PpPackagePageReqVo;
import com.czg.market.vo.PpPackageVO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.vo.GbOrderCountVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.AssertUtil;
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.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 管理端/套餐推广
*
* @author yjjie
* @date 2025/12/18 11:18
*/
@Slf4j
@RestController
@RequestMapping("/admin/package")
public class PpPackageController {
@Resource
private PpPackageService ppPackageService;
@Resource
private PpPackageOrderService ppPackageOrderService;
/**
* 添加套餐
*/
@PostMapping
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:add", name = "添加套餐")
public CzgResult<Void> addPackage(@RequestBody @Validated({InsertGroup.class}) PpPackageVO packageVO) {
ppPackageService.insertPackage(packageVO);
return CzgResult.success();
}
/**
* 修改套餐
*/
@PutMapping
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:update", name = "修改套餐")
public CzgResult<Void> updatePackage(@RequestBody @Validated({UpdateGroup.class}) PpPackageVO packageVO) {
ppPackageService.updatePackage(packageVO);
return CzgResult.success();
}
/**
* 删除套餐
*/
@DeleteMapping("/{id}")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:delete", name = "删除套餐")
public CzgResult<Boolean> deletePackage(@PathVariable Long id) {
return CzgResult.success(ppPackageService.deletePackage(id));
}
/**
* 上下架套餐
* 参数: {"status": 1, "packageId": 123}
*/
@PutMapping("/online")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:online", name = "上下架套餐")
public CzgResult<Boolean> switchPackage(@RequestBody JSONObject param) {
AssertUtil.isNull(param, "参数错误");
Integer status = param.getInteger("status");
Long packageId = param.getLong("packageId");
AssertUtil.isNull(status, "参数错误");
AssertUtil.isNull(packageId, "参数错误");
return CzgResult.success(ppPackageService.updateOnlineStatus(packageId, status));
}
/**
* 获取套餐列表
*/
@GetMapping
public CzgResult<Page<PpPackageVO>> getPackageList(PpPackagePageReqVo reqVo) {
return CzgResult.success(ppPackageService.getPackagePage(reqVo, true));
}
/**
* 获取套餐详情
*/
@GetMapping("/detail/{id}")
public CzgResult<PpPackageVO> getPackageDetail(@PathVariable Long id, Long shopId) {
return CzgResult.success(ppPackageService.getPackageDetail(id, shopId));
}
/**
* 获取套餐推广开关
* 0: 关闭 1: 开启
*/
@GetMapping("/switch")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:getSwitch", name = "获取套餐推广开关")
public CzgResult<Integer> getPackagePromotionSwitch() {
return CzgResult.success(ppPackageService.getPackagePromotionSwitch(StpKit.USER.getShopId()));
}
/**
* 修改套餐推广开关
* 0: 关闭 1: 开启
* {"status": 1}
*/
@PutMapping("/switch")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:updateSwitch", name = "修改套餐推广开关")
public CzgResult<Boolean> updatePackagePromotionSwitch(@RequestBody JSONObject param) {
log.info("修改套餐推广开关: {}", param);
AssertUtil.isNull(param, "参数错误");
Integer status = param.getInteger("status");
AssertUtil.isNull(status, "参数错误");
log.info("修改套餐推广开关 status == {}", status);
return CzgResult.success(ppPackageService.updatePackagePromotionSwitch(status, StpKit.USER.getShopId()));
}
/**
* 获取套餐推广订单列表
*/
@GetMapping("/order")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:order", name = "套餐推广订单列表")
public CzgResult<Page<PpOrderListVO>> getPackageOrderList(GbOrderQueryParam reqVo) {
return CzgResult.success(ppPackageOrderService.queryOrderList(StpKit.USER.getShopId(), null, reqVo));
}
/**
* 订单统计
*/
@GetMapping("/order/stat")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:order", name = "套餐推广订单列表")
public CzgResult<GbOrderCountVO> getPackageOrderStat(GbOrderQueryParam reqVo) {
return CzgResult.success(ppPackageOrderService.orderCount(StpKit.USER.getShopId(), reqVo));
}
}

View File

@@ -1,6 +1,7 @@
package com.czg.controller.admin;
import com.czg.market.dto.MkShopRechargeDTO;
import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.entity.MkShopRechargeFlow;
import com.czg.market.service.MkRechargeFlowService;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
@@ -29,6 +30,12 @@ public class ShopRechargeController {
@Resource
private MkShopConsumeDiscountRecordService shopConsumeDiscountRecordService;
@GetMapping("/test")
public CzgResult<MkShopConsumeDiscountRecord> get(@RequestParam Long shopId) {
// return CzgResult.success(shopConsumeDiscountRecordService.get(shopId));
return null;
}
/**
* 配置信息获取
* 权限标识: activate:list

View File

@@ -1,70 +0,0 @@
package com.czg.controller.user;
import com.czg.market.dto.MkCarouselDTO;
import com.czg.market.entity.MkCarousel;
import com.czg.market.entity.MkShareBase;
import com.czg.market.service.MkCarouselService;
import com.czg.market.service.MkShareBaseService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 轮播图配置
*
* @author ww
*/
@RestController
@RequestMapping("/user")
public class UCarouselController {
@Resource
private MkCarouselService mkCarouselService;
@Resource
private MkShareBaseService mkShareBaseService;
/**
* 轮播图配置
*/
@GetMapping("/carousel")
public CzgResult<List<MkCarousel>> getCarousels(MkCarouselDTO carouselDTO) {
carouselDTO.setShopId(StpKit.USER.getShopId());
carouselDTO.setIsEnabled(1);
return CzgResult.success(mkCarouselService.getCarousels(carouselDTO));
}
/**
* 分享 领取触发
*
* @param tagType
* @param shopId
* @param fromUserId 分享人的shopUserId
* @param toUserId 被分享人的shopUserId
*/
public record ShareClaim(String tagType, Long shopId, Long fromUserId, Long toUserId) {
}
/**
* 分享 基础配置
*/
@GetMapping("/share")
public CzgResult<MkShareBase> share(@RequestParam Long shopId) {
return CzgResult.success(mkShareBaseService.getShareBase(shopId));
}
/**
* 分享 领取触发
* 会绑定上下级关系
*/
@PostMapping("/shareClaim")
public CzgResult<Void> shareClaim(@RequestBody ShareClaim shareClaim) {
mkShareBaseService.shareClaim(shareClaim.tagType, shareClaim.shopId, shareClaim.fromUserId, shareClaim.toUserId);
return CzgResult.success();
}
}

View File

@@ -3,7 +3,6 @@ package com.czg.controller.user;
import com.czg.account.entity.UserInfo;
import com.czg.market.dto.MkDistributionUserDTO;
import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
import com.czg.market.entity.MkDistributionUser;
import com.czg.market.entity.MkDistributionWithdrawFlow;
import com.czg.market.service.MkDistributionConfigService;
import com.czg.market.service.MkDistributionFlowService;
@@ -14,23 +13,20 @@ import com.czg.market.vo.InviteUserVO;
import com.czg.market.vo.MkDistributionConfigVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.task.DistributionTask;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 全民股东相关
* 分销相关
*
* @author Administrator
*/
@Slf4j
@RestController
@RequestMapping("/user/distribution")
public class UDistributionController {
@@ -39,28 +35,14 @@ public class UDistributionController {
@Resource
private MkDistributionUserService distributionUserService;
@Resource
private AppWxServiceImpl appWxService;
@Resource
private MkDistributionWithdrawFlowService withdrawFlowService;
@Resource
private MkDistributionFlowService distributionFlowService;
@Resource
private DistributionTask distributionTask;
/**
* 测试方法-分销流水入账
*/
@GetMapping("/task")
public CzgResult<String> task(@RequestParam Long shopId) {
try {
distributionTask.deliver(shopId);
} catch (Exception e) {
return CzgResult.failure(e.getMessage());
}
return CzgResult.success("任务执行成功");
}
/**
* 全民股东=-获取配置
* 分销员中心-获取配置
*/
@GetMapping("/getConfig")
public CzgResult<MkDistributionConfigVO> getConfig(@RequestParam Long shopId) {
@@ -68,7 +50,7 @@ public class UDistributionController {
}
/**
* 全民股东-首页
* 分销员中心-首页
*/
@PostMapping("/centerUser")
public CzgResult<Map<String, Object>> centerUser() {
@@ -76,7 +58,7 @@ public class UDistributionController {
}
/**
* 全民股东界-已开通的店铺
* 分销员中心-已开通的店铺
*/
@GetMapping("/centerUser/activates")
public CzgResult<Page<DistributionCenterShopVO>> activates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
@@ -84,7 +66,7 @@ public class UDistributionController {
}
/**
* 全民股东-未开通的店铺
* 分销员中心-未开通的店铺
*/
@GetMapping("/centerUser/unActivates")
public CzgResult<Page<DistributionCenterShopVO>> unActivates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
@@ -92,7 +74,7 @@ public class UDistributionController {
}
/**
* 全民股东-配置信息
* 分销员中心-配置信息
*/
@GetMapping("/centerConfig")
public CzgResult<Map<String, Object>> centerConfig(@RequestParam Long shopId) {
@@ -100,27 +82,15 @@ public class UDistributionController {
}
/**
* 全民股东界面-进入过标识
*/
@GetMapping("/editIn")
public CzgResult<Boolean> editIn(@RequestParam Long shopUserId) {
MkDistributionUser distributionUser = new MkDistributionUser();
distributionUser.setFirstIn(1);
distributionUserService.update(distributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, shopUserId));
return CzgResult.success();
}
/**
* 全民股东-获取邀请码
* 分销员中心-获取邀请码
*/
@GetMapping("/getInviteCode")
public CzgResult<String> getInviteCode(@RequestParam Long shopId, @RequestParam Long shopUserId) {
return CzgResult.success(distributionUserService.getInviteCode(shopId, shopUserId));
}
/**
* 全民股东-实名认证
* 分销员中心-实名认证
*/
@PostMapping("/realNameAuth")
public CzgResult<Map<String, Object>> realNameAuth(@RequestBody UserInfo userInfo) {
@@ -132,7 +102,7 @@ public class UDistributionController {
}
/**
* 全民股东-绑定邀请人
* 分销员中心-绑定邀请人
*/
@PostMapping("/bindInviteUser")
public CzgResult<Map<String, Object>> bindInviteUser(@RequestBody MkDistributionUserDTO param) {
@@ -144,7 +114,7 @@ public class UDistributionController {
}
/**
* 全民股东:获取邀请人分页列表
* 分销员:获取邀请人分页列表
*/
@GetMapping("/inviteUser")
public CzgResult<Page<InviteUserVO>> getInviteUser(
@@ -188,6 +158,9 @@ public class UDistributionController {
/**
* 收益明细
*
* @param startTime
* @param endTime
* @param shopId
* @param status pending待入账 success已入账
*/
@GetMapping("/distributionFlow")

View File

@@ -60,10 +60,10 @@ public class UPointsController {
Long shopId = StpKit.USER.getShopId();
Map<String, Object> result = new HashMap<>(2);
MkPointsConfig pointsConfig = pointsConfigService.getById(shopId);
MkPointsUser pointsUser = pointsUserService.getOne(QueryWrapper.create().eq(MkPointsUser::getShopId, shopId).eq(MkPointsUser::getShopUserId, shopUserId));
MkPointsUser pointsUser = pointsUserService.getOne(QueryWrapper.create().eq(MkPointsUser::getShopId, shopId).eq(MkPointsUser::getUserId, shopUserId));
result.put("pointsConfig", pointsConfig == null ? "" : pointsConfig);
result.put("pointsUser", pointsUser == null ? "" : pointsUser);
return CzgResult.success(result);
return CzgResult.success();
}
/**

View File

@@ -1,109 +0,0 @@
package com.czg.controller.user;
import com.alibaba.fastjson2.JSONObject;
import com.czg.PageQueryParam;
import com.czg.market.dto.PpHelpRecordDTO;
import com.czg.market.dto.PpPackageOrderDTO;
import com.czg.market.service.PpHelpRecordService;
import com.czg.market.service.PpPackageOrderService;
import com.czg.market.service.PpPackageService;
import com.czg.market.vo.PpOrderListVO;
import com.czg.market.vo.PpPackagePageReqVo;
import com.czg.market.vo.PpPackageVO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
/**
* 用户端/套餐推广
*
* @author yjjie
* @date 2025/12/18 18:03
*/
@RestController
@RequestMapping("/user/package")
public class UPpPackageController {
@Resource
private PpPackageService ppPackageService;
@Resource
private PpPackageOrderService ppPackageOrderService;
@Resource
private PpHelpRecordService ppHelpRecordService;
/**
* 创建套餐推广订单
* 参数: {"packageId": 123, "shopId": 123}
*/
@PostMapping("/order")
public CzgResult<Long> createOrder(@RequestBody JSONObject params) {
AssertUtil.isNull(params, "参数不能为空");
Long packageId = params.getLong("packageId");
AssertUtil.isNull(packageId, "参数错误");
Long shopId = params.getLong("shopId");
AssertUtil.isNull(shopId, "参数错误");
return CzgResult.success(ppPackageOrderService.createPackageOrder(packageId, shopId));
}
/**
* 获取套餐列表
*/
@GetMapping
public CzgResult<Page<PpPackageVO>> getPackageList(PpPackagePageReqVo reqVo) {
return CzgResult.success(ppPackageService.getPackagePage(reqVo, false));
}
/**
* 获取套餐详情
*/
@GetMapping("/detail/{id}")
public CzgResult<PpPackageVO> getPackageDetail(@PathVariable Long id, Long shopId) {
return CzgResult.success(ppPackageService.getPackageDetail(id, shopId));
}
/**
* 获取我的订单列表
*/
@GetMapping("/order")
public CzgResult<Page<PpOrderListVO>> getMyOrderList(GbOrderQueryParam reqVo) {
return CzgResult.success(ppPackageOrderService.queryOrderList(reqVo.getShopId(), StpKit.USER.getLoginIdAsLong(), reqVo));
}
/**
* 取消订单
*/
@GetMapping("/cancel")
public CzgResult<Boolean> cancelOrder(@RequestParam Long orderId) {
return CzgResult.success(ppPackageOrderService.cancelOrder(orderId));
}
/**
* 助力订单
*/
@GetMapping("/help")
public CzgResult<Boolean> helpOrder(Long orderId) {
return CzgResult.success(ppPackageOrderService.helpOrder(orderId));
}
/**
* 获取订单详情
*/
@GetMapping("/order/detail")
public CzgResult<PpPackageOrderDTO> getOrderDetail(@RequestParam Long orderId) {
return CzgResult.success(ppPackageOrderService.getOrderDetailById(orderId, StpKit.USER.getLoginIdAsLong()));
}
/**
* 获取助力列表
*/
@GetMapping("/help/page")
public CzgResult<Page<PpHelpRecordDTO>> getHelpList(PageQueryParam reqVo) {
return CzgResult.success(ppHelpRecordService.helpPage(reqVo));
}
}

View File

@@ -6,8 +6,8 @@ import org.springframework.stereotype.Component;
/**
* market服务 任务总调度
*
* @author ww
* @description
*/
@Component
public class AAMarketTasks {
@@ -19,9 +19,9 @@ public class AAMarketTasks {
// 分销延时发放
@Scheduled(cron = "0 0 0/2 * * ? ")
@Scheduled(fixedRate = 30000)
public void distributionTask() {
distributionTask.deliver(null);
distributionTask.deliver();
}
@@ -30,7 +30,6 @@ public class AAMarketTasks {
public void birthdayGiftTask() {
birthdayGiftTask.deliver();
}
//会员生日弹窗提醒重置 每年1月1日
@Scheduled(cron = "0 0 0 1 1 ?")
public void birthdayGiftRemindTask() {
@@ -41,7 +40,6 @@ public class AAMarketTasks {
//优惠券 过期
@Resource
private CouponTask couponTask;
//每天每小时的30分 0秒 执行
@Scheduled(cron = "0 30 * * * ? ")
public void couponTask() {
@@ -51,7 +49,6 @@ public class AAMarketTasks {
//会员奖励发放
@Resource
private MemberTask memberTask;
//每天1点 0分 0秒 执行
@Scheduled(cron = "0 0 1 * * ? ")
public void memberTask() {
@@ -61,7 +58,6 @@ public class AAMarketTasks {
//满减活动/限时折扣 处理任务状态 定时任务
@Resource
private ActivityStatusTask activityStatusTask;
//每天0点 0分 1秒 执行
@Scheduled(cron = "1 0 0 * * ? ")
public void activityStatusTask() {
@@ -72,23 +68,11 @@ public class AAMarketTasks {
//月累计 发送条数 累计金额
@Resource
private SmsShopMoneyTask smsShopMoneyTask;
//每月1号 0点 0分 1秒 执行
@Scheduled(cron = "1 0 0 1 * ?")
public void smsShopMoneyTask() {
smsShopMoneyTask.task();
}
@Resource
private PpPackageTask ppPackageTask;
/**
* 套餐推广订单 过期
* 每两小时 触发一次
*/
@Scheduled(cron = "0 24 0/2 * * ?")
public void ppOrderExpire() {
ppPackageTask.ppOrderExpire();
}
}

View File

@@ -1,17 +1,18 @@
package com.czg.task;
import cn.hutool.core.collection.CollUtil;
import com.czg.account.entity.ShopInfo;
import cn.hutool.core.date.DateUtil;
import com.czg.account.entity.ShopUser;
import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService;
import com.czg.constant.TableValueConstant;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException;
import com.czg.market.entity.MkDistributionFlow;
import com.czg.market.service.MkDistributionFlowService;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.OrderInfo;
import com.czg.service.market.enums.OrderStatusEnums;
import com.czg.utils.FunUtils;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
@@ -20,7 +21,6 @@ import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
* 分销定时任务
@@ -39,8 +39,8 @@ public class DistributionTask {
private OrderInfoService orderInfoService;
@DubboReference
private ShopInfoService shopInfoService;
List<String> list = List.of(OrderStatusEnums.REFUND.getCode(), OrderStatusEnums.PART_REFUND.getCode());
@DubboReference
private ShopUserService shopUserService;
/**
* 分销流水入账
@@ -48,55 +48,38 @@ public class DistributionTask {
*/
// @Scheduled(cron = "0 0 0 * * ?")
// @Scheduled(fixedRate = 30000)
public void deliver(Long shopId) {
LocalDateTime now = LocalDateTime.now();
List<ShopInfo> shopInfos = shopInfoService.list(QueryWrapper.create()
.eq(ShopInfo::getIsDeleted, SystemConstants.OneZero.ZERO)
.isNotNull(ShopInfo::getExpireTime)
.lt(ShopInfo::getExpireTime, now)
.gt(ShopInfo::getAmount, BigDecimal.ZERO)
.eq(ShopInfo::getId, shopId)
);
if (CollUtil.isEmpty(shopInfos)) {
log.info("分销延时分账 无符合条件的店铺,无需处理分账");
return;
}
for (ShopInfo shopInfo : shopInfos) {
boolean breakCurrentShopFlow = false;
List<MkDistributionFlow> flowList = distributionFlowService.list(new QueryWrapper()
.eq(MkDistributionFlow::getShopId, shopInfo.getId())
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode())
.le(MkDistributionFlow::getDeliverTime, now)
.orderBy(MkDistributionFlow::getId, true)
);
for (MkDistributionFlow item : flowList) {
if (breakCurrentShopFlow) {
break;
}
try {
log.info("分销延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType());
public void deliver() {
// 1. 订单完成支付时(判断是否分销)产生流水记录。
// 2. 判断入账时间。
// 3. 如果是 0 天,再去判断商户余额是否足够。够则入账,不足则不管。
// 4. 流水增加应该入账的时间(订单产生时带入)
// 5. 定时任务 应该是一天执行一次。查询待入账状态和应入账时间小于当前时间的记录,循环处理:并且判断商户余额是否足够,余额不足忽略处理;余额足够变为已入账并扣除商户余额。
// 6. 订单产生退款时,去流水表查询该订单的流水记录,如果未入账改为已入账,并插入一条退款扣钱的流水。
LocalDateTime localDateTime = DateUtil.date().toLocalDateTime();
distributionFlowService.list(new QueryWrapper()
.eq(MkDistributionFlow::getStatus, TableValueConstant.DistributionFlow.Status.PENDING.getCode()).le(MkDistributionFlow::getDeliverTime, localDateTime)).forEach(item -> {
FunUtils.safeRunVoid(() -> {
log.info("开始处理延时分账, id: {}, orderNo: {}, 类型: {}", item.getId(), item.getOrderNo(), item.getType());
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getOrderNo, item.getOrderNo()));
if (orderInfo == null) {
item.setStatus(TableValueConstant.DistributionFlow.Status.FAIL.getCode());
distributionFlowService.updateById(item);
log.warn("分销延时分账。订单不存在, 订单号: {}", item.getOrderNo());
continue;
log.warn("订单不存在, 订单号: {}", item.getOrderNo());
return;
}
if (list.contains(orderInfo.getStatus())) {
log.warn("分销延时分账。订单已退款, 订单号: {}", item.getOrderNo());
if (CollUtil.newArrayList(OrderStatusEnums.REFUND.getCode(), OrderStatusEnums.REFUNDING.getCode(), OrderStatusEnums.PART_REFUND.getCode()).contains(orderInfo.getStatus())) {
log.warn("订单已退款, 订单号: {}", item.getOrderNo());
distributionUserService.refund(orderInfo.getId(), orderInfo.getOrderNo());
} else {
item.setStatus(TableValueConstant.DistributionFlow.Status.SUCCESS.getCode());
distributionUserService.distributionUserAmount(item, orderInfo);
}
} catch (CzgException e) {
log.error("店铺{}:{}分销延时分账异常:{}", shopInfo.getId(), shopInfo.getShopName(), e.getMessage());
breakCurrentShopFlow = true;
} catch (Exception e) {
log.error("店铺{}:{}分销延时分账异常", shopInfo.getId(), shopInfo.getShopName(), e);
breakCurrentShopFlow = true;
}
}
ShopUser shopUser = shopUserService.getById(item.getDistributionUserId());
distributionUserService.updateShopInfoAmount(orderInfo.getShopId(), item.getRewardAmount().negate(), orderInfo.getId(), TableValueConstant.DistributionAmountFlow.Type.SUB, "分销扣减");
distributionUserService.updateIncome(item.getRewardAmount().negate(), item.getRewardAmount(), BigDecimal.ZERO,
item.getDistributionUserId(), shopUser.getUserId(), item.getShopUserId(), item.getShopId(), item.getLevel());
distributionFlowService.updateById(item);
}
});
});
}
}

View File

@@ -1,69 +0,0 @@
package com.czg.task;
import com.czg.config.RedisCst;
import com.czg.constants.PpPackageConstants;
import com.czg.market.entity.PpPackageOrder;
import com.czg.market.service.PpPackageOrderService;
import com.czg.order.entity.GbOrder;
import com.czg.service.RedisService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
/**
* 套餐推广定时任务
*
* @author yjjie
* @date 2025/12/19 10:05
*/
@Slf4j
@Component
public class PpPackageTask {
@Resource
private RedisService redisService;
@Resource
private PpPackageOrderService ppPackageOrderService;
/**
* 订单 过期
* 每两小时 触发一次
*/
public void ppOrderExpire() {
// 当前系统时间
LocalDateTime now = LocalDateTime.now();
// 过期时间下限当前时间往前推4小时只查最近4小时内过期的
LocalDateTime expire4HoursAgo = now.minusHours(4);
List<PpPackageOrder> expiredOrderList = ppPackageOrderService.list(QueryWrapper.create()
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
.le(PpPackageOrder::getExpireTime, now)
.ge(PpPackageOrder::getExpireTime, expire4HoursAgo));
// 处理已过期订单
for (PpPackageOrder expiredOrder : expiredOrderList) {
//退款
ppPackageOrderService.expiredOrder(expiredOrder.getId());
}
//查询【当前时间往后2小时内】将要过期的订单
LocalDateTime willExpire2HoursLater = now.plusHours(2);
List<PpPackageOrder> willExpireOrderList = ppPackageOrderService.list(QueryWrapper.create()
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
.ge(PpPackageOrder::getExpireTime, now)
.le(PpPackageOrder::getExpireTime, willExpire2HoursLater));
// 处理将要过期订单(如推送提醒、催参团等)
for (PpPackageOrder willExpireOrder : willExpireOrderList) {
LocalDateTime endTime = willExpireOrder.getExpireTime();
Duration duration = Duration.between(now, endTime);
long seconds = duration.getSeconds();
redisService.set(RedisCst.classKeyExpired.EXPIRED_PP_ORDER + willExpireOrder.getId(), willExpireOrder.getId(), seconds);
}
}
}

View File

@@ -1 +0,0 @@
nacos=com.czg.config.FilteredNacosRegistryFactory

View File

@@ -33,7 +33,7 @@ spring:
dubbo:
application:
name: market-server
name: product-server
qos-port: 22261
qos-enable: true
registry:

View File

@@ -27,7 +27,7 @@ spring:
dubbo:
application:
name: market-server
name: product-server
qos-port: 22263
qos-enable: true
registry:

View File

@@ -27,7 +27,7 @@ spring:
dubbo:
application:
name: market-server
name: product-server
qos-port: 22262
qos-enable: true
registry:

View File

@@ -12,7 +12,7 @@ spring:
core-size: 8
max-size: 16
queue-capacity: 200
thread-name-prefix: async-market-
thread-name-prefix: async-product-
logging:
config: classpath:logback.xml

View File

@@ -4,9 +4,7 @@ import com.czg.account.service.ShopTableService;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.AcPushEventService;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.PpPackageOrderService;
import com.czg.market.service.SmsPushEventService;
import com.czg.order.service.GbOrderService;
import com.czg.order.service.OrderInfoCustomService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
@@ -42,10 +40,6 @@ public class RedisKeyExpirationListener implements MessageListener {
private SmsPushEventService smsPushEventService;
@Resource
private AcPushEventService acPushEventService;
@Resource
private GbOrderService gbOrderService;
@DubboReference
private PpPackageOrderService ppPackageOrderService;
//redis key失效监听
@@ -78,14 +72,6 @@ public class RedisKeyExpirationListener implements MessageListener {
.eq(MkShopCouponRecord::getStatus, 0)
.eq(MkShopCouponRecord::getId, Long.parseLong(couponId))
);
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_GB_ORDER)) {
log.info("监听到拼团任务过期,gb_order任务Id: {}", expiredKey);
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_GB_ORDER.length());
gbOrderService.expireRefund(Long.parseLong(eventId), null);
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_PP_ORDER)) {
log.info("监听到套餐推广任务过期,pp_order任务Id: {}", expiredKey);
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_PP_ORDER.length());
ppPackageOrderService.expiredOrder(Long.parseLong(eventId));
} else if (expiredKey.startsWith(RedisCst.classKeyExpired.EXPIRED_SMS)) {
log.info("监听到短信定时发放优惠券,sms_push_event任务Id: {}", expiredKey);
String eventId = expiredKey.substring(RedisCst.classKeyExpired.EXPIRED_SMS.length());

View File

@@ -0,0 +1,85 @@
package com.czg.controller;
import com.czg.annotation.Debounce;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.service.DistributionPayService;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 分销员开通
*
* @author ww
* @description
*/
@RestController
@RequestMapping("/pay/distribution")
public class DistributionPayController {
@Resource
private DistributionPayService payService;
@DubboReference
private SysParamsService paramsService;
// @PostMapping("/cashPay")
// @Debounce(value = "#payParam.checkOrderPay.orderId")
// public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
// payParam.setShopId(shopId);
// return payService.cashPayOrder(payParam);
// }
/**
* 小程序支付
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/ltPayOrder")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, Object>> ltPayOrder( HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
}
/**
* 运营端小程序余额充值
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
*/
@PostMapping("/mchRecharge")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, String>> mchRecharge(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
}
//
// /**
// * 正扫
// */
// @PostMapping("/scanPay")
// @Debounce(value = "#payParam.checkOrderPay.orderId")
// public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
// payParam.setShopId(shopId);
// return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
// }
//
// /**
// * 反扫
// * authCode 必填 扫描码
// */
// @PostMapping("/microPay")
// @Debounce(value = "#payParam.checkOrderPay.orderId")
// public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
// payParam.setShopId(shopId);
// return payService.microPayOrder(payParam);
// }
}

View File

@@ -3,14 +3,8 @@ package com.czg.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.PayCst;
import com.czg.PolyPayUtils;
import com.czg.constant.PayChannelCst;
import com.czg.constants.PayTypeConstants;
import com.czg.dto.req.WechatNotifyReqDto;
import com.czg.dto.req.WechatPayNotifyDataDto;
import com.czg.entity.PolyBaseResp;
import com.czg.exception.CzgException;
import com.czg.CzgPayUtils;
import com.czg.entity.CzgBaseRespParams;
import com.czg.market.entity.MkShopConsumeDiscountRecord;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkShopConsumeDiscountRecordService;
@@ -19,28 +13,30 @@ import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.PayNotifyRespDTO;
import com.czg.service.market.service.impl.AppWxServiceImpl;
import com.czg.third.wechat.WechatReqUtils;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
/**
* 回调
*
* @author ww
* @description
*/
@Slf4j
@RestController
@RequestMapping("/notify")
public class NotifyController {
private static final String SUCCESS = "SUCCESS";
@Resource
private OrderInfoCustomService orderInfoCustomService;
@Resource
@@ -54,8 +50,6 @@ public class NotifyController {
@Resource
private MkShopConsumeDiscountRecordService consumeDiscountRecordService;
//新客立减清除数据 测试用
@RequestMapping("clear")
public String clear(@RequestParam Integer shopId) {
consumeDiscountRecordService.remove(new QueryWrapper().eq(MkShopConsumeDiscountRecord::getShopId, shopId));
@@ -63,63 +57,19 @@ public class NotifyController {
return "success";
}
/**
* 原生支付回调
*/
@RequestMapping("/native/pay/{platform}")
public String pay(@PathVariable String platform, @RequestBody JSONObject json) {
if (PayCst.Type.WECHAT.equalsIgnoreCase(platform)) {
// 微信
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto));
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
log.info("【微信支付回调】解密数据 {}", decrypted);
WechatPayNotifyDataDto dataDto = JSONObject.parseObject(decrypted, WechatPayNotifyDataDto.class);
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
return "success";
} else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝
return "success";
}
throw new CzgException("不支持的支付平台");
}
/**
* 原生退款回调
*/
@RequestMapping("/native/refund/{platform}")
public String refund(@PathVariable String platform, @RequestBody JSONObject json) {
if (PayCst.Type.WECHAT.equalsIgnoreCase(platform)) {
// 微信
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto));
String decrypted = WechatReqUtils.decryptRespParam(null, reqDto);
log.info("【微信退款回调】解密数据 {}", decrypted);
return "success";
} else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝
return "success";
}
throw new CzgException("不支持的支付平台");
}
@RequestMapping("/payCallBack")
public String notifyCallBack(@RequestBody PolyBaseResp respParams) {
PayNotifyRespDTO respDTO = PolyPayUtils.getNotifyResp(respParams);
AssertUtil.isNull(respDTO, "支付回调数据为空");
log.info("支付回调数据为:{}", respDTO);
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.POLY, 0);
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "支付回调数据为空");
log.info("支付回调数据为:{}", czg);
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
return SUCCESS;
}
@RequestMapping("/native/wx/transfer")
public String nativeTransferNotify(HttpServletRequest request) {
public String nativeTransferNotify(HttpServletRequest request) throws IOException {
log.info("接收到微信转账回调");
JSONObject jsonObject = wxService.verifySignature(request);
log.info("参数信息: {}", jsonObject.toJSONString());
@@ -135,15 +85,12 @@ public class NotifyController {
}
/**
* 微信原生支付回调
*/
@RequestMapping("/native/wx/pay/distributionRecharge")
public String nativeNotify(HttpServletRequest request) throws IOException {
// String timestamp = request.getHeader("Wechatpay-Timestamp");
// String nonce = request.getHeader("Wechatpay-Nonce");
// String serialNo = request.getHeader("Wechatpay-Serial");
// String signature = request.getHeader("Wechatpay-Signature");
String timestamp = request.getHeader("Wechatpay-Timestamp");
String nonce = request.getHeader("Wechatpay-Nonce");
String serialNo = request.getHeader("Wechatpay-Serial");
String signature = request.getHeader("Wechatpay-Signature");
String result = IoUtil.readUtf8(request.getInputStream());
JSONObject jsonObject = JSONObject.parseObject(result);
JSONObject resource = jsonObject.getJSONObject("resource");
@@ -159,13 +106,13 @@ public class NotifyController {
String tradeState = plainTextJson.getString("trade_state");
String transactionId = plainTextJson.getString("transaction_id");
OrderPayment payment = paymentService.getOne(new QueryWrapper().eq(OrderPayment::getOrderNo, outTradeNo));
payment.setPayStatus(PayTypeConstants.PayStatus.FAIL);
payment.setPayStatus("fail");
if ("SUCCESS".equals(tradeState)) {
try {
payment.setTradeNumber(transactionId);
payment.setPayTime(DateUtil.date().toLocalDateTime());
payment.setRespJson(plainTextJson.toJSONString());
payment.setPayStatus(PayTypeConstants.PayStatus.SUCCESS);
payment.setPayStatus("success");
distributionUserService.rechargeCallBack(payment.getShopId(), payment.getAmount(), payment.getId());
}catch (Exception e) {
log.error("充值回调失败", e);
@@ -178,8 +125,8 @@ public class NotifyController {
@RequestMapping("/refundCallBack")
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
JSONObject czg = PolyPayUtils.getCzg(respParams);
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
JSONObject czg = CzgPayUtils.getCzg(respParams);
AssertUtil.isNull(czg, "退款回调数据为空");
log.info("退款回调数据为:{}", czg);
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);

View File

@@ -1,18 +1,16 @@
package com.czg.controller.pay;
package com.czg.controller;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil;
import com.czg.PayCst;
import com.czg.annotation.Debounce;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.CheckOrderPay;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.OrderPayParamDTO;
import com.czg.service.order.service.OrderPayService;
import com.czg.service.order.service.PayService;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
@@ -20,7 +18,6 @@ import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -38,40 +35,38 @@ import java.util.Map;
@RequestMapping("/pay")
public class OrderPayController {
@Resource
private OrderPayService orderPayService;
private PayService payService;
@Resource
private OrderInfoCustomService orderInfoCustomService;
@Resource
private OrderInfoService orderInfoService;
@DubboReference
private SysParamsService paramsService;
@Value("${spring.profiles.active}")
private String env;
@PostMapping("/creditPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Object> creditPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.creditPayOrder(payParam);
return payService.creditPayOrder(payParam);
}
@PostMapping("/cashPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.cashPayOrder(payParam);
return payService.cashPayOrder(payParam);
}
/**
* 充值并付款
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/rechargePayOrder")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> rechargePayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
return payService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
}
/**
@@ -88,7 +83,7 @@ public class OrderPayController {
public CzgResult<Object> vipPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
AssertUtil.isBlank(payParam.getPayType(), "支付类型不可为空");
return orderPayService.vipPayOrder(payParam);
return payService.vipPayOrder(payParam);
}
/**
@@ -98,53 +93,53 @@ public class OrderPayController {
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> h5PayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
return payService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
}
/**
* js支付
* <p>
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/jsPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> jsPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
return payService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
}
/**
* 小程序支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/ltPayOrder")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> ltPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
}
// /**
// * 正扫
// */
// @PostMapping("/scanPay")
// @Debounce(value = "#payParam.checkOrderPay.orderId")
// public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
// payParam.setShopId(shopId);
// return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
// }
/**
* 正扫
*/
@PostMapping("/scanPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
}
/**
* 码收款
*
* authCode 必填 扫描码
*/
@PostMapping("/microPay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
payParam.setShopId(shopId);
return orderPayService.microPayOrder(payParam);
return payService.microPayOrder(payParam);
}
/**
@@ -157,7 +152,6 @@ public class OrderPayController {
AssertUtil.isNull(shopId, "店铺id不能为空");
AssertUtil.isNull(checkOrderPay, "订单信息不能为空");
Map<String, Object> map = new HashMap<>();
map.put("env", env);
map.put("shopId", shopId);
map.put("orderId", checkOrderPay.getOrderId());
map.put("payAmount", checkOrderPay.getOrderAmount());
@@ -166,29 +160,21 @@ public class OrderPayController {
OrderInfo orderInfo = orderInfoCustomService.checkOrderPay(checkOrderPay);
map.put("payAmount", orderInfo.getOrderAmount());
}
String baseUrl = paramsService.getSysParamValue(ParamCodeCst.System.SHOP_ORDER_PAY_BASE_URL);
String baseUrl = paramsService.getSysParamValue(SysParamCodeEnum.SHOP_ORDER_PAY_BASE_URL.getCode());
String buildUrl = URLUtil.buildQuery(map, Charset.defaultCharset());
String fullUrl = baseUrl.concat("?").concat(buildUrl);
return CzgResult.success(fullUrl);
}
/**
* 空订单支付/h5页面支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
* checkOrderPay.orderAmount 必填
*/
@PostMapping("/shopPayApi/js2Pay")
@Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
if ("ALIPAY".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.ALIPAY);
} else if ("WECHAT".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.WECHAT);
} else {
throw new CzgException(payParam.getPayType() + "支付方式错误");
}
return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
return payService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
}
/**

View File

@@ -21,7 +21,7 @@ public class StatisticTaskController {
private StatisticTask statisticTask;
/**
* 基础统计 预留重置统计
* 基础统计
*
* @param date 日期yyyy-MM-dd
*/

View File

@@ -1,18 +1,14 @@
package com.czg.controller.pay;
package com.czg.controller;
import com.czg.annotation.Debounce;
import com.czg.order.entity.OrderPayment;
import com.czg.order.service.OrderPaymentService;
import com.czg.pay.QueryOrderRespDTO;
import com.czg.entity.resp.CzgBaseResp;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.VipMemberPayParamDTO;
import com.czg.service.order.dto.VipPayParamDTO;
import com.czg.service.order.dto.VipRefundDTO;
import com.czg.service.order.service.PayService;
import com.czg.service.order.service.ShopUserPayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
@@ -32,11 +28,6 @@ import java.util.Map;
public class VipPayController {
@Resource
private PayService payService;
@Resource
private ShopUserPayService shopUserPayService;
@Resource
private OrderPaymentService paymentService;
/**
* 现金充值
@@ -48,12 +39,12 @@ public class VipPayController {
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.cashPayVip(payParam);
return payService.cashPayVip(payParam);
}
/**
* js支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/jsPayVip")
@@ -61,12 +52,12 @@ public class VipPayController {
public CzgResult<Map<String, Object>> jsPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.jsPayVip(ServletUtil.getClientIP(request), payParam);
return payService.jsPayVip(ServletUtil.getClientIP(request), payParam);
}
/**
* 小程序支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/ltPayVip")
@@ -74,11 +65,14 @@ public class VipPayController {
public CzgResult<Map<String, Object>> ltPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.ltPayVip(ServletUtil.getClientIP(request), payParam);
return payService.ltPayVip(ServletUtil.getClientIP(request), payParam);
}
/**
* 智慧充值
* @param request
* @param rechargeDTO
* @return
*/
@PostMapping("/recharge")
@Debounce(value = "#rechargeDTO.shopUserId")
@@ -87,18 +81,21 @@ public class VipPayController {
return CzgResult.failure("充值失败 未指定充值金额");
}
rechargeDTO.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
return payService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
}
/**
* 会员购买支付
* @param request
* @param payParam
* @return
*/
@PostMapping("/ltPayMember")
@Debounce(value = "#payParam.shopUserId")
public CzgResult<Map<String, Object>> ltPayMember(HttpServletRequest request, @Validated @RequestBody VipMemberPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "购买失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.ltPayMember(ServletUtil.getClientIP(request), payParam);
return payService.ltPayMember(ServletUtil.getClientIP(request), payParam);
}
@@ -111,7 +108,7 @@ public class VipPayController {
public CzgResult<Map<String, Object>> scanPayVip(HttpServletRequest request, @Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
return shopUserPayService.scanPayVip(ServletUtil.getClientIP(request), payParam);
return payService.scanPayVip(ServletUtil.getClientIP(request), payParam);
}
/**
@@ -124,7 +121,7 @@ public class VipPayController {
public CzgResult<Map<String, Object>> microPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
return shopUserPayService.microPayVip(payParam);
return payService.microPayVip(payParam);
}
/**
@@ -135,11 +132,10 @@ public class VipPayController {
@PostMapping("/refundVipBefore")
@Debounce(value = "#payParam.flowId")
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
return shopUserPayService.refundVipBefore(payParam);
return payService.refundVipBefore(payParam);
}
/**
* 会员退款
* cashRefund 是否是现金退款
* 会员退款(先调用 退款前置接口 refundVipBefore)
* 最大退款金额为 充值金额 inAmount
@@ -159,7 +155,7 @@ public class VipPayController {
return CzgResult.failure("退款金额过大");
}
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
return shopUserPayService.refundVip(payParam);
return payService.refundVip(payParam);
}
/**
@@ -169,16 +165,10 @@ public class VipPayController {
public CzgResult<String> queryOrderStatus(Long shopId, String payOrderNo) {
AssertUtil.isNull(shopId, "店铺id不能为空");
AssertUtil.isBlank(payOrderNo, "支付单号不能为空");
OrderPayment payment = paymentService.getOne(QueryWrapper.create().eq(OrderPayment::getOrderNo, payOrderNo));
if (payment == null) {
return CzgResult.failure("支付单号不存在");
}
CzgResult<String> result = CzgResult.success();
CzgResult<QueryOrderRespDTO> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo, payment.getPlatformType());
if (queryPayOrder.isSuccess() && queryPayOrder.getData() != null) {
String state = queryPayOrder.getData().getStatus();
CzgResult<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo);
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
String state = queryPayOrder.getData().getState();
result.setData(state);
switch (state) {
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");

View File

@@ -1,6 +1,8 @@
package com.czg.controller.admin;
import com.czg.annotation.Debounce;
import com.czg.annotation.SaStaffCheckPermission;
import com.czg.config.RabbitPublisher;
import com.czg.order.dto.*;
import com.czg.order.entity.OrderInfo;
import com.czg.order.service.OrderInfoCustomService;
@@ -9,7 +11,8 @@ import com.czg.order.vo.HistoryOrderVo;
import com.czg.order.vo.OrderInfoVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.service.OrderPayService;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.service.PayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import com.mybatisflex.core.paginate.Page;
@@ -31,7 +34,9 @@ public class AdminOrderController {
@Resource
private OrderInfoCustomService orderInfoService;
@Resource
private OrderPayService orderPayService;
private PayService payService;
@Resource
private RabbitPublisher rabbitPublisher;
/**
* 订单列表
@@ -94,7 +99,7 @@ public class AdminOrderController {
@PostMapping("/refundOrder")
@Debounce(value = "#refundDTO.orderId")
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
return orderPayService.refundOrderBefore(refundDTO);
return payService.refundOrderBefore(refundDTO);
}
/**

View File

@@ -1,105 +0,0 @@
package com.czg.controller.admin;
import com.alibaba.fastjson2.JSONObject;
import com.czg.EntryManager;
import com.czg.annotation.Debounce;
import com.czg.dto.req.AggregateMerchantDto;
import com.czg.dto.resp.WechatBankBranchRespDto;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.resp.CzgResult;
import com.czg.service.order.dto.AggregateMerchantVO;
import com.czg.service.order.dto.MerchantQueryDTO;
import com.czg.service.order.service.ShopDirectMerchantService;
import com.czg.task.EntryManagerTask;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
/**
* 进件管理
*
* @author ww
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/data/entryManager")
public class EntryManagerController {
@Resource
private ShopDirectMerchantService shopDirectMerchantService;
@Resource
private EntryManagerTask entryManagerTask;
/**
* ocr识别填充
* 阿里 ocr识别图片
* 本接口支持PNG、JPG、JPEG、BMP、GIF、TIFF、WebP、PDF。
* 图片长宽需要大于 15 像素,小于 8192 像素。
* 长宽比需要小于 50。长宽均大于 500px。
* 图片二进制文件不能超过 10MB。
* 图片过大会影响接口响应速度,建议使用小于 1.5M 图片进行识别,
*
* @param url 图片地址
* @param type IdCard 身份证
* BankCard 银行卡
* BusinessLicense 营业执照
*/
@GetMapping("getInfoByImg")
public CzgResult<JSONObject> getInfoByImg(String url, String type) throws Exception {
return CzgResult.success(shopDirectMerchantService.getInfoByImg(url, type));
}
/**
* 查询银行支行列表
*
* @param bankAliceCode 银行别名code bankAliasCode 从 /system/admin/common/bankInfo 获取
* @param cityCode 市编码 wxProvinceCode 从 /system/admin/common/region 获取
*/
@GetMapping("bankBranchList")
public CzgResult<WechatBankBranchRespDto> queryBankBranchList(String bankAliceCode, String cityCode) {
AssertUtil.isBlank(bankAliceCode, "请选择银行别名");
AssertUtil.isBlank(cityCode, "请选择城市");
return CzgResult.success(EntryManager.queryBankBranchList(bankAliceCode, cityCode));
}
/**
* 获取进件列表
*/
@GetMapping("list")
public CzgResult<Page<ShopDirectMerchant>> getEntryList(MerchantQueryDTO queryParam) {
return CzgResult.success(shopDirectMerchantService.getEntryList(queryParam));
}
/**
* 获取进件信息
*/
@GetMapping
public CzgResult<AggregateMerchantVO> getEntry(Long shopId) {
return CzgResult.success(shopDirectMerchantService.getEntry(shopId));
}
/**
* 主动查询进件信息状态
* 进件状态是INIT 待处理 AUDIT 审核中 SIGN 待签约
* 3分钟内只能查一次
*/
@GetMapping("queryEntry")
@Debounce(value = "#shopId", interval = 1000 * 60 * 3)
public CzgResult<Boolean> queryEntry(Long shopId) {
entryManagerTask.entryManager(shopId);
return CzgResult.success();
}
/**
* 申请进件
*/
@Debounce(value = "#reqDto.shopId")
@PostMapping
public CzgResult<Boolean> entryManager(@RequestBody AggregateMerchantDto reqDto) {
return CzgResult.success(shopDirectMerchantService.entryManager(reqDto));
}
}

View File

@@ -1,68 +0,0 @@
package com.czg.controller.admin;
import com.czg.order.dto.FinanceStsDTO;
import com.czg.order.param.FinanceStsQueryParam;
import com.czg.order.param.SaleSummaryCountParam;
import com.czg.order.service.FinanceStsService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 管理端/财务报表
* @author yjjie
* @date 2026/2/2 10:09
*/
@RestController
@RequestMapping("/admin/finance")
public class FinanceStsController {
@Resource
private FinanceStsService financeStsService;
/**
* 查询财务报表
*/
@GetMapping("/sts")
public CzgResult<FinanceStsDTO> getFinanceSts(@Validated(FinanceStsQueryParam.Query.class) FinanceStsQueryParam param) {
return CzgResult.success(financeStsService.getFinanceSts(param));
}
/**
* 导出财务报表
*/
@GetMapping("/export")
public void exportFinanceSts(@Validated(FinanceStsQueryParam.Export.class) FinanceStsQueryParam param, HttpServletResponse response) {
financeStsService.exportFinanceSts(param, response);
}
/**
* 打印经营日报
*/
@GetMapping("/printDayReport")
public CzgResult<Void> printDayReport(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
financeStsService.printDayReport(param);
return CzgResult.success();
}
/**
* 打印日结单
*/
@GetMapping("/printDaySettle")
public CzgResult<Void> printDaySettle(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
financeStsService.printDaySettle(param);
return CzgResult.success();
}
}

View File

@@ -1,70 +0,0 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.log.annotation.OperationLog;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.service.GbOrderService;
import com.czg.order.vo.GbOrderDetailVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 拼团商品
*
* @author ww
*/
@RestController
@RequestMapping("/admin/gbOrder")
public class GbOrderController {
@Resource
private GbOrderService orderService;
/**
* 拼团商品:订单列表
*/
@GetMapping("page")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:order:list", name = "拼团商品-订单列表")
public CzgResult<Page<GbOrderDetailVO>> getGbOrderPage(GbOrderQueryParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
Page<GbOrderDetailVO> page = orderService.getGbOrderPage(param);
return CzgResult.success(page);
}
/**
* 拼团商品:核销
*
* @param verifyCode 核销码
*/
@PostMapping("checkout")
@OperationLog("拼团商品-核销")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:order:checkout", name = "拼团商品-核销")
public CzgResult<Boolean> checkout(@RequestBody String verifyCode) {
return CzgResult.success(orderService.checkout(verifyCode, StpKit.USER.getShopId()));
}
/**
* 退单/同意退单
*/
@PostMapping("/agreeRefund")
public CzgResult<Boolean> agreeRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(orderService.agreeRefund(param, StpKit.USER.getShopId()));
}
/**
* 驳回退单
*/
@PostMapping("/rejectRefund")
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(orderService.cancelRefund(param, null, StpKit.USER.getShopId()));
}
}

View File

@@ -1,99 +0,0 @@
package com.czg.controller.admin;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.market.dto.GbWareDTO;
import com.czg.market.dto.GbWareQueryParamDTO;
import com.czg.market.entity.GbWare;
import com.czg.market.service.GbWareService;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.service.GbOrderService;
import com.czg.order.vo.GbOrderCountVO;
import com.czg.order.vo.GbWareVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* 拼团商品
*
* @author ww
*/
@Slf4j
@RestController
@RequestMapping("/admin/ware")
public class GbWareController {
@Resource
private GbWareService wareService;
@Resource
private GbOrderService gbOrderService;
@PostMapping("/upShopConfig")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:up", name = "拼团商品-修改")
public CzgResult<Boolean> upShopConfig(@RequestBody GbWareDTO param) {
AssertUtil.isNull(param.getOnlineStatus(), "操作失败,请选择状态");
return CzgResult.success(gbOrderService.upShopConfig(param.getOnlineStatus(), StpKit.USER.getShopId()));
}
/**
* 拼团商品统计
*/
@GetMapping("/ware/count")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:list", name = "拼团商品-列表")
public CzgResult<GbOrderCountVO> getWareCount(GbOrderQueryParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
return CzgResult.success(gbOrderService.countOrder(param));
}
@GetMapping("/getGbWarePage")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:list", name = "拼团商品-列表")
public CzgResult<Page<GbWare>> getGbWarePage(GbWareQueryParamDTO param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
return CzgResult.success(wareService.getGbWarePage(param, param.getShopId(), true));
}
@PostMapping("/addGbWare")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:add", name = "拼团商品-新增")
public CzgResult<Boolean> addGbWare(@RequestBody @Validated GbWareDTO param) {
return CzgResult.success(wareService.addGbWare(param));
}
@PostMapping("/editOnlineStatus")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:up", name = "拼团商品-修改")
public CzgResult<Boolean> editGbWareOnlineStatus(@RequestBody GbWareDTO param) {
AssertUtil.isNull(param.getId(), "操作失败,请选择商品");
AssertUtil.isNull(param.getOnlineStatus(), "操作失败,请选择商品状态");
return CzgResult.success(gbOrderService.editGbWareOnlineStatus(param.getId(), param.getOnlineStatus()));
}
@PostMapping("/updateGbWareById")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:up", name = "拼团商品-修改")
public CzgResult<Boolean> updateGbWareById(@RequestBody @Validated GbWareDTO param) {
return CzgResult.success(wareService.updateGbWareById(param));
}
@DeleteMapping("/deleteGbWare/{id}")
@SaAdminCheckPermission(parentName = "拼团商品", value = "ware:info:del", name = "拼团商品-删除")
public CzgResult<Boolean> deleteGbWare(@PathVariable("id") Long id) {
AssertUtil.isNull(id, "操作失败,请选择商品");
return CzgResult.success(wareService.deleteGbWare(id));
}
/**
* 拼团商品详情
*/
@GetMapping("/ware/detail")
public CzgResult<GbWareVO> getWareDetail(@RequestParam Long shopId, @RequestParam Long wareId) {
return CzgResult.success(gbOrderService.getWareDetail(shopId, wareId, null));
}
}

View File

@@ -6,7 +6,7 @@ import com.czg.log.annotation.OperationLog;
import com.czg.market.dto.MkPointsGoodsRecordDTO;
import com.czg.market.dto.MkPointsGoodsRecordQueryDTO;
import com.czg.market.service.MkPointsGoodsRecordService;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.PointGoodsRefundDTO;
import com.czg.order.service.PointsGoodPayService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
@@ -68,7 +68,7 @@ public class PointsGoodsRecordController {
* 退单/同意退单
*/
@PostMapping("/agreeRefund")
public CzgResult<Boolean> agreeRefund(@RequestBody @Validated CommonRefundDTO param) {
public CzgResult<Boolean> agreeRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
return CzgResult.success(goodPayService.agreeRefund(param, StpKit.USER.getShopId()));
}
@@ -76,7 +76,7 @@ public class PointsGoodsRecordController {
* 驳回退单
*/
@PostMapping("/rejectRefund")
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated CommonRefundDTO param) {
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
return CzgResult.success(goodPayService.cancelRefund(param, null, StpKit.USER.getShopId()));
}

View File

@@ -1,85 +0,0 @@
package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.enums.OrderNoPrefixEnum;
import com.czg.log.annotation.OperationLog;
import com.czg.market.dto.PpPackageOrderDTO;
import com.czg.market.service.PpPackageOrderService;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.service.PayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgRandomUtils;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 管理端/套餐推广
*
* @author yjjie
* @date 2025/12/18 19:26
*/
@RestController
@RequestMapping("/admin/ppOrder")
public class PpOrderController {
@DubboReference
private PpPackageOrderService ppPackageOrderService;
@Resource
private PayService payService;
/**
* 确认退单
*/
@PostMapping("/confirmRefund")
@Transactional
public CzgResult<Boolean> confirmRefund(@RequestBody @Validated CommonRefundDTO param) {
PpPackageOrderDTO detail = ppPackageOrderService.getOrderDetailById(param.getRecordId(), StpKit.USER.getLoginIdAsLong());
if (detail == null) {
return CzgResult.failure("订单不存在");
}
ppPackageOrderService.confirmRefund(param.getRecordId(), StpKit.USER.getShopId());
//退钱
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REPP);
payService.unifyRefund(detail.getShopId(), detail.getId(), detail.getPayOrderId(), refPayOrderNo,
StrUtil.isBlankIfStr(detail.getRefundReason()) ? "套餐推广退款" : detail.getRefundReason(), detail.getFinalPrice());
return CzgResult.success();
}
/**
* 驳回退单
*/
@PostMapping("/rejectRefund")
public CzgResult<Boolean> rejectRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(ppPackageOrderService.cancelRefund(param.getRecordId(),
StpKit.USER.getLoginIdAsLong(), param.getReason()));
}
/**
* 套餐推广-核销
* 参数: {"verifyCode": "123456"}
*/
@PostMapping("checkout")
@OperationLog("套餐推广-核销")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:checkout", name = "套餐推广-核销")
public CzgResult<Boolean> checkout(@RequestBody JSONObject param) {
AssertUtil.isNull(param, "核销码不能为空");
String verifyCode = param.getString("verifyCode");
AssertUtil.isBlank(verifyCode, "核销码不能为空");
return CzgResult.success(ppPackageOrderService.checkout(verifyCode, StpKit.USER.getShopId()));
}
}

View File

@@ -1,22 +1,20 @@
package com.czg.controller.admin;
import com.czg.excel.ExcelExportUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopProdStatistic;
import com.czg.order.param.SaleSummaryCountParam;
import com.czg.order.service.ShopProdStatisticService;
import com.czg.order.vo.SaleSummaryCountVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.List;
/**
@@ -37,6 +35,7 @@ public class SaleSummaryController {
* 统计
*/
@GetMapping("count")
@OperationLog("统计")
//@SaAdminCheckPermission("saleSummary:count")
public CzgResult<SaleSummaryCountVo> summaryCount(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
@@ -50,6 +49,7 @@ public class SaleSummaryController {
* 分页
*/
@GetMapping("page")
@OperationLog("分页")
//@SaAdminCheckPermission("saleSummary:page")
public CzgResult<List<ShopProdStatistic>> summaryPage(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
@@ -59,37 +59,13 @@ public class SaleSummaryController {
return CzgResult.success(list);
}
/**
* 商品报表导出
*/
@ResponseExcel(name = "销售统计明细")
@GetMapping("/export")
public void summaryExport(SaleSummaryCountParam param, HttpServletResponse response) {
public List<ShopProdStatistic> summaryExport(SaleSummaryCountParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
ExcelExportUtil.exportToResponse(prodStatisticService.getArchiveTradeData(param), ShopProdStatistic.class, "销售统计明细", response);
return prodStatisticService.getArchiveTradeData(param);
}
/**
* 商品报表打印
*/
@GetMapping("/print")
public CzgResult<Void> summaryPrint(SaleSummaryCountParam param) {
LocalDateTime now = LocalDateTime.now();
LocalTime nowTime = now.toLocalTime();
// 起始 00:00结束 05:20
LocalTime start = LocalTime.of(0, 0);
LocalTime end = LocalTime.of(5, 20);
if (nowTime.isAfter(start) && nowTime.isBefore(end)) {
// 在 00:00 ~ 05:20 区间内
return CzgResult.failure("当前时间不支持打印打印时间5点20至24点");
}
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
prodStatisticService.summaryPrint(param);
return CzgResult.success();
}
}

View File

@@ -1,36 +0,0 @@
package com.czg.controller.admin;
import com.czg.order.entity.SysPrintData;
import com.czg.order.service.SysPrintDataService;
import com.czg.resp.CzgResult;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 打印数据
*
* @author ww
*/
@RestController
@RequestMapping("/admin/printData")
public class SysPrintDataController {
@Resource
private SysPrintDataService sysPrintDataService;
/**
* 获取打印数据
*/
@GetMapping
public CzgResult<SysPrintData> getWareCount(@RequestParam Long shopId, @RequestParam Long dataId, @RequestParam String type) {
return CzgResult.success(sysPrintDataService.getOne(new QueryWrapper()
.eq(SysPrintData::getType, type)
.eq(SysPrintData::getShopId, shopId)
.eq(SysPrintData::getId, dataId)));
}
}

View File

@@ -1,15 +1,18 @@
package com.czg.controller.admin;
import com.czg.handel.ExcelMergeHandler;
import com.czg.handel.TableRefundCellHandel;
import com.czg.log.annotation.OperationLog;
import com.czg.order.entity.ShopTableOrderStatistic;
import com.czg.order.param.DataSummaryTradeParam;
import com.czg.order.param.TableSummaryParam;
import com.czg.order.service.ShopTableOrderStatisticService;
import com.czg.order.service.TableSummaryService;
import com.czg.order.vo.TableSummaryExportVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.pig4cloud.plugin.excel.annotation.ResponseExcel;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -51,14 +54,15 @@ public class TableSummaryController {
/**
* 导出
*/
@ResponseExcel(name = "台桌统计", writeHandler = {ExcelMergeHandler.class, TableRefundCellHandel.class})
@GetMapping("export")
@OperationLog("导出")
//@SaAdminCheckPermission("tableSummary:export")
public void summaryExport(TableSummaryParam param, HttpServletResponse response) {
public List<TableSummaryExportVo> summaryExport(TableSummaryParam param) {
if (param.getShopId() == null) {
param.setShopId(StpKit.USER.getShopId());
}
tableSummaryService.summaryExportList(param, response);
return tableSummaryService.summaryExportList(param);
}
}

View File

@@ -1,53 +0,0 @@
package com.czg.controller.pay;
import com.czg.annotation.Debounce;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.resp.CzgResult;
import com.czg.service.order.service.DistributionPayService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 分销员开通
*
* @author ww
* @description
*/
@RestController
@RequestMapping("/pay/distribution")
public class DistributionPayController {
@Resource
private DistributionPayService payService;
/**
* 小程序支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* openId 必填
*/
@PostMapping("/ltPayOrder")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, Object>> ltPayOrder(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
}
/**
* 运营端小程序余额充值
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
*/
@PostMapping("/mchRecharge")
@Debounce(value = "#payParam.userId")
public CzgResult<Map<String, String>> mchRecharge(@Validated @RequestBody MkDistributionPayDTO payParam) {
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
return CzgResult.success(payService.mchRecharge(payParam));
}
}

View File

@@ -1,118 +0,0 @@
package com.czg.controller.user;
import com.czg.market.dto.GbWareQueryParamDTO;
import com.czg.market.entity.GbWare;
import com.czg.market.service.GbWareService;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.GbOrderQueryParam;
import com.czg.order.dto.GroupJoinDTO;
import com.czg.order.service.GbOrderService;
import com.czg.order.vo.GbOrderDetailVO;
import com.czg.order.vo.GbWareVO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.ServletUtil;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 用户拼团
*
* @author ww
*/
@RestController
@RequestMapping("/user/gbOrder")
public class UGbOrderController {
@Resource
private GbOrderService orderService;
@Resource
private GbWareService wareService;
/**
* 商品列表
*/
@GetMapping("/ware/page")
public CzgResult<Page<GbWare>> getPointsGoodsSettingPage(@RequestParam(defaultValue = "1", required = false) Integer page,
@RequestParam(defaultValue = "10", required = false) Integer size,
@RequestParam(required = false) String wareName,
@RequestParam(required = false) Integer groupPeopleNum,
Long shopId) {
GbWareQueryParamDTO param = new GbWareQueryParamDTO();
param.setPage(page);
param.setSize(size);
param.setOnlineStatus(1);
param.setWareName(wareName);
param.setGroupPeopleNum(groupPeopleNum);
Page<GbWare> data = wareService.getGbWarePage(param, shopId, false);
return CzgResult.success(data);
}
/**
* 拼团商品详情
*/
@GetMapping("/ware/detail")
public CzgResult<GbWareVO> getWareDetail(@RequestParam Long shopId, @RequestParam Long wareId) {
return CzgResult.success(orderService.getWareDetail(shopId, wareId, StpKit.USER.getLoginIdAsLong()));
}
/**
* 我的拼团记录
*/
@GetMapping("/record/page")
public CzgResult<Page<GbOrderDetailVO>> getGoodsRecordPage(GbOrderQueryParam param) {
param.setUserId(StpKit.USER.getLoginIdAsLong());
Page<GbOrderDetailVO> pages = orderService.getGbOrderPage(param);
return CzgResult.success(pages);
}
/**
* 拼团订单详情
*/
@GetMapping("/record/detail")
public CzgResult<GbOrderDetailVO> getGoodsRecordDetail(
@RequestParam Long shopId,
@RequestParam(required = false) Long detailId,
@RequestParam(required = false) String groupOrderNo) {
return CzgResult.success(orderService.getGoodsRecordDetail(shopId, detailId, groupOrderNo));
}
/**
* 生成订单
* 小程序支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* openId 必填
*/
@PostMapping("/exchange")
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody GroupJoinDTO param) {
param.setUserId(StpKit.USER.getLoginIdAsLong());
param.setIp(ServletUtil.getClientIP(request));
return orderService.groupJoin(param);
}
/**
* 申请退单
*/
@PostMapping("/applyRefund")
public CzgResult<Boolean> applyRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(orderService.applyRefund(param, StpKit.USER.getLoginIdAsLong()));
}
/**
* 取消退单
*/
@PostMapping("/cancelRefund")
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(orderService.cancelRefund(param, StpKit.USER.getLoginIdAsLong(), null));
}
}

View File

@@ -1,13 +1,10 @@
package com.czg.controller.user;
import com.czg.market.entity.MkPointsGoods;
import com.czg.market.entity.MkPointsGoodsRecord;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.service.MkPointsGoodsRecordService;
import com.czg.market.service.MkPointsGoodsService;
import com.czg.market.service.ShopCouponService;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.dto.PointGoodsExchangeDTO;
import com.czg.order.dto.PointGoodsRefundDTO;
import com.czg.order.service.PointsGoodPayService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
@@ -37,8 +34,6 @@ public class UPointGoodsController {
private MkPointsGoodsRecordService goodsRecordService;
@Resource
private PointsGoodPayService goodPayService;
@Resource
private ShopCouponService shopCouponService;
/**
* 商品列表
@@ -56,40 +51,23 @@ public class UPointGoodsController {
return CzgResult.success(data);
}
/**
* 商品详情
*/
@GetMapping("/{id}")
public CzgResult<MkPointsGoods> getPointsGoodsSettingById(@PathVariable("id") Long id) {
MkPointsGoods goods = pointsGoodsService.getById(id);
if ("优惠券".equals(goods.getGoodsCategory())) {
ShopCoupon one = shopCouponService.getOne(QueryWrapper.create().eq(ShopCoupon::getId, goods.getCouponId())
.eq(ShopCoupon::getShopId, goods.getShopId())
.eq(ShopCoupon::getStatus, 1)
.eq(ShopCoupon::getIsDel, 0));
goods.setCouponInfo(one);
}
return CzgResult.success(goods);
}
/**
* 生成订单
* 小程序支付
* payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信
* openId 必填
*/
@PostMapping("/exchange")
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody LtPayOtherDTO param) {
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody PointGoodsExchangeDTO param) {
param.setUserId(StpKit.USER.getLoginIdAsLong());
param.setIp(ServletUtil.getClientIP(request));
return goodPayService.exchange(param);
return goodPayService.exchange(ServletUtil.getClientIP(request), param);
}
/**
* 申请退单
*/
@PostMapping("/applyRefund")
public CzgResult<Boolean> applyRefund(@RequestBody @Validated CommonRefundDTO param) {
public CzgResult<Boolean> applyRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
return CzgResult.success(goodPayService.applyRefund(param, StpKit.USER.getLoginIdAsLong()));
}
@@ -97,7 +75,7 @@ public class UPointGoodsController {
* 取消退单
*/
@PostMapping("/cancelRefund")
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated CommonRefundDTO param) {
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated PointGoodsRefundDTO param) {
return CzgResult.success(goodPayService.cancelRefund(param, StpKit.USER.getLoginIdAsLong(), null));
}

View File

@@ -1,110 +0,0 @@
package com.czg.controller.user;
import com.czg.market.dto.PpPackageOrderDTO;
import com.czg.market.entity.PpPackageOrder;
import com.czg.market.service.PpPackageOrderService;
import com.czg.market.vo.PpPackageVO;
import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.LtPayOtherDTO;
import com.czg.constants.PayTypeConstants;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.service.PayService;
import com.czg.utils.ServletUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* 用户端/套餐推广
*
* @author yjjie
* @date 2025/12/18 18:54
*/
@Slf4j
@RestController
@RequestMapping("/user/ppOrder")
public class UPpOrderController {
@DubboReference
private PpPackageOrderService ppPackageOrderService;
@Resource
private PayService payService;
/**
* 小程序支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* openId 必填
*/
@PostMapping("/pay")
@Transactional
public CzgResult<Map<String, Object>> exchange(HttpServletRequest request, @Validated @RequestBody LtPayOtherDTO param) {
param.setUserId(StpKit.USER.getLoginIdAsLong());
param.setIp(ServletUtil.getClientIP(request));
param.setRecordId(param.getParamId());
PpPackageOrderDTO detail = ppPackageOrderService.getOrderDetailById(param.getRecordId(), StpKit.USER.getLoginIdAsLong());
PpPackageVO packageInfo = detail.getPackageInfo();
// 计算订单金额
BigDecimal price = packageInfo.getPrice();
// 如果存在优惠层级 并且 分享人数大于 0 则计算新的价格
if (packageInfo.getTieredDiscount() != null && !packageInfo.getTieredDiscount().isEmpty() && detail.getShareNum() > 0) {
// 倒序遍历优惠层级
for (int i = packageInfo.getTieredDiscount().size() - 1; i >= 0; i--) {
PpPackageVO.TieredDiscount tieredDiscount = packageInfo.getTieredDiscount().get(i);
if (detail.getShareNum() >= tieredDiscount.getPeopleNum()) {
price = tieredDiscount.getPrice();
break;
}
}
}
param.setPrice(price);
log.info("用户【{}】进行套餐推广支付, 分享人数【{}】,订单金额【{}】", StpKit.USER.getLoginIdAsLong(), detail.getShareNum(), price);
CzgResult<Map<String, Object>> result = CzgResult.success();
CzgResult<Map<String, Object>> mapCzgResult = payService.ltPayOther(param, PayTypeConstants.SourceType.PP, "套餐推广购买");
if (200 != mapCzgResult.getCode()) {
return mapCzgResult;
}
Map<String, Object> resultMap = new HashMap<>(1);
resultMap.put("payInfo", mapCzgResult.getData());
resultMap.put("record", detail.getId());
result.setData(resultMap);
PpPackageOrder order = ppPackageOrderService.getById(param.getRecordId());
order.setFinalPrice(price);
ppPackageOrderService.updateById(order);
return result;
}
/**
* 申请退单
*/
@PostMapping("/applyRefund")
public CzgResult<Boolean> applyRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(ppPackageOrderService.applyRefund(param.getRecordId(), StpKit.USER.getLoginIdAsLong(), param.getReason()));
}
/**
* 取消退单
*/
@PostMapping("/cancelRefund")
public CzgResult<Boolean> cancelRefund(@RequestBody @Validated CommonRefundDTO param) {
return CzgResult.success(ppPackageOrderService.cancelRefund(param.getRecordId(), StpKit.USER.getLoginIdAsLong(), ""));
}
}

View File

@@ -0,0 +1,151 @@
package com.czg.handel;
import cn.idev.excel.metadata.Head;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.write.handler.CellWriteHandler;
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import java.util.List;
/**
* @author tankaikai
* @since 2025-04-01 18:41
*/
public class ExcelMergeHandler implements CellWriteHandler {
// 要合并的列索引数组
private int[] mergeColumnIndex = {0, 1, 2, 3, 8, 9};
// 合并开始的行索引
private int mergeRowIndex = 1;
public ExcelMergeHandler() {
}
/**
* 构造函数
*
* @param mergeRowIndex 合并开始的行索引
* @param mergeColumnIndex 要合并的列索引数组
*/
public ExcelMergeHandler(int mergeRowIndex, int[] mergeColumnIndex) {
this.mergeRowIndex = mergeRowIndex;
this.mergeColumnIndex = mergeColumnIndex;
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
// 当前行索引
int curRowIndex = cell.getRowIndex();
// 当前列索引
int curColIndex = cell.getColumnIndex();
// 如果当前行大于合并开始行且当前列在需要合并的列中
if (curRowIndex > mergeRowIndex && isMergeColumn(curColIndex)) {
// 进行合并操作
mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
}
}
/**
* 检查当前列是否在需要合并的列中
*
* @param curColIndex 当前列索引
* @return 如果是需要合并的列返回true否则返回false
*/
private boolean isMergeColumn(int curColIndex) {
for (int columnIndex : mergeColumnIndex) {
if (curColIndex == columnIndex) {
return true;
}
}
return false;
}
/**
* 当前单元格向上合并
*
* @param writeSheetHolder 当前工作表持有者
* @param cell 当前单元格
* @param curRowIndex 当前行索引
* @param curColIndex 当前列索引
*/
private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
// 获取当前单元格的数据
Object curData = getCellData(cell);
// 获取前一个单元格的数据
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
Object preData = getCellData(preCell);
// 判断当前单元格和前一个单元格的数据以及主键是否相同
if (curData.equals(preData) && isSamePrimaryKey(cell, curRowIndex)) {
// 获取工作表
Sheet sheet = writeSheetHolder.getSheet();
// 合并单元格
mergeCells(sheet, curRowIndex, curColIndex);
CellStyle style = preCell.getCellStyle();
// 设置水平居中
style.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
preCell.setCellStyle(style);
}
}
/**
* 获取单元格的数据
*
* @param cell 单元格
* @return 单元格数据
*/
private Object getCellData(Cell cell) {
return cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
}
/**
* 判断当前单元格和前一个单元格的主键是否相同
*
* @param cell 当前单元格
* @param curRowIndex 当前行索引
* @return 如果主键相同返回true否则返回false
*/
private boolean isSamePrimaryKey(Cell cell, int curRowIndex) {
String currentPrimaryKey = cell.getRow().getCell(0).getStringCellValue();
String previousPrimaryKey = cell.getSheet().getRow(curRowIndex - 1).getCell(0).getStringCellValue();
return currentPrimaryKey.equals(previousPrimaryKey);
}
/**
* 合并单元格
*
* @param sheet 工作表
* @param curRowIndex 当前行索引
* @param curColIndex 当前列索引
*/
private void mergeCells(Sheet sheet, int curRowIndex, int curColIndex) {
// 获取已合并的区域
List<CellRangeAddress> mergeRegions = sheet.getMergedRegions();
boolean isMerged = false;
// 检查前一个单元格是否已经被合并
for (int i = 0; i < mergeRegions.size() && !isMerged; i++) {
CellRangeAddress cellRangeAddr = mergeRegions.get(i);
if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
sheet.removeMergedRegion(i);
cellRangeAddr.setLastRow(curRowIndex);
sheet.addMergedRegion(cellRangeAddr);
isMerged = true;
}
}
// 如果前一个单元格未被合并,则新增合并区域
if (!isMerged) {
CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
sheet.addMergedRegion(cellRangeAddress);
}
}
}

View File

@@ -0,0 +1,55 @@
package com.czg.handel;
import cn.hutool.core.util.ArrayUtil;
import cn.idev.excel.metadata.Head;
import cn.idev.excel.metadata.data.WriteCellData;
import cn.idev.excel.write.handler.CellWriteHandler;
import cn.idev.excel.write.metadata.holder.WriteSheetHolder;
import cn.idev.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.*;
import java.util.List;
/**
* 台桌统计退单单元格处理器
*
* @author tankaikai
* @since 2025-04-02 09:50
*/
public class TableRefundCellHandel implements CellWriteHandler {
// 要处理的列索引数组
private int[] yellowColumnIndex = {10, 11};
public TableRefundCellHandel() {
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
// 当前行索引
int curRowIndex = cell.getRowIndex();
// 当前列索引
int curColIndex = cell.getColumnIndex();
if (curRowIndex == 0) {
return;
}
// 如果是指定要处理的列,则要进行加黄操作
if (ArrayUtil.contains(yellowColumnIndex, curColIndex)) {
Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
if (preCell.getCellType() == CellType.NUMERIC) {
if (preCell.getNumericCellValue() < 0) {
//System.out.println("设置黄色背景:" + curRowIndex + "行," + curColIndex + "列" + preCell.getNumericCellValue());
CellStyle style = preCell.getSheet().getWorkbook().createCellStyle();
style.cloneStyleFrom(preCell.getCellStyle());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
// 设置水平居中
style.setAlignment(HorizontalAlignment.CENTER);
// 设置垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
preCell.setCellStyle(style);
}
}
}
}
}

View File

@@ -1,144 +0,0 @@
package com.czg.mq;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.EntryManager;
import com.czg.PayCst;
import com.czg.config.RabbitConstants;
import com.czg.config.RedisCst;
import com.czg.dto.resp.EntryRespDto;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.service.RedisService;
import com.czg.service.order.dto.AggregateMerchantVO;
import com.czg.service.order.service.ShopDirectMerchantService;
import com.mybatisflex.core.query.QueryWrapper;
import com.rabbitmq.client.Channel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.ThreadContext;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 打印mq消息处理器
*
* @author Administrator
*/
@Component
@Slf4j
public class EntryManagerMqListener {
@Resource
private RedisService redisService;
@Resource
private ShopDirectMerchantService shopDirectMerchantService;
String key = RedisCst.SHOP_ENTRY;
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(value = "${spring.profiles.active}-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER,
durable = "true", exclusive = "false", autoDelete = "false"),
exchange = @Exchange(value = "${spring.profiles.active}-" + RabbitConstants.Exchange.CASH_EXCHANGE),
key = "${spring.profiles.active}-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER
),
concurrency = "5"
)
@RabbitHandler
public void handle(Message message, Channel channel, String msg) throws IOException {
log.info("进件1MQ对接开始 店铺标识:{}", msg);
long deliveryTag = message.getMessageProperties().getDeliveryTag();
if (StrUtil.isBlank(msg)) {
channel.basicNack(deliveryTag, false, false);
return;
}
String[] split = msg.split(":");
if (split.length != 2) {
log.error("进件MQ对接参数异常 店铺标识:{}", msg);
channel.basicNack(deliveryTag, false, false);
return;
}
if (split[0]==null) {
channel.basicNack(deliveryTag, false, false);
return;
}
Long shopId = Long.valueOf(split[0]);
if (hasMessageId(msg)) {
return;
}
try {
// 将唯一标识添加到日志上下文
ThreadContext.put("traceId", String.valueOf(shopId));
log.info("进件2MQ对接开始shopId:{}", msg);
// 安全转换shopId
AggregateMerchantVO entry = shopDirectMerchantService.getEntry(shopId);
log.info("进件3MQ对接开始shopId:{}", msg);
if (entry != null) {
EntryManager.uploadParamImage(entry);
List<String> platform = new ArrayList<>();
if (PayCst.EntryStatus.WAIT.equals(entry.getAlipayStatus())) {
platform.add(PayCst.Type.ALIPAY);
}
if (PayCst.EntryStatus.WAIT.equals(entry.getWechatStatus())) {
platform.add(PayCst.Type.WECHAT);
}
EntryRespDto resp = EntryManager.entryMerchant(entry, platform.toArray(new String[0]));
ShopDirectMerchant merchant = new ShopDirectMerchant();
merchant.setMerchantBaseInfo(JSONObject.toJSONString(entry.getMerchantBaseInfo()));
merchant.setLegalPersonInfo(JSONObject.toJSONString(entry.getLegalPersonInfo()));
merchant.setBusinessLicenceInfo(JSONObject.toJSONString(entry.getBusinessLicenceInfo()));
merchant.setStoreInfo(JSONObject.toJSONString(entry.getStoreInfo()));
merchant.setSettlementInfo(JSONObject.toJSONString(entry.getSettlementInfo()));
merchant.setWechatApplyId(resp.getWechatApplyId());
merchant.setWechatStatus(resp.getWechatStatus());
merchant.setWechatErrorMsg(resp.getWechatErrorMsg());
merchant.setAlipayOrderId(resp.getAlipayOrderId());
merchant.setAlipayStatus(resp.getAlipayStatus());
merchant.setAlipayAuthInfo(resp.getAlipayAuthInfo());
merchant.setAlipayErrorMsg(resp.getAlipayErrorMsg());
shopDirectMerchantService.update(merchant, new QueryWrapper().eq(ShopDirectMerchant::getShopId, shopId).eq(ShopDirectMerchant::getLicenceNo, split[1]));
}
channel.basicAck(deliveryTag, false);
} catch (Exception e) {
log.error("进件MQ对接业务异常shopId:{}", msg, e);
ShopDirectMerchant merchant = new ShopDirectMerchant();
merchant.setWechatStatus(PayCst.EntryStatus.REJECTED);
merchant.setAlipayStatus(PayCst.EntryStatus.REJECTED);
merchant.setErrorMsg("系统错误,请联系管理员后重试。");
shopDirectMerchantService.update(merchant, new QueryWrapper().eq(ShopDirectMerchant::getShopId, shopId).eq(ShopDirectMerchant::getLicenceNo, split[1]));
channel.basicNack(deliveryTag, false, false);
} finally {
delMessageId(msg);
// 清除日志上下文信息
ThreadContext.remove("messageId");
}
}
public boolean hasMessageId(String messageId) {
if (!redisService.hasKey(key)) {
if (StrUtil.isNotBlank(messageId)) {
redisService.leftPush(key, messageId);
return false;
} else {
return true;
}
}
List<Object> list = redisService.lGet(key, 0, -1);
if (!list.contains(messageId)) {
redisService.leftPush(key, messageId);
return false;
}
return true;
}
public void delMessageId(String messageId) {
redisService.lRemove(key, 0, messageId);
}
}

View File

@@ -2,13 +2,14 @@ package com.czg.mq;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RabbitConstants;
import com.czg.order.entity.MqLog;
import com.czg.order.service.MqLogService;
import com.czg.order.service.OrderInfoCustomService;
import com.czg.order.service.OrderInfoRpcService;
import com.czg.service.RedisService;
import com.czg.service.order.utils.FunUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
@@ -30,7 +31,7 @@ public class OrderMqListener {
@Resource
private OrderInfoCustomService orderInfoCustomService;
@Resource
private RedisService redisService;
private FunUtil funUtil;
/**
* 订单上菜
@@ -43,10 +44,13 @@ public class OrderMqListener {
info = info.replace("UP_ORDER_DETAIL:", "");
log.info("接收到修改菜品状态mq, info: {}", info);
String finalInfo = info;
redisService.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
funUtil.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
orderInfoCustomService.updateOrderDetailStatus(Long.valueOf(finalInfo));
});
info = info.replace("UP_ORDER_DETAIL:", "");
System.out.println(info);
}
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE})
@@ -70,10 +74,10 @@ public class OrderMqListener {
public void orderStockRecover(String orderId) {
long startTime = DateUtil.date().getTime();
log.info("接收到订单取消恢复库存消息:{}", orderId);
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_CANCEL_QUEUE).setMsg(orderId).setType("orderStockRecover").setPlat("java.order").setCreateTime(DateUtil.date().toLocalDateTime());
try {
orderInfoRpcService.orderCancelCallback(Long.valueOf(orderId));
} catch (Exception e) {
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_CANCEL_QUEUE).setMsg(orderId).setType("orderStockRecover").setPlat("java.order").setCreateTime(DateUtil.date().toLocalDateTime());
log.error("订单取消恢复库存失败", e);
String errorInfo = ExceptionUtil.stacktraceToString(e);
mqLog.setErrInfo(errorInfo);
@@ -87,10 +91,11 @@ public class OrderMqListener {
public void orderStockReturn(String jsonObjStr) {
long startTime = DateUtil.date().getTime();
log.info("接收到订单退款返还库存消息:{}", jsonObjStr);
try {
orderInfoRpcService.orderRefundCallback(JSONObject.parseObject(jsonObjStr));
} catch (Exception e) {
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_REFUND_QUEUE).setMsg(jsonObjStr).setType("orderStockReturn").setPlat("java.order").setCreateTime(DateUtil.date().toLocalDateTime());
try {
JSONObject data = JSON.parseObject(jsonObjStr);
orderInfoRpcService.orderRefundCallback(data);
} catch (Exception e) {
log.error("订单退款返还库存失败", e);
String errorInfo = ExceptionUtil.stacktraceToString(e);
mqLog.setErrInfo(errorInfo);

View File

@@ -1,23 +1,18 @@
package com.czg.mq;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RabbitConstants;
import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.exception.CzgException;
import com.czg.order.entity.MqLog;
import com.czg.order.entity.SysPrintData;
import com.czg.order.service.MqLogService;
import com.czg.order.service.SysPrintDataService;
import com.czg.service.RedisService;
import com.czg.service.order.print.PrintConfig;
import com.czg.service.order.print.PrinterHandler;
import com.czg.service.order.utils.FunUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;
import java.util.function.Consumer;
@@ -33,18 +28,19 @@ public class PrintMqListener {
@Resource
private MqLogService mqLogService;
@Resource
private RedisService redisService;
@Resource
private PrintConfig printConfig;
@Resource
private RabbitPublisher rabbitPublisher;
@Resource
protected SysPrintDataService printDataService;
private FunUtil funUtil;
private <T> void invokeFun(String queue, String type, String plat, T data, Consumer<T> consumer) {
// 注入自定义线程池(建议单独配置,避免使用默认线程池)
@Resource
private ThreadPoolTaskExecutor asyncExecutor;
@Lazy
@Resource
private PrinterHandler printerHandler;
private <T> void invokeFun(String type, String plat, T data, Consumer<T> consumer) {
long startTime = DateUtil.date().getTime();
log.info("接收到{}打印消息:{}", type, data);
MqLog mqLog = new MqLog().setQueue(queue).setMsg(data.toString())
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE).setMsg(data.toString())
.setType(type).setPlat(plat).setCreateTime(DateUtil.date().toLocalDateTime());
try {
consumer.accept(data);
@@ -60,63 +56,60 @@ public class PrintMqListener {
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE})
public void orderPrint(String req) {
// 执行核心打印逻辑
invokeFun(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, "orderPrint", "java.order", req, (data) -> {
invokeFun("orderPrint", "java.order", req, (data) -> {
JSONObject jsonObject = JSONObject.parseObject(data);
String orderIdStr = jsonObject.getString("orderId");
if (StrUtil.isBlank(orderIdStr)) {
String orderId = jsonObject.getString("orderId");
if (orderId == null) {
throw new RuntimeException("订单打印失败未传递orderId");
}
String[] split = orderIdStr.split("_");
if (split.length < 3) {
throw new CzgException("订单ID格式不正确" + orderIdStr);
}
Long orderId = Long.parseLong(split[0]);
//付费类型 0后付费/1先付费
Integer payType = Integer.parseInt(split[1]);
//订单状态 0未完成/1完成
Integer orderStatus = Integer.parseInt(split[2]);
//该字段表示 网络打印机是否打印订单 本地传参来的
// Boolean printOrder = jsonObject.getBoolean("printOrder");
redisService.runFunAndCheckKey(() -> {
if (orderStatus == 1) {
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ORDER, null);
}
if (payType == 1 || orderStatus == 0) {
//菜品打印 全是后端
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ALL_KITCHEN, null);
printConfig.orderHandler(orderId, PrinterHandler.PrintTypeEnum.ONLY_KITCHEN, null);
}
Boolean printOrder = jsonObject.getBoolean("printOrder");
funUtil.runFunAndCheckKey(() -> {
printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
return null;
}, RedisCst.getLockKey("orderPrint", orderId));
});
// // 使用异步线程池执行延迟任务,不阻塞当前消费者线程
// CompletableFuture.runAsync(() -> {
// try {
// // 延迟3秒处理
// TimeUnit.SECONDS.sleep(3);
// // 执行核心打印逻辑
// invokeFun("orderPrint", "java.order", req, (data) -> {
// JSONObject jsonObject = JSONObject.parseObject(data);
// String orderId = jsonObject.getString("orderId");
// if (orderId == null) {
// throw new RuntimeException("订单打印失败未传递orderId");
// }
// Boolean printOrder = jsonObject.getBoolean("printOrder");
// funUtil.runFunAndCheckKey(() -> {
// printerHandler.handler(orderId, printOrder != null && !printOrder ? PrinterHandler.PrintTypeEnum.ONE : PrinterHandler.PrintTypeEnum.ONE_AND_ORDER);
// return null;
// }, RedisCst.getLockKey("orderPrint", orderId));
// });
// } catch (InterruptedException e) {
// Thread.currentThread().interrupt();
// // 记录中断日志
// log.warn("打印任务被中断req:{}", req, e);
// } catch (Exception e) {
// // 记录业务异常日志
// log.error("打印任务处理失败req:{}", req, e);
// }
// }, asyncExecutor);
}
/**
* 交班打印
*/
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE})
public void handoverPrint(String id) {
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER));
}
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE})
public void otherPrint(String data) {
JSONObject jsonObject = JSONObject.parseObject(data);
Long shopId = jsonObject.getLong("shopId");
String printTypeEnum = jsonObject.getString("printTypeEnum");
JSONObject data2 = jsonObject.getJSONObject("data");
JSONArray data3 = null;
if (data2 == null) {
data3 = jsonObject.getJSONArray("data");
}
PrinterHandler.PrintTypeEnum typeEnum = PrinterHandler.PrintTypeEnum.valueOf(printTypeEnum);
if (typeEnum != PrinterHandler.PrintTypeEnum.HANDOVER) {
SysPrintData sysPrintData = new SysPrintData();
sysPrintData.setShopId(shopId);
if (data2 != null) {
sysPrintData.setData(data2.toJSONString());
} else {
sysPrintData.setData(data3.toJSONString());
}
sysPrintData.setType(typeEnum.toString());
printDataService.save(sysPrintData);
rabbitPublisher.sendOtherPrintLocalMsg(shopId, printTypeEnum, sysPrintData.getId());
}
printConfig.otherHandler(shopId, data2, data3, typeEnum);
/**
* 交班打印
*/
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE})
public void callTablePrint(String id) {
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL));
}
}

View File

@@ -1,98 +0,0 @@
package com.czg.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.EntryManager;
import com.czg.PayCst;
import com.czg.dto.resp.QueryStatusResp;
import com.czg.order.entity.ShopDirectMerchant;
import com.czg.order.service.ShopMerchantService;
import com.czg.pay.AlipayAuthInfoDto;
import com.czg.pay.NativeMerchantDTO;
import com.czg.service.order.service.ShopDirectMerchantService;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 进件查询
*
* @author ww
*/
@Component
@Slf4j
public class EntryManagerTask {
@Resource
private ShopDirectMerchantService shopDirectMerchantService;
@Resource
private ShopMerchantService shopMerchantService;
// TODO 暂时不用原生进件,使用第三方进件
//每10分钟查一次
// @Scheduled(cron = "0 0/10 * * * ? ")
public void run() {
// log.info("进件查询,定时任务执行");
// long start = System.currentTimeMillis();
// entryManager(null);
// log.info("进件查询,定时任务执行完毕,耗时:{}ms", System.currentTimeMillis() - start);
}
/**
* 查询状态为待处理、待签约、待审核的进件
*/
public void entryManager(Long shopId) {
List<ShopDirectMerchant> list = shopDirectMerchantService.list(QueryWrapper.create()
.eq(ShopDirectMerchant::getShopId, shopId)
.in(ShopDirectMerchant::getWechatStatus, PayCst.EntryStatus.NEED_QUERY_LIST)
.or(ShopDirectMerchant::getAlipayStatus).in(PayCst.EntryStatus.NEED_QUERY_LIST));
if (CollUtil.isEmpty(list)) {
return;
}
for (ShopDirectMerchant shopDirectMerchant : list) {
String wechatMerchantId = "";
String alipayMerchantId = "";
if (PayCst.EntryStatus.NEED_QUERY_LIST.contains(shopDirectMerchant.getWechatStatus()) && StrUtil.isNotBlank(shopDirectMerchant.getWechatApplyId())) {
QueryStatusResp wechatStatus = EntryManager.queryWechatEntryStatus(shopDirectMerchant.getWechatApplyId());
shopDirectMerchant.setWechatStatus(wechatStatus.getStatus());
shopDirectMerchant.setWechatErrorMsg(wechatStatus.getFailReason());
shopDirectMerchant.setWechatSignUrl("");
shopDirectMerchant.setWechatMerchantId(wechatStatus.getThirdMerchantId());
if (PayCst.EntryStatus.FINISH.equals(wechatStatus.getStatus())) {
wechatMerchantId = wechatStatus.getThirdMerchantId();
}
}
if (PayCst.EntryStatus.NEED_QUERY_LIST.contains(shopDirectMerchant.getAlipayStatus()) && StrUtil.isNotBlank(shopDirectMerchant.getAlipayOrderId())) {
QueryStatusResp alipayStatus = EntryManager.queryAlipayEntryStatus(shopDirectMerchant.getAlipayOrderId());
shopDirectMerchant.setAlipayStatus(alipayStatus.getStatus());
shopDirectMerchant.setAlipayErrorMsg(alipayStatus.getFailReason());
shopDirectMerchant.setAlipaySignUrl("");
shopDirectMerchant.setAlipayMerchantId(alipayStatus.getThirdMerchantId());
if (PayCst.EntryStatus.FINISH.equals(alipayStatus.getStatus())) {
alipayMerchantId = alipayStatus.getThirdMerchantId();
}
}
shopDirectMerchantService.updateById(shopDirectMerchant);
if (StrUtil.isNotBlank(wechatMerchantId) || StrUtil.isNotBlank(alipayMerchantId)) {
// ShopMerchantDTO shopMerchantDTO = new ShopMerchantDTO();
// shopMerchantDTO.setShopId(shopId);
// shopMerchantDTO.setChannel(PayChannelCst.NATIVE);
// shopMerchantDTO.setRelatedId(shopDirectMerchant.getShopId());
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
nativeMerchantDTO.setWechatMerchantId(wechatMerchantId);
nativeMerchantDTO.setAlipayMerchantId(alipayMerchantId);
if (StrUtil.isNotBlank(shopDirectMerchant.getAlipayAuthInfo())) {
AlipayAuthInfoDto alipayAuthInfoDto = JSONObject.parseObject(shopDirectMerchant.getAlipayAuthInfo(), AlipayAuthInfoDto.class);
nativeMerchantDTO.setAlipayAuthInfo(alipayAuthInfoDto);
}
// shopMerchantDTO.setNativeMerchantDTO(nativeMerchantDTO);
// shopMerchantService.editEntry(shopMerchantDTO, false);
shopMerchantService.upMerchant(shopDirectMerchant.getShopId(), nativeMerchantDTO);
}
}
}
}

View File

@@ -1,40 +1,29 @@
package com.czg.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.czg.account.service.ShopTableService;
import com.czg.config.RedisCst;
import com.czg.enums.OrderNoPrefixEnum;
import com.czg.enums.ShopTableStatusEnum;
import cn.hutool.core.util.IdUtil;
import com.czg.market.service.OrderInfoService;
import com.czg.order.entity.CashierCart;
import com.czg.order.entity.GbOrder;
import com.czg.order.entity.OrderInfo;
import com.czg.order.entity.OrderPayment;
import com.czg.constants.PayTypeConstants;
import com.czg.order.service.CashierCartService;
import com.czg.order.service.GbOrderService;
import com.czg.order.service.OrderPaymentService;
import com.czg.service.RedisService;
import com.czg.service.order.enums.OrderStatusEnums;
import com.czg.service.order.service.PayService;
import com.czg.utils.CzgRandomUtils;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
/**
* 订单过期处理
* 退款失败 补偿
* 订单定时任务
*
* @author ww
* @description
*/
@Slf4j
@Component
@@ -44,99 +33,43 @@ public class OTimeTask {
@Resource
private CashierCartService cartService;
@Resource
private OrderPaymentService paymentService;
@Resource
private GbOrderService gbOrderService;
private OrderPaymentService orderPaymentService;
@Resource
private PayService payService;
@Resource
private RedisService redisService;
@DubboReference
private ShopTableService shopTableService;
/**
* order 过期
*/
@Scheduled(cron = "0 0 1 * * ? ")
public void run() {
QueryWrapper queryWrapper = QueryWrapper.create()
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode())
.lt(OrderInfo::getTradeDay, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd"));
List<OrderInfo> list = orderInfoService.list(queryWrapper);
if (CollUtil.isNotEmpty(list)) {
list.forEach(orderInfo -> shopTableService.updateStatus(orderInfo.getShopId(), null, orderInfo.getTableCode(), ShopTableStatusEnum.IDLE.getValue()));
OrderInfo orderInfo = new OrderInfo();
orderInfo.setStatus(OrderStatusEnums.CANCELLED.getCode());
orderInfoService.update(orderInfo, queryWrapper);
}
orderInfoService.update(orderInfo, QueryWrapper.create()
.eq(OrderInfo::getStatus, OrderStatusEnums.UNPAID.getCode())
.lt(OrderInfo::getTradeDay, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd")));
QueryWrapper cartUpdateWrapper = new QueryWrapper();
cartUpdateWrapper.lt(CashierCart::getCreateTime, DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd HH:mm:ss"))
.and(wrapper -> {
wrapper.isNull(CashierCart::getUpdateTime).or(CashierCart::getUpdateTime).lt(DateUtil.format(DateUtil.lastWeek(), "yyyy-MM-dd HH:mm:ss"));
wrapper.isNull(CashierCart::getUpdateTime).or(CashierCart::getUpdateTime).lt(DateUtil.format(DateUtil.yesterday(), "yyyy-MM-dd HH:mm:ss"));
});
cartService.remove(cartUpdateWrapper);
}
/**
* 订单 过期 退钱
* 每两小时 触发一次
*/
@Scheduled(cron = "0 0 0/2 * * ?")
public void gbOrderExpire() {
// 当前系统时间
LocalDateTime now = LocalDateTime.now();
// 过期时间下限当前时间往前推4小时只查最近4小时内过期的
LocalDateTime expire4HoursAgo = now.minusHours(4);
List<GbOrder> expiredOrderList = gbOrderService.list(QueryWrapper.create()
.eq(GbOrder::getStatus, "ing")
.le(GbOrder::getGroupEndTime, now)
.ge(GbOrder::getGroupEndTime, expire4HoursAgo));
// 处理已过期订单
for (GbOrder expiredOrder : expiredOrderList) {
//退款
gbOrderService.expireRefund(null, expiredOrder);
}
//查询【当前时间往后2小时内】将要过期的订单
LocalDateTime willExpire2HoursLater = now.plusHours(2);
List<GbOrder> willExpireOrderList = gbOrderService.list(QueryWrapper.create()
.eq(GbOrder::getStatus, "ing")
.ge(GbOrder::getGroupEndTime, now)
.le(GbOrder::getGroupEndTime, willExpire2HoursLater));
// 处理将要过期订单(如推送提醒、催参团等)
for (GbOrder willExpireOrder : willExpireOrderList) {
LocalDateTime endTime = willExpireOrder.getGroupEndTime();
Duration duration = Duration.between(now, endTime);
long seconds = duration.getSeconds();
redisService.set(RedisCst.classKeyExpired.EXPIRED_GB_ORDER + willExpireOrder.getId(), willExpireOrder.getId(), seconds);
}
}
/**
* 退钱补偿
* 积分 和 拼团
*/
@Scheduled(cron = "0 50 23 * * ? ")
public void refundCompensate() {
//积分 和 拼团
List<String> ware = List.of(
PayTypeConstants.SourceType.WARE,
PayTypeConstants.SourceType.POINT,
PayTypeConstants.SourceType.PP
);
LocalDateTime tenMinutesAgo = LocalDateTime.now().minusMinutes(10);
LocalDateTime thirdDayAgo = LocalDateTime.now().minusDays(3);
List<OrderPayment> list = paymentService.list(QueryWrapper.create()
List<OrderPayment> list = orderPaymentService.list(QueryWrapper.create()
.gt(OrderPayment::getUpdateTime, thirdDayAgo)
.lt(OrderPayment::getUpdateTime, tenMinutesAgo)
.in(OrderPayment::getSourceType, ware)
.eq(OrderPayment::getPayType, PayTypeConstants.PayType.REFUND)
.ne(OrderPayment::getPayStatus, PayTypeConstants.PayStatus.SUCCESS));
.eq(OrderPayment::getPayType, "refund")
.ne(OrderPayment::getPayStatus, "success"));
for (OrderPayment payment : list) {
String refPayOrderNo = CzgRandomUtils.snowflake(OrderNoPrefixEnum.REP);
String refPayOrderNo = "REP" + IdUtil.getSnowflakeNextId();
payService.unifyRefund(payment, refPayOrderNo);
}
}

View File

@@ -17,7 +17,6 @@ import java.util.List;
/**
* 统计任务
*
* @author Administrator
*/
@Component
@@ -37,14 +36,14 @@ public class StatisticTask {
//每天 00点15分 执行 开始统计数据
@Scheduled(cron = "0 0 5 * * ? ")
@Scheduled(cron = "0 15 0 * * ? ")
public void run() {
log.info("统计数据,定时任务执行");
long start = System.currentTimeMillis();
// 获取前一天
LocalDate yesterday = LocalDate.now().minusDays(1);
baseStatistic(yesterday);
log.info("统计数据,定时任务执行完毕,耗时:{}ms", System.currentTimeMillis() - start);
log.info("统计数据,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
}

View File

@@ -1 +0,0 @@
nacos=com.czg.config.FilteredNacosRegistryFactory

View File

@@ -25,23 +25,7 @@ spring:
port: 5672
username: chaozg
password: chaozg123
# 关键优化解决MissedHeartbeatException 心跳超时问题
connection-timeout: 10000 # 连接超时时间10秒避免连接建立过慢
requested-heartbeat: 30 # 心跳间隔调整为30秒原60秒过长降低超时概率过短易误触发
# 自动重连配置Spring AMQP 自带,关键兜底)
publisher-returns: true
template:
retry:
enabled: true # 开启消息发送重试
max-attempts: 3 # 最大重试次数
initial-interval: 3000 # 首次重试间隔2秒
multiplier: 1.5 # 重试间隔倍增因子
listener:
simple:
retry:
enabled: true # 开启消费者重试
max-attempts: 3 # 消费者最大重试次数
acknowledge-mode: auto # 确认模式可根据业务改为manual
dubbo:
application:
name: order-server

View File

@@ -1,9 +1,10 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.1.42:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: root
password: Chaozg123.
url: jdbc:mysql://rm-bp1kn7h89nz62cno1ro.mysql.rds.aliyuncs.com:3306/czg_cashier?useUnicode=true&characterEncoding=utf-8
username: cashier
password: Cashier@1@
data:
redis:

View File

@@ -52,6 +52,10 @@
<artifactId>cash-common-service</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -13,6 +13,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.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -25,12 +26,11 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-20
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/product/consGroup")
public class ConsGroupController {
@Resource
private ConsGroupService consGroupService;
private final ConsGroupService consGroupService;
@Resource
private ShopSyncService shopSyncService;

View File

@@ -9,7 +9,6 @@ import com.czg.product.param.ConsSubUnitParam;
import com.czg.product.service.ConsInfoService;
import com.czg.product.service.ShopSyncService;
import com.czg.product.vo.ConsStatisticsVo;
import com.czg.product.vo.ConsStockRecord;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.AssertUtil;
@@ -19,6 +18,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.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -31,13 +31,11 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-20
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/product/cons")
public class ConsInfoController {
@Resource
private ConsInfoService consInfoService;
private final ConsInfoService consInfoService;
@Resource
private ShopSyncService shopSyncService;
@@ -45,25 +43,18 @@ public class ConsInfoController {
* 分页
*/
@GetMapping("page")
@OperationLog("耗材信息-分页")
//@SaAdminCheckPermission("consInfo:page")
public CzgResult<Page<ConsInfoDTO>> getConsInfoPage(ConsInfoDTO param) {
Page<ConsInfoDTO> data = consInfoService.getConsInfoPage(param);
return CzgResult.success(data);
}
/**
* 列表
*/
@GetMapping("consStock")
public CzgResult<List<ConsStockRecord>> getConsStockList(Long shopId) {
return CzgResult.success(consInfoService.getConsStockList(shopId));
}
/**
* 列表
*/
@GetMapping("list")
@OperationLog("耗材信息-列表")
//@SaAdminCheckPermission("consInfo:list")
public CzgResult<List<ConsInfoDTO>> getConsInfoList(ConsInfoDTO param) {
List<ConsInfoDTO> data = consInfoService.getConsInfoList(param);
@@ -76,6 +67,7 @@ public class ConsInfoController {
* @param id 耗材信息id
*/
@GetMapping("{id}")
@OperationLog("耗材信息-详情")
//@SaAdminCheckPermission("consInfo:info")
public CzgResult<ConsInfoDTO> getConsInfoById(@PathVariable("id") Long id) {
AssertUtil.isNull(id, "{}不能为空", "id");
@@ -171,7 +163,6 @@ public class ConsInfoController {
return CzgResult.success();
}
/**
* 编辑副单位
*/
@@ -192,6 +183,7 @@ public class ConsInfoController {
* 统计
*/
@GetMapping("statistics")
@OperationLog("耗材信息-统计")
//@SaAdminCheckPermission("consInfo:info")
public CzgResult<ConsStatisticsVo> getConsInfoById(ConsInfoParam param) {
Long shopId = StpKit.USER.getShopId(0L);

View File

@@ -5,7 +5,6 @@ import cn.hutool.core.util.URLUtil;
import com.czg.log.annotation.OperationLog;
import com.czg.product.dto.ConsStockFlowDTO;
import com.czg.product.dto.OcrDTO;
import com.czg.product.entity.MkOcrService;
import com.czg.product.param.ConsCheckStockParam;
import com.czg.product.param.ConsInOutStockHeadParam;
import com.czg.product.param.ConsReportDamageParam;
@@ -17,11 +16,11 @@ import com.czg.utils.AssertUtil;
import com.czg.validator.ValidatorUtil;
import com.czg.validator.group.DefaultGroup;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.List;
@@ -32,35 +31,32 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-21
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/product/stock")
public class ConsStockFlowController {
@Resource
private ConsStockFlowService consStockFlowService;
@Resource
private MkOcrService ocrService;
private final ConsStockFlowService consStockFlowService;
/**
* 入库单识别
* @return
* @throws IOException
*/
@PostMapping("/ocr")
public CzgResult<Integer> ocr(@RequestBody OcrDTO ocrDTO) throws Exception {
URI uri = new URI(ocrDTO.getUrl());
URL url = uri.toURL();
public CzgResult<Integer> ocr(@RequestBody OcrDTO ocrDTO) throws IOException {
URL url = new URL(ocrDTO.getUrl());
InputStream stream = URLUtil.getStream(url);
return CzgResult.success(ocrService.ocr(FileUtil.getName(ocrDTO.getUrl()), stream, "cons"));
return CzgResult.success(consStockFlowService.ocr(FileUtil.getName(ocrDTO.getUrl()), stream));
}
/**
* ocr识别结果
*
* @param id ocrId
* @return 识别结果
*/
@GetMapping("/ocrResult")
public CzgResult<ConsInOutStockHeadParam> ocrResult(@RequestParam Long id) {
return CzgResult.success(ocrService.ocrDetail(id));
return CzgResult.success(consStockFlowService.ocrDetail(id));
}

View File

@@ -15,6 +15,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.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -27,16 +28,12 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-17
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/prod/group")
public class ProdGroupController {
@Resource
private ProdGroupService prodGroupService;
@Resource
private RabbitPublisher rabbitPublisher;
private final ProdGroupService prodGroupService;
private final RabbitPublisher rabbitPublisher;
@Resource
private ShopSyncService shopSyncService;

View File

@@ -2,9 +2,9 @@ package com.czg.controller.admin;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson2.JSONObject;
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;
import com.czg.log.annotation.OperationLog;
@@ -16,6 +16,7 @@ import com.czg.product.param.*;
import com.czg.product.service.ProdConsRelationService;
import com.czg.product.service.ProductService;
import com.czg.product.service.ShopSyncService;
import com.czg.product.service.UProductService;
import com.czg.product.vo.ProductStatisticsVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
@@ -26,36 +27,30 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 管理端/商品管理 - 商品列表
* 商品管理 - 商品列表
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-16
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/product")
public class ProductController {
@Resource
private ProductService productService;
@Resource
private ProdConsRelationService prodConsRelationService;
@Resource
private RabbitPublisher rabbitPublisher;
private final ProductService productService;
private final ProdConsRelationService prodConsRelationService;
private final RabbitPublisher rabbitPublisher;
@Resource
private ShopSyncService shopSyncService;
@Resource
private UProductService uProductService;
@Resource
private ShopInfoService shopInfoService;
@@ -65,18 +60,9 @@ public class ProductController {
@GetMapping("page")
@OperationLog("商品-分页")
//@SaAdminCheckPermission("product:page")
public CzgResult<Map<String, Object>> getProductPage(ProductDTO param) {
public CzgResult<Page<ProductDTO>> getProductPage(ProductDTO param) {
Page<ProductDTO> data = productService.getProductPage(param);
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(data), Map.class);
return CzgResult.success(map);
}
/**
* 导出商品
*/
@GetMapping("export")
public void exportProduct(ProductDTO param, HttpServletResponse response) {
productService.exportProductList(param, response);
return CzgResult.success(data);
}
/**
@@ -84,8 +70,16 @@ public class ProductController {
*/
@GetMapping("list")
@OperationLog("商品-列表")
public CzgResult<List<ProductDTO>> getProductList(@RequestParam(required = false) Long categoryId) {
return CzgResult.success(productService.getProductCacheList(StpKit.USER.getShopId(), categoryId));
//@SaAdminCheckPermission("product:list")
public CzgResult<List<ProductDTO>> getProductList(ProductDTO param) {
Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId);
List<ProductDTO> productList = productService.getProductCacheList(param);
productService.refreshProductStock(param, productList);
productList.forEach(prod -> {
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
});
return CzgResult.success(productList);
}
/**
@@ -111,25 +105,16 @@ public class ProductController {
for (ProdSkuDTO prodSkuDTO : dto.getSkuList()) {
ValidatorUtil.validateEntity(prodSkuDTO, DefaultGroup.class);
}
Long shopId = StpKit.USER.getShopId();
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
productService.addProduct(dto);
asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
/**
* 商品-库存变动记录
*/
@GetMapping("stockFlow")
@OperationLog("商品-库存变动记录")
//@SaAdminCheckPermission("consStockFlow:flow")
public CzgResult<Page<ProductStockFlow>> stockFlow(ProductStockFlowParam param) {
Page<ProductStockFlow> data = productService.findProductStockFlowPage(param);
return CzgResult.success(data);
}
/**
* 商品-修改
*/
@@ -145,11 +130,31 @@ public class ProductController {
if (dto.getGroupCategoryId() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_fen_zu");
}
Long shopId = StpKit.USER.getShopId();
if (dto.getStockNumber() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_shang_pin_ku_cun");
}
Long shopId = StpKit.USER.getShopId(0L);
dto.setShopId(shopId);
productService.updateProduct(dto);
asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
@PostMapping("modifyStock")
@OperationLog("商品-修改库存")
//@SaStaffCheckPermission("yun_xu_xiu_gai_shang_pin")
public CzgResult<Void> updateProductStock(@RequestBody ProductModifyStockParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
Long shopId = StpKit.USER.getShopId(0L);
param.setShopId(shopId);
productService.updateProductStock(param);
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
@@ -165,10 +170,12 @@ public class ProductController {
public CzgResult<Void> deleteProduct(@PathVariable("id") Long id) {
//效验数据
AssertUtil.isNull(id, "{}不能为空", "id");
Long shopId = StpKit.USER.getShopId();
Long shopId = StpKit.USER.getShopId(0L);
productService.deleteProduct(shopId, id);
asyncProductToShop(id);
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
@@ -180,10 +187,12 @@ public class ProductController {
//@SaStaffCheckPermission("yun_xu_shang_xia_jia_shang_pin")
//@SaAdminCheckPermission("product:on-off")
public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) {
Long shopId = StpKit.USER.getShopId();
Long shopId = StpKit.USER.getShopId(0L);
param.setShopId(shopId);
productService.onOffProduct(param);
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
@@ -195,20 +204,12 @@ public class ProductController {
//@SaStaffCheckPermission("yun_xu_shou_qing_shang_pin")
//@SaAdminCheckPermission("product:markIsSoldOut")
public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) {
Long shopId = StpKit.USER.getShopId();
Long shopId = StpKit.USER.getShopId(0L);
param.setShopId(shopId);
productService.markProductIsSoldOut(param);
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
return CzgResult.success();
}
/**
* 商品-标记自动售罄
*/
@PostMapping("markIsAutoSoldOut")
public CzgResult<Void> markIsAutoSoldOut(@RequestBody @Validated({DefaultGroup.class}) ProductIsAutoSaleParam param) {
productService.markProductIsAutoSoldOut(StpKit.USER.getShopId(), param);
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(StpKit.USER.getShopId())));
ThreadUtil.execAsync(() -> {
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success();
}
@@ -219,19 +220,45 @@ public class ProductController {
@OperationLog("商品-绑定耗材")
//@SaAdminCheckPermission("product:bind")
public CzgResult<Void> bindCons(@RequestBody @Validated({DefaultGroup.class}) ProdConsBindDTO param) {
AssertUtil.isNull(param.getId(), "商品Id不能为空");
prodConsRelationService.saveProdConsRelation(param);
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(StpKit.USER.getShopId())));
asyncConsProToShop(param.getId());
return CzgResult.success();
}
/**
* 商品-退款退至库存
*/
@PostMapping("refundToStock")
@OperationLog("商品-退款退至库存")
//@SaAdminCheckPermission("product:update")
public CzgResult<Void> refundToStock(@RequestBody @Validated({DefaultGroup.class}) ProdRefundToStockParam param) {
productService.refundToStock(param);
asyncProductToShop(param.getId());
return CzgResult.success();
}
/**
* 商品-库存预警设置
*/
@PostMapping("stockWarning")
@OperationLog("商品-库存预警设置")
//@SaAdminCheckPermission("product:stockWarning")
public CzgResult<Void> stockWarning(@RequestParam Integer warnLine) {
AssertUtil.isNull(warnLine, "{}不能为空", "warnLine");
if (warnLine < 0) {
throw new CzgException("预警值不能小于0");
}
productService.stockWarning(warnLine);
return CzgResult.success();
}
/**
* 商品-报损
*/
@PostMapping("reportDamage")
@OperationLog("商品-报损")
//@SaStaffCheckPermission("yun_xu_ti_jiao_bao_sun")
//@SaAdminCheckPermission("product:reportDamage")
public CzgResult<Void> reportDamage(@RequestBody ProductReportDamageParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class);
productService.reportDamage(param);
@@ -251,6 +278,17 @@ public class ProductController {
return CzgResult.success(data);
}
/**
* 商品-库存变动记录
*/
@GetMapping("stockFlow")
@OperationLog("商品-库存变动记录")
//@SaAdminCheckPermission("consStockFlow:flow")
public CzgResult<Page<ProductStockFlow>> stockFlow(ProductStockFlowParam param) {
Page<ProductStockFlow> data = productService.findProductStockFlowPage(param);
return CzgResult.success(data);
}
/**
* 商品-报损
*/
@@ -268,7 +306,9 @@ public class ProductController {
if (shopInfo.getMainId() == null || shopId == shopInfo.getMainId()) {
throw new CzgException("不存在主子店铺关系,无需同步商品信息");
}
ThreadUtil.execAsync(() -> shopSyncService.sync(shopInfo.getMainId(), shopId, shopId));
ThreadUtil.execAsync(() -> {
shopSyncService.sync(shopInfo.getMainId(), shopId, shopId);
});
CzgResult<Void> ret = CzgResult.success();
ret.setMsg("操作成功,数据正在后台同步中...");
return ret;
@@ -276,11 +316,15 @@ public class ProductController {
private void asyncProductToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> shopSyncService.syncProductBySourceShop(shopId, id, shopId));
ThreadUtil.execAsync(() -> {
shopSyncService.syncProductBySourceShop(shopId, id, shopId);
});
}
private void asyncConsProToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> shopSyncService.syncConsProBySourceShop(shopId, id, shopId));
ThreadUtil.execAsync(() -> {
shopSyncService.syncConsProBySourceShop(shopId, id, shopId);
});
}
}

View File

@@ -13,7 +13,7 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -26,29 +26,22 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-10
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/prod/category")
public class ShopProdCategoryController {
@Resource
private ShopProdCategoryService shopProdCategoryService;
private final ShopProdCategoryService shopProdCategoryService;
@Resource
private ShopSyncService shopSyncService;
/**
* 分页
*/
@GetMapping("page")
@OperationLog("商品分类-分页")
//@SaAdminCheckPermission("shopProdCategory:page")
public CzgResult<Page<ShopProdCategoryDTO>> getShopProdCategoryPage(ShopProdCategoryDTO param) {
Page<ShopProdCategoryDTO> data = shopProdCategoryService.getShopProdCategoryPage(param);
return CzgResult.success(data);
}
/**
* 列表
*/
@GetMapping("list")
@OperationLog("商品分类-列表")
//@SaAdminCheckPermission("shopProdCategory:list")
@@ -57,18 +50,6 @@ public class ShopProdCategoryController {
return CzgResult.success(data);
}
/**
* 导出
*/
@GetMapping("/export")
@OperationLog("商品分类-导出")
public void exportShopProdCategory(ShopProdCategoryDTO param, HttpServletResponse response) {
shopProdCategoryService.exportShopProdCategory(param, response);
}
/**
* 详情
*/
@GetMapping("{id}")
@OperationLog("商品分类-详情")
//@SaAdminCheckPermission("shopProdCategory:info")
@@ -78,9 +59,6 @@ public class ShopProdCategoryController {
return CzgResult.success(data);
}
/**
* 新增
*/
@PostMapping
@OperationLog("商品分类-新增")
//@SaAdminCheckPermission("shopProdCategory:add")
@@ -90,9 +68,6 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 修改
*/
@PutMapping
@OperationLog("商品分类-修改")
//@SaAdminCheckPermission("shopProdCategory:update")
@@ -102,9 +77,6 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 删除
*/
@DeleteMapping("{id}")
@OperationLog("商品分类-删除")
//@SaAdminCheckPermission("shopProdCategory:delete")
@@ -115,9 +87,6 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 禁用
*/
@PostMapping("disable/{id}")
@OperationLog("商品分类-禁用")
//@SaAdminCheckPermission("shopProdCategory:able")
@@ -129,9 +98,6 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
/**
* 启用
*/
@PostMapping("enable/{id}")
@OperationLog("商品分类-启用")
//@SaAdminCheckPermission("shopProdCategory:able")
@@ -143,11 +109,12 @@ public class ShopProdCategoryController {
return CzgResult.success();
}
private void asyncToBranchShop(Long id) {
long shopId = StpKit.USER.getShopId(0L);
long sysUserId = StpKit.USER.getLoginIdAsLong();
ThreadUtil.execAsync(() -> shopSyncService.syncCategoryBySourceShop(shopId, id, sysUserId));
ThreadUtil.execAsync(() -> {
shopSyncService.syncCategoryBySourceShop(shopId, id, sysUserId);
});
}
}

View File

@@ -26,13 +26,11 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-13
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/prod/spec")
public class ShopProdSpecController {
@Resource
private ShopProdSpecService shopProdSpecService;
private final ShopProdSpecService shopProdSpecService;
@Resource
private ShopSyncService shopSyncService;

View File

@@ -13,7 +13,6 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -22,24 +21,21 @@ import java.util.List;
/**
* 管理端/商品单位
* 商品单位
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-10
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/prod/unit")
public class ShopProdUnitController {
@Resource
private ShopProdUnitService shopProdUnitService;
private final ShopProdUnitService shopProdUnitService;
@Resource
private ShopSyncService shopSyncService;
/**
* 分页
*/
@GetMapping("page")
@OperationLog("商品单位-分页")
//@SaAdminCheckPermission("shopProdUnit:page")
@@ -48,9 +44,6 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 列表
*/
@GetMapping("list")
@OperationLog("商品单位-列表")
//@SaAdminCheckPermission("shopProdUnit:list")
@@ -59,18 +52,6 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 导出
*/
@GetMapping("/export")
@OperationLog("商品单位-导出")
public void exportProduct(ShopProdUnitDTO param, HttpServletResponse response) {
shopProdUnitService.exportShopProdUnit(param, response);
}
/**
* 详情
*/
@GetMapping("{id}")
@OperationLog("商品单位-详情")
//@SaAdminCheckPermission("shopProdUnit:info")
@@ -80,9 +61,6 @@ public class ShopProdUnitController {
return CzgResult.success(data);
}
/**
* 新增
*/
@PostMapping
@OperationLog("商品单位-新增")
//@SaAdminCheckPermission("shopProdUnit:add")
@@ -92,9 +70,6 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 修改
*/
@PutMapping
@OperationLog("商品单位-修改")
//@SaAdminCheckPermission("shopProdUnit:update")
@@ -104,9 +79,6 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 删除
*/
@DeleteMapping("{id}")
@OperationLog("商品单位-删除")
//@SaAdminCheckPermission("shopProdUnit:delete")
@@ -117,9 +89,6 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 禁用
*/
@PostMapping("disable/{id}")
@OperationLog("商品单位-禁用")
//@SaAdminCheckPermission("shopProdUnit:able")
@@ -131,9 +100,6 @@ public class ShopProdUnitController {
return CzgResult.success();
}
/**
* 启用
*/
@PostMapping("enable/{id}")
@OperationLog("商品单位-启用")
//@SaAdminCheckPermission("shopProdUnit:able")

View File

@@ -18,6 +18,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.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -30,13 +31,11 @@ import java.util.List;
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-20
*/
@AllArgsConstructor
@RestController
@RequestMapping("/admin/product/vendor")
public class ShopVendorController {
@Resource
private ShopVendorService shopVendorService;
private final ShopVendorService shopVendorService;
@Resource
private ShopSyncService shopSyncService;

View File

@@ -1,38 +0,0 @@
package com.czg.controller.admin;
import com.czg.product.service.MkOcrCountStickService;
import com.czg.resp.CzgResult;
import com.czg.utils.AssertUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* 拍照数签子
* @author ww
*/
@RestController
@RequestMapping("/admin/stick")
public class StickCountController {
@Resource
private MkOcrCountStickService stickCountService;
/**
* 文件上传并返回点数统计结果
*
* @param file 上传的图片文件
* @return 点数统计结果
*/
@PostMapping("/count")
public CzgResult<Integer> uploadAndCount(MultipartFile file) throws IOException {
AssertUtil.isNull(file, "上传文件不能为空");
// 9. 返回成功结果
return CzgResult.success(stickCountService.getCountStick(file.getBytes(), file.getOriginalFilename()));
}
}

View File

@@ -1,37 +1,40 @@
package com.czg.controller.user;
import com.czg.constants.SystemConstants;
import com.czg.enums.YesNoEnum;
import com.czg.product.param.ShopProductSkuParam;
import com.czg.product.service.ConsInfoService;
import com.czg.product.service.UProductService;
import com.czg.product.vo.*;
import com.czg.product.vo.ShopGroupProductVo;
import com.czg.product.vo.ShopProductInfoVo;
import com.czg.product.vo.ShopProductSkuInfoVo;
import com.czg.product.vo.ShopProductVo;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.RedisService;
import com.czg.utils.AssertUtil;
import com.czg.validator.ValidatorUtil;
import com.czg.validator.group.DefaultGroup;
import jakarta.annotation.Resource;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* 用户端/店铺商品
* 店铺商品
*
* @author Tankaikai tankaikai@aliyun.com
* @since 1.0 2025-02-16
*/
@AllArgsConstructor
@RestController
@RequestMapping("/user/product")
public class UProductController {
@Resource
private UProductService uProductService;
@Resource
private ConsInfoService consInfoService;
private final UProductService uProductService;
private final RedisService redisService;
/**
* 小程序点餐-热销商品列表
@@ -40,9 +43,10 @@ public class UProductController {
public CzgResult<List<ShopProductVo>> queryHotsProductList() {
Long shopId = StpKit.USER.getShopId(0L);
List<ShopProductVo> list = uProductService.queryHotsProductList(shopId);
// list.forEach(prod -> {
// prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
// });
list.forEach(prod -> {
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
});
uProductService.refreshProductStock(shopId, list);
return CzgResult.success(list);
}
@@ -53,11 +57,13 @@ public class UProductController {
public CzgResult<List<ShopGroupProductVo>> queryGroupProductList() {
Long shopId = StpKit.USER.getShopId(0L);
List<ShopGroupProductVo> list = uProductService.queryGroupProductList(shopId);
Map<Long, Integer> productStock = uProductService.findShopProductStock(shopId);
list.forEach(item -> {
uProductService.refreshProductStock(productStock, item.getProductList());
item.getProductList().forEach(prod -> {
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getIsSaleTime(), item.getUseTime(), item.getSaleStartTime(), item.getSaleEndTime()));
if (item.getUseTime() == SystemConstants.OneZero.ONE) {
if (item.getUseTime() == YesNoEnum.YES.value()) {
prod.setStartTime(item.getSaleStartTime());
prod.setEndTime(item.getSaleEndTime());
}
@@ -66,14 +72,6 @@ public class UProductController {
return CzgResult.success(list);
}
/**
* 列表
*/
@GetMapping("consStock")
public CzgResult<List<ConsStockRecord>> getConsStockList(Long shopId) {
return CzgResult.success(consInfoService.getConsStockList(shopId));
}
/**
* 小程序点餐-商品详情
*

View File

@@ -1 +0,0 @@
nacos=com.czg.config.FilteredNacosRegistryFactory

View File

@@ -21,7 +21,7 @@ wx:
appId: wx212769170d2c6b2a
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSZyFA2G6b9_jiZgEppzLB70
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0

View File

@@ -1,33 +0,0 @@
package com.czg.service;
import com.alibaba.fastjson2.JSONObject;
import com.czg.product.dto.ProductDTO;
import com.czg.product.service.ProductService;
import com.czg.product.service.UProductService;
import com.czg.product.vo.ShopGroupProductVo;
import com.czg.product.vo.ShopProductVo;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
/**
* @author yjjie
* @date 2025/12/24 13:36
*/
@SpringBootTest
public class ProductTest {
@Resource
private ProductService productService;
@Resource
private UProductService uProductService;
@Test
public void testGetById() {
// ProductDTO product = productService.getProductById(169L);
// System.out.println(JSONObject.toJSONString( product));
}
}

View File

@@ -58,7 +58,7 @@ public class MiniAppPagesController {
* @param status 小程序页面状态 -1 查全部 1 启用 0 禁用
*/
@GetMapping("page")
// @SaAdminCheckPermission(parentName = "小程序页面",value = "miniAppPages:page", name = "小程序页面分页")
@SaAdminCheckPermission(parentName = "小程序页面",value = "miniAppPages:page", name = "小程序页面分页")
public CzgResult<Page<MiniAppPagesDTO>> getMiniAppPage(String name, String path, Integer status) {
return miniAppPageService.getMiniAppPage(name, path, status);
}

View File

@@ -1,59 +0,0 @@
package com.czg.controller.admin;
import com.czg.BaseQueryParam;
import com.czg.resp.CzgResult;
import com.czg.system.entity.SysBankInfo;
import com.czg.system.entity.SysRegion;
import com.czg.system.service.SysBankInfoService;
import com.czg.system.service.SysCategoryInfoService;
import com.czg.system.service.SysRegionService;
import com.czg.system.vo.SysCategoryInfoVO;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 通用
*
* @author Administrator
*/
@RestController
@RequestMapping("/admin/common")
public class SysCommonController {
@Resource
private SysRegionService sysRegionService;
@Resource
private SysBankInfoService bankInfoService;
@Resource
private SysCategoryInfoService categoryInfoService;
/**
* 获取所有地域
*/
@GetMapping("/region")
public CzgResult<List<SysRegion>> region() {
return CzgResult.success(sysRegionService.regionList());
}
/**
* 获取银行信息
*/
@GetMapping("/bankInfo")
public CzgResult<Page<SysBankInfo>> bankInfo(BaseQueryParam param, @RequestParam String bankName) {
return CzgResult.success(bankInfoService.bankInfoList(param, bankName));
}
/**
* 类目信息表
*/
@GetMapping("/category")
public CzgResult<List<SysCategoryInfoVO>> category() {
return CzgResult.success(categoryInfoService.categoryList());
}
}

View File

@@ -2,9 +2,9 @@ package com.czg.controller.admin;
import com.aliyun.sts20150401.models.AssumeRoleResponse;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.constants.ParamCodeCst;
import com.czg.resp.CzgResult;
import com.czg.system.dto.VersionDTO;
import com.czg.system.enums.SysParamCodeEnum;
import com.czg.system.service.SysParamsService;
import com.czg.system.service.VersionService;
import com.czg.validator.group.InsertGroup;
@@ -14,8 +14,6 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author GYJoker
@@ -96,19 +94,18 @@ public class VersionController {
@GetMapping(value = "/getCredentials")
public CzgResult<Object> getCredentials() {
try {
Map<String, String> ossKeyMap = paramsService.getParamsByMap("ossKeySet", ParamCodeCst.OSS_KEY_SET);
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
.setAccessKeyId(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ACCESS_KEY))
.setAccessKeyId(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ACCESS_KEY.getCode()))
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
.setAccessKeySecret(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ACCESS_SECRET));
.setAccessKeySecret(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ACCESS_SECRET.getCode()));
// Endpoint 请参考 https://api.aliyun.com/product/Sts
config.endpoint = ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ENDPOINT);
config.endpoint = paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ENDPOINT.getCode());
com.aliyun.sts20150401.Client client = new com.aliyun.sts20150401.Client(config);
com.aliyun.sts20150401.models.AssumeRoleRequest assumeRoleRequest = new com.aliyun.sts20150401.models.AssumeRoleRequest();
assumeRoleRequest.setRoleArn(ossKeyMap.get(ParamCodeCst.AliYun.ALI_OSS_ROLE_ARN));
assumeRoleRequest.setRoleArn(paramsService.getSysParamValue(SysParamCodeEnum.ALI_OSS_ROLE_ARN.getCode()));
assumeRoleRequest.setRoleSessionName("test");
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
// 复制代码运行请自行打印 API 的返回值

View File

@@ -1,9 +1,7 @@
package com.czg.controller.user;
import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.dto.VersionDTO;
import com.czg.system.service.SysParamsService;
import com.czg.system.service.VersionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
@@ -11,44 +9,23 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 用户端
* @author GYJoker
*/
@RestController
@RequestMapping("/user")
@RequestMapping("/user/version")
public class UserVersionController {
@Resource
private VersionService versionService;
@Resource
private SysParamsService sysParamsService;
/**
* 获取版本信息
*
* @param source 渠道
* @param type 类型
* @return VersionDTO
*/
@GetMapping("/version/info/{source}/{type}")
@GetMapping("/info/{source}/{type}")
public CzgResult<VersionDTO> getVersionInfo(@PathVariable("source") String source, @PathVariable("type") String type) {
return versionService.getVersionInfo(source, type);
}
/**
* 帮助中心
*
* @return VersionDTO
*/
@GetMapping("/getHelp")
public CzgResult<Map<String, String>> getHelpInfo() {
List<SysParamsDTO> systemHelps = sysParamsService.getByParamType("system_help");
Map<String, String> systemHelpMap = systemHelps.stream().collect(Collectors.toMap(SysParamsDTO::getParamCode, SysParamsDTO::getParamValue));
return CzgResult.success(systemHelpMap);
}
}

View File

@@ -1 +0,0 @@
nacos=com.czg.config.FilteredNacosRegistryFactory

View File

@@ -50,8 +50,9 @@ public class FastJson2Config implements WebMvcConfigurer {
// 设置支持的媒体类型
List<MediaType> supportedMediaTypes = new ArrayList<>();
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
supportedMediaTypes.add(MediaType.APPLICATION_JSON_UTF8);
converter.setSupportedMediaTypes(supportedMediaTypes);
// 将转换器添加到 Spring MVC 的消息转换器列表中
converters.addFirst(converter);
converters.add(0, converter);
}
}

View File

@@ -1,82 +0,0 @@
package com.czg.config;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper;
import org.apache.dubbo.registry.nacos.NacosRegistry;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author yjjie
* @date 2025/12/19 16:44
*/
@Slf4j
public class FilteredNacosRegistry extends NacosRegistry {
// 定义需要过滤的方法名黑名单(可根据业务调整)
private static final List<String> FILTER_METHODS = Arrays.asList(
"updateBatch",
"saveOrUpdateBatch",
"getOneByEntityId",
"getByEntityIdOpt",
"saveBatch",
"removeByMap",
"getByIdOpt",
"getOneOpt",
"getOneAs",
"getObjOpt",
"getObjAs",
"getObjAsOpt",
"objList",
"objListAs",
"listByMap",
"queryChain",
"updateChain",
"getObj"
);
/**
* 适配 Dubbo 3.3 版本的构造函数
*
* @param url Dubbo 注册中心URL
* @param namingService NacosNamingServiceWrapperDubbo 3.3 特有包装类)
*/
public FilteredNacosRegistry(URL url, NacosNamingServiceWrapper namingService) {
// 调用父类2参数构造URL + NacosNamingServiceWrapper
super(url, namingService);
}
@Override
public void register(URL url) {
// 1. 获取原始注册的方法列表
String originalMethods = url.getParameter("methods");
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), originalMethods);
if (originalMethods != null && !originalMethods.isEmpty()) {
// 2. 过滤黑名单中的方法名
List<String> filteredMethods = Arrays.stream(originalMethods.split(","))
// 去除首尾空格
.map(String::trim)
// 过滤指定方法
.filter(method -> !FILTER_METHODS.contains(method))
.collect(Collectors.toList());
// 3. 处理过滤后的结果
if (filteredMethods.isEmpty()) {
// 若所有方法都被过滤,直接终止注册(可选:根据业务决定是否保留服务注册)
// log.info("【过滤提示】服务 {} 所有方法均被过滤,终止注册", url.getServiceInterface());
return;
} else {
// 替换 URL 中的 methods 参数为过滤后的列表
url = url.addParameter("methods", String.join(",", filteredMethods));
// log.info("【过滤提示】服务 {} 注册方法:{}", url.getServiceInterface(), filteredMethods);
}
}
// 执行父类的注册逻辑将过滤后的URL注册到Nacos
super.register(url);
}
}

View File

@@ -1,45 +0,0 @@
package com.czg.config;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.nacos.NacosNamingServiceWrapper;
import org.apache.dubbo.registry.nacos.NacosRegistry;
import org.apache.dubbo.registry.nacos.NacosRegistryFactory;
import java.lang.reflect.Field;
/**
* @author yjjie
* @date 2025/12/19 17:31
*/
public class FilteredNacosRegistryFactory extends NacosRegistryFactory {
@Override
public Registry createRegistry(URL url) {
// 1. 先创建 Dubbo 原生的 NacosRegistry 实例
NacosRegistry originalNacosRegistry = (NacosRegistry) super.createRegistry(url);
try {
// 2. 反射提取 NacosRegistry 中的 NacosNamingServiceWrapper 实例Dubbo 3.3 私有字段名namingService
Field namingServiceField = NacosRegistry.class.getDeclaredField("namingService");
// 突破私有访问限制
namingServiceField.setAccessible(true);
NacosNamingServiceWrapper namingServiceWrapper = (NacosNamingServiceWrapper) namingServiceField.get(originalNacosRegistry);
// 3. 创建自定义的 FilteredNacosRegistry传入URL + 提取的 namingServiceWrapper
return new FilteredNacosRegistry(url, namingServiceWrapper);
} catch (NoSuchFieldException | IllegalAccessException e) {
// 兼容字段名差异(若字段名不是 namingService尝试其他可能nacosNamingService
try {
Field fallbackField = NacosRegistry.class.getDeclaredField("nacosNamingService");
fallbackField.setAccessible(true);
NacosNamingServiceWrapper namingServiceWrapper = (NacosNamingServiceWrapper) fallbackField.get(originalNacosRegistry);
return new FilteredNacosRegistry(url, namingServiceWrapper);
} catch (Exception ex) {
throw new RuntimeException("获取 NacosNamingServiceWrapper 失败", ex);
}
}
}
}

View File

@@ -1,6 +1,5 @@
package com.czg.config;
import cn.hutool.core.util.StrUtil;
import com.mybatisflex.core.audit.AuditManager;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
@@ -17,25 +16,9 @@ public class MybatisFlexConfig {
//设置 SQL 审计收集器
AuditManager.setMessageCollector(auditMessage ->
log.info("[sql] time: {}, size: {}, sql:\n{}",
auditMessage.getElapsedTime(), auditMessage.getQueryCount(), compressSql(auditMessage.getFullSql())));
log.info("[sql] time: {}, size: {},\n sql:{}",
auditMessage.getElapsedTime(), auditMessage.getQueryCount(), auditMessage.getFullSql())
);
}
/**
* 精简SQL去除多余换行、制表符、连续空格保留语法必需空格
*
* @param originalSql 原始带换行/空格的SQL
* @return 精简后的SQL
*/
public static String compressSql(String originalSql) {
if (StrUtil.isBlank(originalSql)) {
return "";
}
// 1. 替换所有换行、制表符为单个空格
String tempSql = originalSql.replaceAll("\\r\\n|\\r|\\n|\\t", " ");
// 2. 替换多个连续空格为单个空格
tempSql = tempSql.replaceAll("\\s+", " ");
// 3. 去除首尾空格
return tempSql.trim();
}
}

View File

@@ -8,7 +8,6 @@ import com.czg.resp.CzgRespCode;
import com.czg.resp.CzgResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.DefaultMessageSourceResolvable;
import org.springframework.core.NestedExceptionUtils;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.converter.HttpMessageNotReadableException;
@@ -87,6 +86,7 @@ public class CzgControllerAdvice {
}
/**
* 处理自定义异常
*/
@@ -164,24 +164,10 @@ public class CzgControllerAdvice {
@ExceptionHandler(value = Exception.class)
@ResponseStatus(HttpStatus.OK)
public CzgResult<Object> errorHandler(Exception ex) {
// setErrorLog(ex);
// 3. 处理未捕获的异常(系统异常,隐藏敏感信息)
log.error("系统未处理异常", ex);
String rootMsg = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
return CzgResult.failure(CzgRespCode.FAILURE.getCode(), rootMsg);
// Throwable rootCause = ex;
// while (rootCause.getCause() != null && !(rootCause instanceof CzgException)) {
// rootCause = rootCause.getCause();
// }
//
// // 2. 如果根因是CzgException直接抛出/返回该异常
// if (rootCause instanceof CzgException exception) {
// return CzgResult.failure(exception.getCode(), exception.getMsg());
// }else if (rootCause instanceof ValidateException exception) {
// return CzgResult.failure(exception.getStatus(), exception.getMessage());
// }
// 3. 非业务异常,按原有逻辑处理
// return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统错误,请联系管理员");
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR.getCode(), "系统错误,请联系管理员");
}
private void setErrorLog(Exception ex) {

View File

@@ -21,24 +21,12 @@ public class RabbitConfig {
@Value("${spring.profiles.active}")
private String activeProfile;
@Bean
@Primary
public DirectExchange directExchange() {
return new DirectExchange(activeProfile + "-" + RabbitConstants.Exchange.CASH_EXCHANGE);
}
//------------------------------------------------------ 商家入驻
@Bean
public Queue entryManagerQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER, true, false, false);
}
@Bean
public Binding entryManagerExchange(Queue entryManagerQueue, DirectExchange exchange) {
return BindingBuilder.bind(entryManagerQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.SHOP_ENTRY_MANAGER);
}
//------------------------------------------------------订单打印队列
@Bean
public Queue orderPrintQueue() {
@@ -48,7 +36,6 @@ public class RabbitConfig {
args.put("x-message-ttl", 180000);
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE, true, false, false, args);
}
@Bean
public Binding bindingOrderPrintExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRINT_QUEUE);
@@ -64,32 +51,29 @@ public class RabbitConfig {
// args.put("x-message-ttl", 180000);
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, true, false, false);
}
@Bean
public Binding bindingOrderMachinePrintExchange(Queue orderMachinePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderMachinePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE);
}
//------------------------------------------------------其它打印消息打票
//------------------------------------------------------交班打票
@Bean
public Queue otherPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE, true, false, false);
public Queue handoverPrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, true, false, false);
}
@Bean
public Binding bindingHandoverPrintExchange(Queue handoverPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(handoverPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE);
}
//------------------------------------------------------叫号 打票
@Bean
public Binding bindingOtherPrintExchange(Queue otherPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(otherPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_QUEUE);
public Queue callTablePrintQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE, true, false, false);
}
@Bean
public Queue otherPrintLocalQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_LOCAL_QUEUE, true, false, false);
}
@Bean
public Binding bindingOtherPrintLocalExchange(Queue otherPrintLocalQueue, DirectExchange exchange) {
return BindingBuilder.bind(otherPrintLocalQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.OTHER_PRINT_LOCAL_QUEUE);
public Binding bindingCallTablePrintExchange(Queue callTablePrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(callTablePrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE);
}
//------------------------------------------------------订单取消
@@ -97,10 +81,9 @@ public class RabbitConfig {
public Queue orderCancelQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE, true);
}
@Bean
public Binding bindingOrderCancelExchange(Queue orderCancelQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderCancelQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
public Binding bindingOrderCancelExchange(Queue orderPrintQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderPrintQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_CANCEL_QUEUE);
}
//------------------------------------------------------ 订单库存更新
@@ -108,7 +91,6 @@ public class RabbitConfig {
public Queue orderStockQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE, true);
}
@Bean
public Binding bindingOrderStockExchange(Queue orderStockQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderStockQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_STOCK_QUEUE);
@@ -120,29 +102,16 @@ public class RabbitConfig {
public Queue productInfoChangeQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE, true);
}
@Bean
public Binding bindingProductInfoChange(Queue productInfoChangeQueue, DirectExchange exchange) {
return BindingBuilder.bind(productInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.PRODUCT_INFO_CHANGE_QUEUE);
}
//------------------------------------------------------ 耗材信息更新
@Bean
public Queue consInfoChangeQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.CONS_INFO_CHANGE_QUEUE, true);
}
@Bean
public Binding bindingConsInfoChange(Queue consInfoChangeQueue, DirectExchange exchange) {
return BindingBuilder.bind(consInfoChangeQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.CONS_INFO_CHANGE_QUEUE);
}
//------------------------------------------------------ 订单退款
@Bean
public Queue orderRefundQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE, true);
}
@Bean
public Binding bindingOrderRefundExchange(Queue orderRefundQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderRefundQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_REFUND_QUEUE);
@@ -150,7 +119,6 @@ public class RabbitConfig {
//------------------------------------------------------ 申请短信模板队列
/**
* 1,2,applySmsTemp 模版审核
* 1,2,sendMarkSms 发送营销短信
@@ -161,7 +129,6 @@ public class RabbitConfig {
public Queue applySmsTemplateQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, true);
}
@Bean
public Binding bindingApplySmsTemplateExchange(Queue applySmsTemplateQueue, DirectExchange exchange) {
return BindingBuilder.bind(applySmsTemplateQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE);
@@ -172,7 +139,6 @@ public class RabbitConfig {
public Queue birthdayGiftSmsQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE, true);
}
@Bean
public Binding bindingBirthdayGiftSmsExchange(Queue birthdayGiftSmsQueue, DirectExchange exchange) {
return BindingBuilder.bind(birthdayGiftSmsQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.BIRTHDAY_GIFT_SMS_QUEUE);
@@ -183,7 +149,6 @@ public class RabbitConfig {
public Queue orderProductStatusQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRODUCT_STATUS_QUEUE, true);
}
@Bean
public Binding bindingOrderProductStatusExchange(Queue orderProductStatusQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderProductStatusQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_PRODUCT_STATUS_QUEUE);
@@ -195,7 +160,6 @@ public class RabbitConfig {
public Queue orderDetailStatusQueue() {
return new Queue(activeProfile + "-" + RabbitConstants.Queue.ORDER_DETAIL_STATUS_QUEUE, true);
}
@Bean
public Binding bindingOrderDetailStatusExchange(Queue orderDetailStatusQueue, DirectExchange exchange) {
return BindingBuilder.bind(orderDetailStatusQueue).to(exchange).with(activeProfile + "-" + RabbitConstants.Queue.ORDER_DETAIL_STATUS_QUEUE);

View File

@@ -10,18 +10,14 @@ public interface RabbitConstants {
}
class Queue {
public static final String SHOP_ENTRY_MANAGER = "shop.entry.manager";
public static final String ORDER_STOCK_QUEUE = "order.stock.queue";
public static final String ORDER_REFUND_QUEUE = "order.refund.queue";
public static final String ORDER_CANCEL_QUEUE = "order.cancel.queue";
public static final String ORDER_PRINT_QUEUE = "order.print.queue";
public static final String ORDER_MACHINE_PRINT_QUEUE = "order.machine.print.queue";
public static final String OTHER_PRINT_QUEUE = "other.print.queue";
public static final String OTHER_PRINT_LOCAL_QUEUE = "other.print.local.queue";
public static final String ORDER_HANDOVER_PRINT_QUEUE = "order.handover.print.queue";
public static final String CALL_TABLE_PRINT_QUEUE = "call.table.print.queue";
public static final String PRODUCT_INFO_CHANGE_QUEUE = "product.info.change.queue";
public static final String CONS_INFO_CHANGE_QUEUE = "cons.info.change.queue";
/**
* 订单商品状态队列
@@ -33,7 +29,6 @@ public interface RabbitConstants {
* 1,2,applySmsTemp 模版审核
* 1,2,sendMarkSms 发送营销短信
* 1,2,sendWechatTemp 发送微信模版消息
* 1,2,groupBuyYes 拼团成功
*
*/
public static final String APPLY_SMS_TEMPLATE_QUEUE = "apply.sms.temp";

Some files were not shown because too many files have changed in this diff Show More