Merge branch 'test' into prod
# Conflicts: # cash-api/account-server/src/main/java/com/czg/controller/admin/AuthorizationController.java # cash-api/order-server/src/main/java/com/czg/controller/DistributionPayController.java # cash-service/order-service/src/main/java/com/czg/service/order/service/impl/OrderInfoCustomServiceImpl.java # cash-service/order-service/src/main/java/com/czg/service/order/service/impl/PayServiceImpl.java
This commit is contained in:
@@ -1,28 +1,18 @@
|
||||
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.*;
|
||||
import com.czg.account.service.AuthorizationService;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.account.service.SysUserService;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -76,27 +66,6 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销获取 信息使用
|
||||
|
||||
@@ -4,14 +4,18 @@ 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.*;
|
||||
|
||||
@@ -19,6 +23,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单管理
|
||||
*
|
||||
* @author zs
|
||||
*/
|
||||
@RestController
|
||||
@@ -27,9 +32,12 @@ public class MenuController {
|
||||
|
||||
@Resource
|
||||
private SysMenuService menuService;
|
||||
@Resource
|
||||
private QuickMenuService quickMenuService;
|
||||
|
||||
/**
|
||||
* 获取当前用户菜单列表
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@GetMapping
|
||||
@@ -40,6 +48,7 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 收银机菜单
|
||||
*
|
||||
* @return 所有菜单
|
||||
*/
|
||||
@GetMapping("/list/cash")
|
||||
@@ -49,6 +58,7 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 获取所有菜单
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@SaAdminCheckPermission(parentName = "菜单管理", value = "menu:list", name = "菜单列表")
|
||||
@@ -62,6 +72,7 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单详情
|
||||
*
|
||||
* @return 菜单结构
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -73,6 +84,7 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单添加
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -84,6 +96,7 @@ public class MenuController {
|
||||
|
||||
/**
|
||||
* 菜单修改
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@@ -95,12 +108,15 @@ 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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
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())));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
package com.czg.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
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;
|
||||
@@ -15,13 +12,11 @@ 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;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -3,9 +3,14 @@ package com.czg.controller;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.CzgPayUtils;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.PolyPayUtils;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.entity.CzgBaseRespParams;
|
||||
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.market.entity.MkShopConsumeDiscountRecord;
|
||||
import com.czg.market.service.MkDistributionUserService;
|
||||
import com.czg.market.service.MkShopConsumeDiscountRecordService;
|
||||
@@ -14,16 +19,15 @@ 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.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -59,13 +63,57 @@ public class NotifyController {
|
||||
return "success";
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生支付回调
|
||||
*/
|
||||
@RequestMapping("/native/pay/{platform}")
|
||||
public String pay(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.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.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
|
||||
/**
|
||||
* 原生退款回调
|
||||
*/
|
||||
@RequestMapping("/native/refund/{platform}")
|
||||
public String refund(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.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.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
throw new CzgException("不支持的支付平台");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/payCallBack")
|
||||
public String notifyCallBack(@RequestBody CzgBaseRespParams respParams) {
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "支付回调数据为空");
|
||||
log.info("支付回调数据为:{}", czg);
|
||||
orderInfoCustomService.payCallBackOrder(czg.getString("mchOrderNo"), czg, 0);
|
||||
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);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -87,12 +135,15 @@ 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");
|
||||
@@ -127,8 +178,8 @@ public class NotifyController {
|
||||
|
||||
|
||||
@RequestMapping("/refundCallBack")
|
||||
public String refundCallBack(@RequestBody CzgBaseRespParams respParams) {
|
||||
JSONObject czg = CzgPayUtils.getCzg(respParams);
|
||||
public String refundCallBack(@RequestBody PolyBaseResp respParams) {
|
||||
JSONObject czg = PolyPayUtils.getCzg(respParams);
|
||||
AssertUtil.isNull(czg, "退款回调数据为空");
|
||||
log.info("退款回调数据为:{}", czg);
|
||||
orderInfoCustomService.refundCallBackOrder(czg.getString("mchOrderNo"), czg);
|
||||
|
||||
@@ -9,7 +9,7 @@ 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.PayService;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
@@ -31,7 +31,7 @@ public class AdminOrderController {
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoService;
|
||||
@Resource
|
||||
private PayService payService;
|
||||
private OrderPayService orderPayService;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
@@ -94,7 +94,7 @@ public class AdminOrderController {
|
||||
@PostMapping("/refundOrder")
|
||||
@Debounce(value = "#refundDTO.orderId")
|
||||
public CzgResult<Object> refundOrder(@Validated @RequestBody OrderInfoRefundDTO refundDTO) {
|
||||
return payService.refundOrderBefore(refundDTO);
|
||||
return orderPayService.refundOrderBefore(refundDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
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.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
|
||||
@@ -24,25 +23,36 @@ public class ShopMerchantController {
|
||||
/**
|
||||
* 商户支付信息获取
|
||||
* 权限标识: shopMerchant:detail
|
||||
*
|
||||
* @param shopId 店铺id
|
||||
* @return 支付信息
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:detail", name = "商户支付信息获取")
|
||||
@GetMapping
|
||||
public CzgResult<ShopMerchant> detail(@RequestParam Integer shopId) {
|
||||
public CzgResult<ShopMerchantDTO> detail(@RequestParam Long shopId) {
|
||||
return CzgResult.success(shopMerchantService.detail(shopId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 商户支付信息修改
|
||||
* 权限标识: shopMerchant:edit
|
||||
*
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@SaAdminCheckPermission(parentName = "支付参数信息", value = "shopMerchant:edit", name = "商户支付信息修改")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopMerchantEditDTO shopMerchantEditDTO) {
|
||||
return CzgResult.success(shopMerchantService.edit(shopMerchantEditDTO));
|
||||
public CzgResult<Boolean> edit(@RequestBody ShopMerchantDTO shopMerchant) {
|
||||
return CzgResult.success(shopMerchantService.editEntry(shopMerchant, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前店铺的主店进件信息
|
||||
*/
|
||||
@SaAdminCheckRole("管理员")
|
||||
@GetMapping("getMainMerchant")
|
||||
public CzgResult<ShopDirectMerchant> getMainMerchant(Long shopId) {
|
||||
return CzgResult.success(shopMerchantService.getMainMerchant(shopId));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
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 支付宝,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(@Validated @RequestBody MkDistributionPayDTO payParam) {
|
||||
AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
|
||||
return CzgResult.success(payService.mchRecharge(payParam));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.czg.controller;
|
||||
package com.czg.controller.pay;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
@@ -10,7 +10,7 @@ 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.PayService;
|
||||
import com.czg.service.order.service.OrderPayService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.ServletUtil;
|
||||
@@ -35,7 +35,7 @@ import java.util.Map;
|
||||
@RequestMapping("/pay")
|
||||
public class OrderPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
private OrderPayService orderPayService;
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
@@ -47,14 +47,14 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> creditPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.creditPayOrder(payParam);
|
||||
return orderPayService.creditPayOrder(payParam);
|
||||
}
|
||||
|
||||
@PostMapping("/cashPay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.cashPayOrder(payParam);
|
||||
return orderPayService.cashPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> rechargePayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.rechargePayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,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 payService.vipPayOrder(payParam);
|
||||
return orderPayService.vipPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ 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 payService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
return orderPayService.h5PayOrder(ServletUtil.getClientIP(request, ""), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> jsPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.jsPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> ltPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public class OrderPayController {
|
||||
@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);
|
||||
return orderPayService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class OrderPayController {
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody OrderPayParamDTO payParam) {
|
||||
payParam.setShopId(shopId);
|
||||
return payService.microPayOrder(payParam);
|
||||
return orderPayService.microPayOrder(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +174,7 @@ public class OrderPayController {
|
||||
@PostMapping("/shopPayApi/js2Pay")
|
||||
@Debounce(value = "#payParam.checkOrderPay.orderId")
|
||||
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
|
||||
return payService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.czg.controller;
|
||||
package com.czg.controller.pay;
|
||||
|
||||
import com.czg.annotation.Debounce;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.order.entity.OrderPayment;
|
||||
import com.czg.order.service.OrderPaymentService;
|
||||
import com.czg.pay.QueryOrderRespDTO;
|
||||
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;
|
||||
@@ -28,6 +32,11 @@ import java.util.Map;
|
||||
public class VipPayController {
|
||||
@Resource
|
||||
private PayService payService;
|
||||
@Resource
|
||||
private ShopUserPayService shopUserPayService;
|
||||
|
||||
@Resource
|
||||
private OrderPaymentService paymentService;
|
||||
|
||||
/**
|
||||
* 现金充值
|
||||
@@ -39,7 +48,7 @@ public class VipPayController {
|
||||
public CzgResult<Object> cashPayVip(@Validated @RequestBody VipPayParamDTO payParam) {
|
||||
AssertUtil.isNull(payParam.getShopUserId(), "充值失败 未指定店铺用户Id");
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.cashPayVip(payParam);
|
||||
return shopUserPayService.cashPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +61,7 @@ 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 payService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.jsPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,14 +74,11 @@ 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 payService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.ltPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
* 智慧充值
|
||||
* @param request
|
||||
* @param rechargeDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/recharge")
|
||||
@Debounce(value = "#rechargeDTO.shopUserId")
|
||||
@@ -81,21 +87,18 @@ public class VipPayController {
|
||||
return CzgResult.failure("充值失败 未指定充值金额");
|
||||
}
|
||||
rechargeDTO.setPlatformType(ServletUtil.getHeaderIgnoreCase(ServletUtil.getRequest(), "platformType"));
|
||||
return payService.recharge(ServletUtil.getClientIP(request), rechargeDTO, rechargeDTO.getShopUserId());
|
||||
return shopUserPayService.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 payService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.ltPayMember(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,7 +111,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 payService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
return shopUserPayService.scanPayVip(ServletUtil.getClientIP(request), payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +124,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 payService.microPayVip(payParam);
|
||||
return shopUserPayService.microPayVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,7 +135,7 @@ public class VipPayController {
|
||||
@PostMapping("/refundVipBefore")
|
||||
@Debounce(value = "#payParam.flowId")
|
||||
public CzgResult<Map<String, BigDecimal>> refundVipBefore(@Validated @RequestBody VipRefundDTO payParam) {
|
||||
return payService.refundVipBefore(payParam);
|
||||
return shopUserPayService.refundVipBefore(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +158,7 @@ public class VipPayController {
|
||||
return CzgResult.failure("退款金额过大");
|
||||
}
|
||||
payParam.setPlatformType(ServletUtil.getHeaderIgnoreCase(request, "platformType"));
|
||||
return payService.refundVip(payParam);
|
||||
return shopUserPayService.refundVip(payParam);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,10 +168,16 @@ 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<CzgBaseResp> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo);
|
||||
if (queryPayOrder.getCode() == 200 && queryPayOrder.getData() != null) {
|
||||
String state = queryPayOrder.getData().getState();
|
||||
CzgResult<QueryOrderRespDTO> queryPayOrder = payService.queryPayOrder(shopId, null, payOrderNo, payment.getPlatformType());
|
||||
if (queryPayOrder.isSuccess() && queryPayOrder.getData() != null) {
|
||||
String state = queryPayOrder.getData().getStatus();
|
||||
result.setData(state);
|
||||
switch (state) {
|
||||
case "TRADE_AWAIT" -> result.setMsg("等待用户付款");
|
||||
@@ -0,0 +1,144 @@
|
||||
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;
|
||||
}
|
||||
Long shopId = Long.valueOf(split[0]);
|
||||
if (shopId == null) {
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
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.Platform.ALIPAY);
|
||||
}
|
||||
if (PayCst.EntryStatus.WAIT.equals(entry.getWechatStatus())) {
|
||||
platform.add(PayCst.Platform.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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ 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.order.utils.FunUtil;
|
||||
import com.czg.service.RedisService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
@@ -31,7 +31,7 @@ public class OrderMqListener {
|
||||
@Resource
|
||||
private OrderInfoCustomService orderInfoCustomService;
|
||||
@Resource
|
||||
private FunUtil funUtil;
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 订单上菜
|
||||
@@ -44,13 +44,10 @@ public class OrderMqListener {
|
||||
info = info.replace("UP_ORDER_DETAIL:", "");
|
||||
log.info("接收到修改菜品状态mq, info: {}", info);
|
||||
String finalInfo = info;
|
||||
funUtil.debounce("UP_ORDER_DETAIL:" + info, 5, () -> {
|
||||
redisService.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})
|
||||
|
||||
@@ -6,13 +6,12 @@ import com.czg.config.RabbitConstants;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.order.entity.MqLog;
|
||||
import com.czg.order.service.MqLogService;
|
||||
import com.czg.service.RedisService;
|
||||
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;
|
||||
@@ -28,19 +27,15 @@ public class PrintMqListener {
|
||||
@Resource
|
||||
private MqLogService mqLogService;
|
||||
@Resource
|
||||
private FunUtil funUtil;
|
||||
|
||||
// 注入自定义线程池(建议单独配置,避免使用默认线程池)
|
||||
@Resource
|
||||
private ThreadPoolTaskExecutor asyncExecutor;
|
||||
private RedisService redisService;
|
||||
@Lazy
|
||||
@Resource
|
||||
private PrinterHandler printerHandler;
|
||||
|
||||
private <T> void invokeFun(String type, String plat, T data, Consumer<T> consumer) {
|
||||
private <T> void invokeFun(String queue, String type, String plat, T data, Consumer<T> consumer) {
|
||||
long startTime = DateUtil.date().getTime();
|
||||
log.info("接收到{}打印消息:{}", type, data);
|
||||
MqLog mqLog = new MqLog().setQueue(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE).setMsg(data.toString())
|
||||
MqLog mqLog = new MqLog().setQueue(queue).setMsg(data.toString())
|
||||
.setType(type).setPlat(plat).setCreateTime(DateUtil.date().toLocalDateTime());
|
||||
try {
|
||||
consumer.accept(data);
|
||||
@@ -56,45 +51,18 @@ public class PrintMqListener {
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE})
|
||||
public void orderPrint(String req) {
|
||||
// 执行核心打印逻辑
|
||||
invokeFun("orderPrint", "java.order", req, (data) -> {
|
||||
invokeFun(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, "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(() -> {
|
||||
redisService.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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,14 +70,16 @@ public class PrintMqListener {
|
||||
*/
|
||||
@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));
|
||||
invokeFun(RabbitConstants.Queue.ORDER_HANDOVER_PRINT_QUEUE, "handoverPrint", "java.order", id, (data) ->
|
||||
printerHandler.handler(data, PrinterHandler.PrintTypeEnum.HANDOVER));
|
||||
}
|
||||
|
||||
/**
|
||||
* 交班打印
|
||||
* 叫号打印
|
||||
*/
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_PRINT_QUEUE})
|
||||
@RabbitListener(queues = {"${spring.profiles.active}-" + RabbitConstants.Queue.CALL_TABLE_QUEUE})
|
||||
public void callTablePrint(String id) {
|
||||
invokeFun("handoverPrint", "java.order", id, (data) -> printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL));
|
||||
invokeFun(RabbitConstants.Queue.CALL_TABLE_QUEUE, "callTable", "java.order", id, (data) ->
|
||||
printerHandler.handler(data, PrinterHandler.PrintTypeEnum.CALL));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
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.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 进件查询
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EntryManagerTask {
|
||||
@Resource
|
||||
private ShopDirectMerchantService shopDirectMerchantService;
|
||||
@Resource
|
||||
private ShopMerchantService shopMerchantService;
|
||||
|
||||
//每10分钟查一次
|
||||
@Scheduled(cron = "0 0/10 * * * ? ")
|
||||
public void run() {
|
||||
log.info("进件查询,定时任务执行");
|
||||
long start = System.currentTimeMillis();
|
||||
entryManager(null);
|
||||
log.info("进件查询,定时任务执行完毕,耗时:{}ms", start - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询状态为待处理、待签约、待审核的进件
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单过期处理
|
||||
* 退款失败 补偿
|
||||
*
|
||||
* @author ww
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,23 @@ 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
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user