Compare commits
52 Commits
dev
...
7d640b4f9c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d640b4f9c | |||
| 3fd032c1d0 | |||
| 6b0423a2ba | |||
| 9c69c8dcbc | |||
| 19ed77b35b | |||
| d1dd806204 | |||
| c015c9d907 | |||
| 08eec1b338 | |||
| 782fd5a0e5 | |||
| 4c65d3226a | |||
| 74156e207a | |||
| b74367b9cd | |||
| 1c7d3ac374 | |||
| 1a18449d65 | |||
| 3b28287f22 | |||
| b9e768bd47 | |||
| 3dcc649224 | |||
| 5cb95a31f1 | |||
| f2ab7bdcd5 | |||
| 10cb6aa8cc | |||
| ff95440732 | |||
| 5fe6b48786 | |||
| 6bd1959fc3 | |||
| c78b7a1ec3 | |||
|
|
bae925695a | ||
| a94a9197b8 | |||
| 3a1579d281 | |||
| f092fdc0e9 | |||
| bb673d805a | |||
| 0ba52b85b2 | |||
| 0345ab85ec | |||
| 6f64c8be81 | |||
| 1ce9b023ab | |||
| a1aebd16de | |||
| 0549a077b2 | |||
| 45965fb426 | |||
| 034a8c4650 | |||
| 4cd71ad35a | |||
| 64830203f3 | |||
| c542f18938 | |||
| cc40a8a7f0 | |||
| f10bafce52 | |||
| 3e42b534e0 | |||
| a367a286ce | |||
| 37651e0e02 | |||
| 9bcbad42ad | |||
| 8242a4f905 | |||
| cf3c58169d | |||
| f1e9d0f4cf | |||
| de21e0a202 | |||
| fff14043b5 | |||
| 5da3b447c7 |
@@ -16,7 +16,10 @@ import com.czg.sa.StpKit;
|
||||
import com.czg.task.DistributionTask;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import io.seata.core.exception.TransactionException;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.NestedExceptionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -27,6 +30,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/user/distribution")
|
||||
public class UDistributionController {
|
||||
@@ -42,7 +46,7 @@ public class UDistributionController {
|
||||
private DistributionTask distributionTask;
|
||||
|
||||
/**
|
||||
* 分销员中心-获取配置
|
||||
* 测试方法-分销流水入账
|
||||
*/
|
||||
@GetMapping("/task")
|
||||
public CzgResult<String> task(@RequestParam Long shopId) {
|
||||
@@ -103,6 +107,20 @@ public class UDistributionController {
|
||||
return CzgResult.success(distributionUserService.getInviteCode(shopId, shopUserId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-获取邀请码
|
||||
*/
|
||||
@GetMapping("/autoGetInviteCode")
|
||||
public CzgResult<String> autoGetInviteCode(@RequestParam Long shopId, @RequestParam Long shopUserId) {
|
||||
try {
|
||||
return CzgResult.success(distributionUserService.getInviteCode(shopId, shopUserId));
|
||||
} catch (Exception e) {
|
||||
String rootMsg = NestedExceptionUtils.getMostSpecificCause(e).getMessage();
|
||||
log.error("获取邀请码失败用户:{},:{}", shopUserId, rootMsg);
|
||||
return CzgResult.success("");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-实名认证
|
||||
*/
|
||||
@@ -115,6 +133,20 @@ public class UDistributionController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分销员中心-无感-绑定邀请人
|
||||
*/
|
||||
@PostMapping("/autoBindInviteUser")
|
||||
public CzgResult<Map<String, Object>> autoBindInviteUser(@RequestBody MkDistributionUserDTO param) throws TransactionException {
|
||||
try {
|
||||
bindInviteUser(param);
|
||||
} catch (Exception e) {
|
||||
log.error("无感绑定邀请人失败:{}", param, e);
|
||||
}
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分销员中心-绑定邀请人
|
||||
*/
|
||||
@@ -172,10 +204,7 @@ public class UDistributionController {
|
||||
/**
|
||||
* 收益明细
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @param shopId
|
||||
* @param status pending待入账 success已入账
|
||||
* @param status pending待入账 success已入账
|
||||
*/
|
||||
@GetMapping("/distributionFlow")
|
||||
public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,
|
||||
|
||||
@@ -79,7 +79,7 @@ public class UPpPackageController {
|
||||
* 取消订单
|
||||
*/
|
||||
@GetMapping("/cancel")
|
||||
public CzgResult<Boolean> cancelOrder(Long orderId) {
|
||||
public CzgResult<Boolean> cancelOrder(@RequestParam Long orderId) {
|
||||
return CzgResult.success(ppPackageOrderService.cancelOrder(orderId));
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class UPpPackageController {
|
||||
* 获取订单详情
|
||||
*/
|
||||
@GetMapping("/order/detail")
|
||||
public CzgResult<PpPackageOrderDTO> getOrderDetail(Long orderId) {
|
||||
public CzgResult<PpPackageOrderDTO> getOrderDetail(@RequestParam Long orderId) {
|
||||
return CzgResult.success(ppPackageOrderService.getOrderDetailById(orderId, StpKit.USER.getLoginIdAsLong()));
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public class NotifyController {
|
||||
*/
|
||||
@RequestMapping("/native/pay/{platform}")
|
||||
public String pay(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
|
||||
if (PayCst.Type.WECHAT.equalsIgnoreCase(platform)) {
|
||||
// 微信
|
||||
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
|
||||
log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto));
|
||||
@@ -80,7 +80,7 @@ public class NotifyController {
|
||||
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
|
||||
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
|
||||
return "success";
|
||||
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
} else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class NotifyController {
|
||||
*/
|
||||
@RequestMapping("/native/refund/{platform}")
|
||||
public String refund(@PathVariable String platform, @RequestBody JSONObject json) {
|
||||
if (PayCst.Platform.WECHAT.equalsIgnoreCase(platform)) {
|
||||
if (PayCst.Type.WECHAT.equalsIgnoreCase(platform)) {
|
||||
// 微信
|
||||
WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
|
||||
log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto));
|
||||
@@ -100,7 +100,7 @@ public class NotifyController {
|
||||
log.info("【微信退款回调】解密数据 {}", decrypted);
|
||||
|
||||
return "success";
|
||||
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
} else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
|
||||
// 支付宝
|
||||
return "success";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class DistributionPayController {
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/ltPayOrder")
|
||||
@@ -42,7 +42,7 @@ public class DistributionPayController {
|
||||
|
||||
/**
|
||||
* 运营端小程序余额充值
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
*/
|
||||
@PostMapping("/mchRecharge")
|
||||
@Debounce(value = "#payParam.userId")
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.czg.controller.pay;
|
||||
|
||||
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;
|
||||
@@ -59,7 +61,7 @@ public class OrderPayController {
|
||||
|
||||
/**
|
||||
* 充值并付款
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/rechargePayOrder")
|
||||
@@ -99,7 +101,7 @@ public class OrderPayController {
|
||||
/**
|
||||
* js支付
|
||||
* <p>
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/jsPay")
|
||||
@@ -111,7 +113,7 @@ public class OrderPayController {
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/ltPayOrder")
|
||||
@@ -167,13 +169,21 @@ public class OrderPayController {
|
||||
}
|
||||
|
||||
/**
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* 空订单支付/h5页面支付
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class VipPayController {
|
||||
|
||||
/**
|
||||
* js支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/jsPayVip")
|
||||
@@ -66,7 +66,7 @@ public class VipPayController {
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/ltPayVip")
|
||||
@@ -139,6 +139,7 @@ public class VipPayController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 会员退款
|
||||
* cashRefund 是否是现金退款
|
||||
* 会员退款(先调用 退款前置接口 refundVipBefore)
|
||||
* 最大退款金额为 充值金额 inAmount
|
||||
|
||||
@@ -90,7 +90,7 @@ public class UGbOrderController {
|
||||
/**
|
||||
* 生成订单
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/exchange")
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
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.service.PointsGoodPayService;
|
||||
@@ -34,6 +37,8 @@ public class UPointGoodsController {
|
||||
private MkPointsGoodsRecordService goodsRecordService;
|
||||
@Resource
|
||||
private PointsGoodPayService goodPayService;
|
||||
@Resource
|
||||
private ShopCouponService shopCouponService;
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
@@ -51,10 +56,26 @@ 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 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/exchange")
|
||||
|
||||
@@ -45,7 +45,7 @@ public class UPpOrderController {
|
||||
|
||||
/**
|
||||
* 小程序支付
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
*/
|
||||
@PostMapping("/pay")
|
||||
|
||||
@@ -62,11 +62,11 @@ public class EntryManagerMqListener {
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
Long shopId = Long.valueOf(split[0]);
|
||||
if (shopId == null) {
|
||||
if (split[0]==null) {
|
||||
channel.basicNack(deliveryTag, false, false);
|
||||
return;
|
||||
}
|
||||
Long shopId = Long.valueOf(split[0]);
|
||||
if (hasMessageId(msg)) {
|
||||
return;
|
||||
}
|
||||
@@ -81,10 +81,10 @@ public class EntryManagerMqListener {
|
||||
EntryManager.uploadParamImage(entry);
|
||||
List<String> platform = new ArrayList<>();
|
||||
if (PayCst.EntryStatus.WAIT.equals(entry.getAlipayStatus())) {
|
||||
platform.add(PayCst.Platform.ALIPAY);
|
||||
platform.add(PayCst.Type.ALIPAY);
|
||||
}
|
||||
if (PayCst.EntryStatus.WAIT.equals(entry.getWechatStatus())) {
|
||||
platform.add(PayCst.Platform.WECHAT);
|
||||
platform.add(PayCst.Type.WECHAT);
|
||||
}
|
||||
EntryRespDto resp = EntryManager.entryMerchant(entry, platform.toArray(new String[0]));
|
||||
ShopDirectMerchant merchant = new ShopDirectMerchant();
|
||||
|
||||
@@ -21,7 +21,7 @@ wx:
|
||||
appId: wx212769170d2c6b2a
|
||||
secrete: 8492a7e8d55bbb1b57f5c8276ea1add0
|
||||
operationMsgTmpId: wFdoUG-dUT7bDRHq8bMJD9CF5TjyH9x_uJQgQByZqHg
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSQ3Sv7VF5vksdZigiEx2pD0
|
||||
warnMsgTmpId: C08OUr80x6wGmUN1zpFhSZyFA2G6b9_jiZgEppzLB70
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -164,20 +165,23 @@ public class CzgControllerAdvice {
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> errorHandler(Exception ex) {
|
||||
log.error("系统未处理异常", ex);
|
||||
Throwable rootCause = ex;
|
||||
while (rootCause.getCause() != null && !(rootCause instanceof CzgException)) {
|
||||
rootCause = rootCause.getCause();
|
||||
}
|
||||
String rootMsg = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
|
||||
return CzgResult.failure(CzgRespCode.FAILURE.getCode(), rootMsg);
|
||||
|
||||
// 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());
|
||||
}
|
||||
// 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) {
|
||||
|
||||
@@ -56,8 +56,8 @@ public class RabbitPublisher {
|
||||
* @param orderId 订单id
|
||||
* @param printOrder 是否打印结算单
|
||||
*/
|
||||
public void sendOrderPrintMsg(String orderId, boolean printOrder) {
|
||||
log.info("开始发送打印mq消息, orderId: {}, printOrder: {}", orderId, printOrder);
|
||||
public void sendOrderPrintMsg(String orderId, boolean printOrder, String source) {
|
||||
log.info("开始发送打印mq消息, orderId: {}, printOrder: {}, source: {}", orderId, printOrder, source);
|
||||
//厨房票
|
||||
sendMsg(RabbitConstants.Queue.ORDER_MACHINE_PRINT_QUEUE, new JSONObject().fluentPut("orderId", orderId).fluentPut("printOrder", printOrder).toString());
|
||||
//前台票
|
||||
@@ -108,8 +108,9 @@ public class RabbitPublisher {
|
||||
* 1,2,sendMarkSms 发送营销短信 shop_id,sms_push_event.id,sendMarkSms
|
||||
* 1,2,sendWechatTemp 发送微信模版消息 shop_id,ac_push_event.id,sendWechatTemp
|
||||
* 1,2,groupBuyYes 发送微信模版消息 shop_id,gb_order.id,groupBuyYes
|
||||
*
|
||||
* @param param 店铺Id,主键Id
|
||||
* @param type applySmsTemp,sendMarkSms,sendWechatTemp,groupBuyYes
|
||||
* @param type applySmsTemp,sendMarkSms,sendWechatTemp,groupBuyYes
|
||||
*/
|
||||
public void sendApplySmsMsg(String param, String type) {
|
||||
sendMsg(RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, param + "," + type);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.czg.config;
|
||||
|
||||
import cn.dev33.satoken.application.ApplicationInfo;
|
||||
import cn.dev33.satoken.config.SaTokenConfig;
|
||||
import cn.dev33.satoken.context.SaHolder;
|
||||
import cn.dev33.satoken.interceptor.SaInterceptor;
|
||||
@@ -43,7 +42,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
userConfig.setIsShare(true);
|
||||
// config2.setTimeout(2000);
|
||||
userConfig.setTokenStyle("simple-uuid");
|
||||
MyStpLogic.CLIENT_LOGIC.setConfig(userConfig);
|
||||
MyStpLogic.USER_LOGIC.setConfig(userConfig);
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@@ -58,25 +57,32 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
// 注册路由拦截器,自定义认证规则
|
||||
registry.addInterceptor(new SaInterceptor(handler -> {
|
||||
log.info(SaHolder.getRequest().getRequestPath());
|
||||
// 重置根路径,防止satoken切割根路径导致匹配不到路径
|
||||
ApplicationInfo.routePrefix = "";
|
||||
log.info("{}: {}", SaHolder.getRequest().getMethod(), SaHolder.getRequest().getRequestPath());
|
||||
if ("OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod())) {
|
||||
SaRouter.back();
|
||||
return;
|
||||
}
|
||||
SaRouter
|
||||
.match(r -> "OPTIONS".equalsIgnoreCase(SaHolder.getRequest().getMethod()))
|
||||
.stop()
|
||||
// 完全开放的路径(不需要任何认证)
|
||||
.match("/user/login", "/user/geo/**", "/user/home/**",
|
||||
"/user/dict/**", "/user/openId", "/admin/auth/**",
|
||||
"/admin/shopMsgPush/subscribe/**",
|
||||
"/admin/coupon/grant",
|
||||
"/pay/**",
|
||||
"/notify/**")
|
||||
.stop() // 直接放行,不检查登录
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
.notMatch("/user/**")
|
||||
.notMatch("/pay/**")
|
||||
.notMatch("/notify/**")
|
||||
.notMatch("/admin/auth/**")
|
||||
.notMatch("/admin/shopMsgPush/subscribe/**")
|
||||
.notMatch("/admin/coupon/grant")
|
||||
// 用户认证路径
|
||||
.match("/user/**")
|
||||
.check(r -> MyStpLogic.USER_LOGIC.checkLogin())
|
||||
|
||||
// 管理端认证(内网IP免认证)
|
||||
.match("/**")
|
||||
.check(r -> {
|
||||
ServletRequestAttributes attributes =
|
||||
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes)
|
||||
RequestContextHolder.getRequestAttributes();
|
||||
if (attributes == null || (!ServletUtil.getClientIP(attributes.getRequest()).contains("192.168") && !ServletUtil.getClientIP(attributes.getRequest()).contains("127.0.0.1"))) {
|
||||
MyStpLogic.ADMIN_LOGIC.checkLogin();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.function.Consumer;
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class MyStpLogic {
|
||||
public static final StpLogic CLIENT_LOGIC = new StpLogic("client");
|
||||
public static final StpLogic USER_LOGIC = new StpLogic("user");
|
||||
public static final StpLogic ADMIN_LOGIC = new StpLogic("admin");
|
||||
|
||||
public Object isPC() {
|
||||
@@ -42,7 +42,7 @@ public class MyStpLogic {
|
||||
private StpLogic getLogic() {
|
||||
boolean hit = SaRouter.match("/user/**").isHit();
|
||||
if (hit) {
|
||||
return CLIENT_LOGIC;
|
||||
return USER_LOGIC;
|
||||
}
|
||||
return ADMIN_LOGIC;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,23 @@ public class ShopUser implements Serializable {
|
||||
private LocalDateTime nextDeliverTime;
|
||||
// 是否分销员
|
||||
private String distributionShops;
|
||||
/**
|
||||
* 上级分销员id
|
||||
*/
|
||||
private Long parentUserId;
|
||||
/**
|
||||
* 上上级分销员id
|
||||
*/
|
||||
private Long gradeUserId;
|
||||
/**
|
||||
* 一级分销收入
|
||||
*/
|
||||
private BigDecimal oneIncome;
|
||||
/**
|
||||
* 二级分销收入
|
||||
*/
|
||||
private BigDecimal twoIncome;
|
||||
|
||||
private String memberCircleName;
|
||||
private Integer memberCircleReward;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.czg.account.service;
|
||||
|
||||
import com.czg.account.entity.ShopConfig;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -15,7 +16,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface ShopConfigService extends IService<ShopConfig> {
|
||||
|
||||
ShopInfo getShopInfoAndConfig(Serializable id);
|
||||
ShopInfo getShopInfoAndConfig(Serializable id) throws CzgException;
|
||||
|
||||
void editStatusByShopIdList(Long mainShopId, Integer isEnable, boolean onyUpValid, String name, String useShopType, List<Long> shopIdList);
|
||||
|
||||
|
||||
@@ -46,18 +46,9 @@ public interface SystemConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 三方支付类型
|
||||
* 小程序APPID
|
||||
*/
|
||||
class PayType {
|
||||
/**
|
||||
* 微信支付
|
||||
*/
|
||||
public static final String WECHAT = "wechatPay";
|
||||
|
||||
/**
|
||||
* 支付宝支付
|
||||
*/
|
||||
public static final String ALIPAY = "alipay";
|
||||
class PayAppId {
|
||||
|
||||
/**
|
||||
* 微信小程序支付
|
||||
|
||||
@@ -110,8 +110,10 @@ public class MkDistributionFlow implements Serializable {
|
||||
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 分成比例
|
||||
*/
|
||||
private BigDecimal commission;
|
||||
private BigDecimal parentCommission;
|
||||
private LocalDateTime deliverTime;
|
||||
private Long userId;
|
||||
}
|
||||
|
||||
@@ -62,12 +62,8 @@ public class MkDistributionLevelConfig implements Serializable {
|
||||
/**
|
||||
* 一级分销比例
|
||||
*/
|
||||
private BigDecimal levelOneCommission;
|
||||
private BigDecimal commission;
|
||||
|
||||
/**
|
||||
* 二级分销比例
|
||||
*/
|
||||
private BigDecimal levelTwoCommission;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.czg.market.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 邀请与上级关联表 实体类。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-11-06
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_user_invite")
|
||||
public class ShopUserInvite implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* (随机)
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺ID
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 店铺用户ID
|
||||
*/
|
||||
private Long shopUserId;
|
||||
|
||||
/**
|
||||
* 邀请人ID mk_distribution_user.id
|
||||
*/
|
||||
private Long distributionUserId;
|
||||
|
||||
/**
|
||||
* 邀请人上级ID mk_distribution_user.id
|
||||
*/
|
||||
private Long distributionUserParentId;
|
||||
|
||||
/**
|
||||
* 邀请人收益/一级分润
|
||||
*/
|
||||
private BigDecimal oneIncome;
|
||||
|
||||
/**
|
||||
* 邀请人上级收益/二级分润
|
||||
*/
|
||||
private BigDecimal twoIncome;
|
||||
|
||||
/**
|
||||
* 邀请时间
|
||||
*/
|
||||
private LocalDateTime inviteTime;
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
|
||||
/**
|
||||
* 分销员中心-获取邀请码
|
||||
*/
|
||||
String getInviteCode(Long shopId, Long shopUserId);
|
||||
String getInviteCode(Long shopId, Long shopUserId) throws CzgException, ValidateException ;
|
||||
|
||||
/**
|
||||
* 分销员中心-实名认证
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.czg.market.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.market.entity.ShopUserInvite;
|
||||
|
||||
/**
|
||||
* 邀请与上级关联表 服务层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-11-06
|
||||
*/
|
||||
public interface ShopUserInviteService extends IService<ShopUserInvite> {
|
||||
|
||||
/**
|
||||
* 根据店铺ID和店铺用户ID查询邀请记录
|
||||
*
|
||||
* @param shopId 店铺ID
|
||||
* @param shopUserId 店铺用户ID
|
||||
* @return 邀请记录
|
||||
*/
|
||||
ShopUserInvite getOneByShopIdAndShopUserId(Long shopId, Long shopUserId);
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 小程序支付 其它类型
|
||||
* payType 必填 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* payType 必填 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
* openId 必填
|
||||
* @author ww
|
||||
*/
|
||||
@@ -32,7 +32,7 @@ public class LtPayOtherDTO {
|
||||
@NotNull(message = "兑换数量不能为空")
|
||||
private int number;
|
||||
/**
|
||||
* 支付方式 支付方式,aliPay 支付宝,wechatPay 微信
|
||||
* 支付方式,ALIPAY 支付宝,WECHAT 微信
|
||||
*/
|
||||
private String payType;
|
||||
/**
|
||||
@@ -58,8 +58,13 @@ public class LtPayOtherDTO {
|
||||
* 对应的记录Id 支付回调向该内容进行回填
|
||||
* 积分商品为 mk_points_goods_record 主键id
|
||||
* 团购商品为 gb_order_detail 主键id
|
||||
*
|
||||
*/
|
||||
private Long recordId;
|
||||
/**
|
||||
* 霸王餐充值为 订单id 会员充值为 活动id
|
||||
*/
|
||||
private Long relatedId;
|
||||
|
||||
public void checkPayInfo(){
|
||||
AssertUtil.isBlank(payType, "支付方式不能为空");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
package com.czg.order.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -26,7 +25,7 @@ public class MkDistributionPayDTO implements Serializable {
|
||||
private Long userId;
|
||||
/**
|
||||
* 支付类型
|
||||
* {@link com.czg.constants.SystemConstants.PayType}
|
||||
* {@link com.czg.PayCst.Type}
|
||||
*/
|
||||
private String payType;
|
||||
private String returnUrl;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.czg.utils;
|
||||
import cn.hutool.core.lang.func.Func0;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.NestedExceptionUtils;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
@@ -27,11 +28,17 @@ public class FunUtils {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void asyncSafeRunVoid(Runnable func, String... msg) {
|
||||
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
|
||||
}
|
||||
|
||||
|
||||
public static void safeRunVoid(Runnable func, String... msg) {
|
||||
try {
|
||||
func.run();
|
||||
} catch (Exception e) {
|
||||
log.warn(msg.length > 0 ? msg[0] : "方法执行失败: {}", e.getMessage());
|
||||
String message = NestedExceptionUtils.getMostSpecificCause(e).getMessage();
|
||||
log.warn((msg.length > 0 ? msg[0] : "方法执行失败") + ": " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,13 +50,8 @@ public class FunUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void asyncSafeRunVoid(Runnable func, String... msg) {
|
||||
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在事务提交后执行方法
|
||||
* 异步 执行
|
||||
*
|
||||
* @param func 方法
|
||||
*/
|
||||
|
||||
@@ -80,13 +80,13 @@ public class EntryManager {
|
||||
List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>();
|
||||
|
||||
if (platform == null || platform.length == 0) {
|
||||
platform = new String[]{PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY};
|
||||
platform = new String[]{PayCst.Type.WECHAT, PayCst.Type.ALIPAY};
|
||||
}
|
||||
|
||||
if (ArrayUtil.contains(platform, PayCst.Platform.WECHAT)) {
|
||||
if (ArrayUtil.contains(platform, PayCst.Type.WECHAT)) {
|
||||
tasks.add(() -> WechatEntryManager.entryMerchant(null, reqDto));
|
||||
}
|
||||
if (ArrayUtil.contains(platform, PayCst.Platform.ALIPAY)) {
|
||||
if (ArrayUtil.contains(platform, PayCst.Type.ALIPAY)) {
|
||||
tasks.add(() -> AlipayIsvEntryManager.entryMerchant(null, reqDto));
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ public class EntryManager {
|
||||
for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) {
|
||||
// 合并两个进件结果
|
||||
EntryThirdRespDto respDto = result.result();
|
||||
if (PayCst.Platform.WECHAT.equals(respDto.getPlatform())) {
|
||||
if (PayCst.Type.WECHAT.equals(respDto.getPlatform())) {
|
||||
entryRespDto.setWechatApplyId(respDto.getEntryId());
|
||||
entryRespDto.setWechatStatus(respDto.getStatus());
|
||||
entryRespDto.setWechatErrorMsg(respDto.getErrorMsg());
|
||||
} else if (PayCst.Platform.ALIPAY.equals(respDto.getPlatform())) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(respDto.getPlatform())) {
|
||||
entryRespDto.setAlipayOrderId(respDto.getEntryId());
|
||||
entryRespDto.setAlipayStatus(respDto.getStatus());
|
||||
entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg());
|
||||
@@ -384,9 +384,9 @@ public class EntryManager {
|
||||
// verifyEntryParam(merchantDto);
|
||||
// uploadParamImage(merchantDto);
|
||||
//// System.out.println(merchantDto);
|
||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY);
|
||||
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY);
|
||||
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.WECHAT);
|
||||
// entryMerchant(merchantDto, PayCst.Type.ALIPAY);
|
||||
// entryMerchant(merchantDto, PayCst.Type.WECHAT, PayCst.Type.ALIPAY);
|
||||
System.out.println(respDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,15 +21,16 @@ public interface PayCst {
|
||||
String ALIPAY_ERROR_MSG_KEY = "message";
|
||||
|
||||
/**
|
||||
* 平台
|
||||
* 支付类型
|
||||
*/
|
||||
class Platform {
|
||||
class Type {
|
||||
/**
|
||||
* 微信
|
||||
* 微信支付
|
||||
*/
|
||||
public static final String WECHAT = "WECHAT";
|
||||
|
||||
/**
|
||||
* 支付宝
|
||||
* 支付宝支付
|
||||
*/
|
||||
public static final String ALIPAY = "ALIPAY";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.czg;
|
||||
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.pay.*;
|
||||
import com.czg.third.alipay.AlipayIsvPayManager;
|
||||
@@ -21,9 +20,9 @@ public class PayManager {
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||
if (PayCst.Type.WECHAT.equals(paramsDto.getPayType())) {
|
||||
return WechatPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
@@ -37,9 +36,9 @@ public class PayManager {
|
||||
* @return 结果
|
||||
*/
|
||||
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(paramsDto.getPayType())) {
|
||||
if (PayCst.Type.WECHAT.equals(paramsDto.getPayType())) {
|
||||
return WechatPayManager.barPay(null, paramsDto, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPayType())) {
|
||||
return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
@@ -50,9 +49,9 @@ public class PayManager {
|
||||
* 查询订单状态
|
||||
*/
|
||||
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) {
|
||||
if (SystemConstants.PayType.WECHAT.equals(platform)) {
|
||||
if (PayCst.Type.WECHAT.equals(platform)) {
|
||||
return WechatPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||
} else if (SystemConstants.PayType.ALIPAY.equals(platform)) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(platform)) {
|
||||
return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
@@ -63,9 +62,9 @@ public class PayManager {
|
||||
* 退款
|
||||
*/
|
||||
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) {
|
||||
if (PayCst.Platform.WECHAT.equals(paramsDto.getPlatform())) {
|
||||
if (PayCst.Type.WECHAT.equals(paramsDto.getPlatform())) {
|
||||
return WechatPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||
} else if (PayCst.Platform.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(paramsDto.getPlatform())) {
|
||||
return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
|
||||
} else {
|
||||
throw new CzgException("不支持的支付平台");
|
||||
|
||||
@@ -106,9 +106,9 @@ public class PayParamsDto {
|
||||
AssertUtil.isBlank(appId, "appId不能为空");
|
||||
AssertUtil.isBlank(openId, "用户唯一标识不能为空");
|
||||
|
||||
if (PayCst.Platform.WECHAT.equals(platform)) {
|
||||
if (PayCst.Type.WECHAT.equals(platform)) {
|
||||
AssertUtil.isBlank(merchantId, "商户ID不能为空");
|
||||
} else if (PayCst.Platform.ALIPAY.equals(platform)) {
|
||||
} else if (PayCst.Type.ALIPAY.equals(platform)) {
|
||||
AssertUtil.isBlank(payParams, "支付参数不能为空");
|
||||
alipayAuthInfo = JSONObject.parseObject(payParams, AlipayAuthInfoDto.class);
|
||||
AssertUtil.isNull(alipayAuthInfo, "支付参数错误");
|
||||
|
||||
@@ -129,7 +129,7 @@ public class WechatPayNotifyDataDto {
|
||||
.setMchOrderNo(outTradeNo)
|
||||
.setThirdOrderNo(transactionId)
|
||||
.setAmount(getPayAmount())
|
||||
.setPlatform(PayCst.Platform.WECHAT)
|
||||
.setPlatform(PayCst.Type.WECHAT)
|
||||
.setExtData(attach)
|
||||
.setPaySuccessTime(time)
|
||||
.setErrorMsg(tradeStateDesc);
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.czg.dto.resp.EntryThirdRespDto;
|
||||
import com.czg.dto.resp.QueryStatusResp;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.third.alipay.dto.config.AlipayConfigDto;
|
||||
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
||||
import com.czg.utils.UploadFileUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class AlipayEntryManager {
|
||||
*/
|
||||
public static QueryStatusResp queryMerchantEntryStatus(AlipayConfigDto configDto, String merchantCode) {
|
||||
QueryStatusResp queryStatusResp = new QueryStatusResp();
|
||||
queryStatusResp.setPlatform(PayCst.Platform.ALIPAY);
|
||||
queryStatusResp.setPlatform(PayCst.Type.ALIPAY);
|
||||
queryStatusResp.setMerchantCode(merchantCode);
|
||||
|
||||
AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
|
||||
@@ -158,7 +157,7 @@ public class AlipayEntryManager {
|
||||
public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto);
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
.setPlatform(PayCst.Type.ALIPAY);
|
||||
|
||||
try {
|
||||
AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AlipayIsvEntryManager {
|
||||
configDto = AlipayConfigDto.getThirdDefaultConfig();
|
||||
}
|
||||
QueryStatusResp respDto = new QueryStatusResp()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
.setPlatform(PayCst.Type.ALIPAY);
|
||||
AlipayClient.setApiClient(configDto);
|
||||
|
||||
try {
|
||||
@@ -104,7 +104,7 @@ public class AlipayIsvEntryManager {
|
||||
}
|
||||
AlipayClient.setApiClient(configDto);
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.ALIPAY);
|
||||
.setPlatform(PayCst.Type.ALIPAY);
|
||||
try {
|
||||
String batchNo = createRequest(configDto, reqDto);
|
||||
respDto.setEntryId(batchNo);
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AlipayIsvPayManager {
|
||||
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
|
||||
model.setSubject(paramsDto.getSubject());
|
||||
model.setBody(paramsDto.getBody());
|
||||
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY);
|
||||
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Type.ALIPAY);
|
||||
|
||||
model.setExtendParams(new ExtendParams());
|
||||
CustomizedParams customizedParams = new CustomizedParams();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.czg.third.wechat;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.alibaba.fastjson2.JSONWriter;
|
||||
import com.czg.PayCst;
|
||||
@@ -15,7 +14,10 @@ import com.czg.third.wechat.dto.req.entry.*;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryBusinessReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.WechatEntryLicenseReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.*;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryMiniProgramReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntrySalesInfoReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryStoreInfoReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.business.sales.WechatEntryWebInfoReqDto;
|
||||
import com.czg.third.wechat.dto.req.entry.id.WechatEntryIdCardReqDto;
|
||||
import com.czg.third.wechat.dto.resp.WechatAuditDetail;
|
||||
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
|
||||
@@ -50,7 +52,7 @@ public class WechatEntryManager {
|
||||
*/
|
||||
public static QueryStatusResp queryMerchantEntryStatus(WechatPayConfigDto configDto, String applyId) {
|
||||
QueryStatusResp queryStatusResp = new QueryStatusResp();
|
||||
queryStatusResp.setPlatform(PayCst.Platform.WECHAT);
|
||||
queryStatusResp.setPlatform(PayCst.Type.WECHAT);
|
||||
queryStatusResp.setMerchantCode(applyId);
|
||||
|
||||
String resp = WechatReqUtils.getReq(configDto, "/v3/applyment4sub/applyment/applyment_id/" + applyId, Map.of());
|
||||
@@ -109,7 +111,7 @@ public class WechatEntryManager {
|
||||
*/
|
||||
public static EntryThirdRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) {
|
||||
EntryThirdRespDto respDto = new EntryThirdRespDto()
|
||||
.setPlatform(PayCst.Platform.WECHAT);
|
||||
.setPlatform(PayCst.Type.WECHAT);
|
||||
try {
|
||||
WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto);
|
||||
log.info("微信进件参数:{}", JSONObject.toJSONString(entryReqDto));
|
||||
|
||||
@@ -56,7 +56,7 @@ public class WechatPayManager {
|
||||
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
|
||||
reqData.put("description", paramsDto.getSubject());
|
||||
reqData.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Platform.WECHAT);
|
||||
reqData.put("notify_url", paramsDto.getNotifyUrl() + "/" + PayCst.Type.WECHAT);
|
||||
reqData.put("attach", paramsDto.getExtParam());
|
||||
|
||||
JSONObject amount = new JSONObject();
|
||||
@@ -267,7 +267,7 @@ public class WechatPayManager {
|
||||
refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
|
||||
refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
|
||||
refundParam.put("reason", paramsDto.getRefundReason());
|
||||
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Platform.WECHAT);
|
||||
refundParam.put("notify_url", notifyUrl + "/" + PayCst.Type.WECHAT);
|
||||
|
||||
JSONObject amount = new JSONObject();
|
||||
amount.put("total", paramsDto.getOrderTotalAmount());
|
||||
@@ -291,7 +291,7 @@ public class WechatPayManager {
|
||||
.setThirdRefundNo(object.getString("refund_id"))
|
||||
.setRefundTime(object.getString("success_time"))
|
||||
.setOriginalData(resp)
|
||||
.setPlatform(PayCst.Platform.WECHAT);
|
||||
.setPlatform(PayCst.Type.WECHAT);
|
||||
|
||||
JSONObject resAmount = object.getJSONObject("amount");
|
||||
if (resAmount != null) {
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.czg.service.account.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -26,9 +22,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AcAccountUtil {
|
||||
@Resource
|
||||
@Lazy
|
||||
private RedisService redisService;
|
||||
|
||||
@DubboReference
|
||||
private SysParamsService paramsService;
|
||||
|
||||
@@ -54,7 +48,7 @@ public class AcAccountUtil {
|
||||
String accessToken = getAccessToken();
|
||||
// String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR";
|
||||
if (StrUtil.isBlank(accessToken)) {
|
||||
log.error("获取 access_token 失败");
|
||||
log.error("银收客czg 公众号获取 access_token 失败");
|
||||
return "";
|
||||
}
|
||||
String bodyJson = "{\"action_info\":{\"scene\":{\"scene_str\":\"" + userId + "\"}},\"action_name\":\"QR_STR_SCENE\",\"expire_seconds\":\"2592000\"}";
|
||||
@@ -87,23 +81,24 @@ public class AcAccountUtil {
|
||||
|
||||
|
||||
public String getAccessToken() {
|
||||
String accessToken = Convert.toStr(redisService.get("wx:ac:AccessToken"));
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
Map<String, String> userAc = paramsService.getParamsByMap("user_ac_key_set", ParamCodeCst.USER_AC_KEY_SET);
|
||||
// 用户小程序参数
|
||||
String acAppId = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_APP_ID);
|
||||
String acSecrete = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_SECRETE);
|
||||
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", acAppId, acSecrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
log.warn("公众号获取token失败, 响应内容: {}", resp);
|
||||
return "";
|
||||
|
||||
String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", acAppId, acSecrete));
|
||||
// 响应 {"accessToken":"100_6C_jltHANT1y2Fot5PXKFDzPXTyWumCsao0oMoNRvJUTuxS0IOVO4nBmjdmx5dZfYItShFVSAKYzNDf7ZGLPlx52ii1Y1qerrbbSmIiLWCrec5qjBY4gV5Tfv8YKKTdABAEEN","appId":"wx212769170d2c6b2a"}
|
||||
if (StrUtil.isNotBlank(resp)) {
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
return respInfo.getString("accessToken");
|
||||
} else {
|
||||
String resp2 = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", acAppId, acSecrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp2);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
log.warn("银收客czg 公众号获取token失败, 响应内容: {}", resp2);
|
||||
return "";
|
||||
}
|
||||
return respInfo.getString("access_token");
|
||||
}
|
||||
accessToken = respInfo.getString("access_token");
|
||||
int expiresIn = respInfo.getInteger("expires_in");
|
||||
redisService.set("wx:ac:AccessToken", accessToken, expiresIn - 10);
|
||||
return accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.czg.service.account.util;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.symmetric.AES;
|
||||
@@ -11,6 +10,7 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.config.RedisCst;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.system.dto.SysParamsDTO;
|
||||
@@ -140,7 +140,7 @@ public class WechatMiniMsgUtil {
|
||||
|
||||
public String getAccountOpenId(String code) {
|
||||
Map<String, String> shopAc = sysParamsService.getParamsByMap("shop_ac_key_set", ParamCodeCst.SHOP_AC_KEY_SET);
|
||||
String accountAppId = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountAppId = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_APP_ID);
|
||||
String accountSecrete = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
|
||||
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
|
||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||
@@ -162,25 +162,23 @@ public class WechatMiniMsgUtil {
|
||||
|
||||
//获取小程序token
|
||||
private String getAccessToken() {
|
||||
String accessToken = Convert.toStr(redisService.get("wx:mini:AccessToken"));
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
// 商户小程序参数
|
||||
Map<String, String> shopMiniKeyMap = sysParamsService.getParamsByMap("shop_mini_key_set", ParamCodeCst.SHOP_MINI_KEY_SET);
|
||||
String appId = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
|
||||
String secrete = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
|
||||
|
||||
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete);
|
||||
String response = HttpUtil.get(url);
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||
if (!jsonResponse.containsKey("access_token")) {
|
||||
throw new RuntimeException("Failed to retrieve access token: " + response);
|
||||
String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", appId, secrete));
|
||||
if (StrUtil.isNotBlank(resp)) {
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
return respInfo.getString("accessToken");
|
||||
} else {
|
||||
String response = HttpUtil.get(String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, appId, secrete));
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||
if (!jsonResponse.containsKey("access_token")) {
|
||||
throw new CzgException("零点八零商户端 获取access_token失败: " + response);
|
||||
}
|
||||
return jsonResponse.getString("access_token");
|
||||
}
|
||||
accessToken = jsonResponse.getString("access_token");
|
||||
int expiresIn = jsonResponse.getInteger("expires_in");
|
||||
redisService.set("wx:mini:AccessToken", accessToken, expiresIn - 10);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
and a.table_code is not null
|
||||
</if>
|
||||
group by a.id
|
||||
ORDER BY a.create_time
|
||||
ORDER BY a.area_id,a.id
|
||||
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
and amount - #{money} >= 0
|
||||
</update>
|
||||
<update id="updateOneOrTwoAmount">
|
||||
update tb_shop_user_invite
|
||||
update tb_shop_user
|
||||
<set>
|
||||
<if test="isOne != null and isOne == 1">
|
||||
one_income = one_income + #{amount}
|
||||
@@ -27,8 +27,7 @@
|
||||
two_income = two_income + #{amount}
|
||||
</if>
|
||||
</set>
|
||||
where shop_user_id = #{shopUserId}
|
||||
and shop_id = #{shopId}
|
||||
where id = #{shopUserId}
|
||||
</update>
|
||||
|
||||
|
||||
@@ -257,10 +256,10 @@
|
||||
</select>
|
||||
<select id="getInviteUser" resultType="com.czg.market.vo.InviteUserVO">
|
||||
SELECT
|
||||
u.id AS shopUserId,
|
||||
u.head_img AS headImg,
|
||||
u.nick_name AS shopUserName,
|
||||
u.phone AS shopUserPhone,
|
||||
invite.id AS shopUserId,
|
||||
invite.head_img AS headImg,
|
||||
invite.nick_name AS shopUserName,
|
||||
invite.phone AS shopUserPhone,
|
||||
invite.one_income AS oneIncome,
|
||||
invite.invite_time AS inviteTime,
|
||||
dist.total_income AS totalIncome,
|
||||
@@ -270,13 +269,12 @@
|
||||
dist.status AS status,
|
||||
dist.distribution_level_id AS levelId,
|
||||
dist.distribution_level_name AS levelName,
|
||||
u.distribution_shops AS distributionShops
|
||||
FROM tb_shop_user_invite invite
|
||||
left join tb_shop_user u on invite.shop_user_id = u.id
|
||||
left join mk_distribution_user dist on u.id = dist.id and dist.shop_id = #{shopId}
|
||||
WHERE invite.`distribution_user_id` = #{distributionUserId} and invite.shop_id = #{shopId}
|
||||
invite.distribution_shops AS distributionShops
|
||||
FROM tb_shop_user invite
|
||||
left join mk_distribution_user dist on invite.id = dist.id and dist.shop_id = #{shopId}
|
||||
WHERE invite.`parent_user_id` = #{distributionUserId}
|
||||
<if test="distributionLevelId != null">and dist.distribution_level_id = #{distributionLevelId}</if>
|
||||
<if test="shopUserId != null">and invite.shop_user_id = #{shopUserId}</if>
|
||||
<if test="shopUserId != null">and invite.id = #{shopUserId}</if>
|
||||
ORDER BY invite.`invite_time` DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.czg.service.market.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.market.entity.ShopUserInvite;
|
||||
|
||||
/**
|
||||
* 邀请与上级关联表 映射层。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-11-06
|
||||
*/
|
||||
public interface ShopUserInviteMapper extends BaseMapper<ShopUserInvite> {
|
||||
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -17,6 +16,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信支付service
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
@@ -27,35 +27,26 @@ public class AppWxServiceImpl extends BaseWx {
|
||||
@DubboReference
|
||||
private SysParamsService paramsService;
|
||||
|
||||
public AppWxServiceImpl(@Autowired RedisService autoRedisService) {
|
||||
this.redisService = autoRedisService;
|
||||
public AppWxServiceImpl() {
|
||||
config = new Config();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessToken(boolean refresh) {
|
||||
init();
|
||||
Object token = redisService.get("wx:user:access_token");
|
||||
if (!refresh && token instanceof String) {
|
||||
return (String) token;
|
||||
}
|
||||
|
||||
String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
|
||||
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
|
||||
);
|
||||
|
||||
log.info("获取access_token响应: {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
String accessToken = jsonObject.getString("access_token");
|
||||
if (accessToken == null) {
|
||||
throw new RuntimeException("获取access_token失败");
|
||||
String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", config.appId, config.appSecret));
|
||||
// 响应 {"accessToken":"100_6C_jltHANT1y2Fot5PXKFDzPXTyWumCsao0oMoNRvJUTuxS0IOVO4nBmjdmx5dZfYItShFVSAKYzNDf7ZGLPlx52ii1Y1qerrbbSmIiLWCrec5qjBY4gV5Tfv8YKKTdABAEEN","appId":"wx212769170d2c6b2a"}
|
||||
if (StrUtil.isNotBlank(resp)) {
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
return respInfo.getString("accessToken");
|
||||
} else {
|
||||
String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
|
||||
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
|
||||
);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
return jsonObject.getString("access_token");
|
||||
}
|
||||
Long expiresIn = jsonObject.getLong("expires_in");
|
||||
if (expiresIn == null) {
|
||||
expiresIn = DEFAULT_EXPIRES_IN;
|
||||
}
|
||||
redisService.set("wx:user:access_token", accessToken, expiresIn - EXPIRES_OFFSET);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,7 +56,7 @@ public class AppWxServiceImpl extends BaseWx {
|
||||
|
||||
// 微信支付参数
|
||||
Map<String, String> payKeyMap = paramsService.getParamsByMap("pay_key_set", ParamCodeCst.PAY_KEY_SET);
|
||||
|
||||
|
||||
// 小程序id
|
||||
config.appId = userMiniKeyMap.get(ParamCodeCst.Wechat.Mini.USER_WX_APP_ID);
|
||||
// 小程序secrete
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.service.RedisService;
|
||||
import com.ijpay.core.IJPayHttpResponse;
|
||||
@@ -35,7 +34,6 @@ import java.security.cert.X509Certificate;
|
||||
import java.util.Base64;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 微信支付相关
|
||||
@@ -139,12 +137,13 @@ public abstract class BaseWx {
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
String prepayId = jsonObject.getString("prepay_id");
|
||||
if (StrUtil.isBlank(prepayId)) {
|
||||
throw new RuntimeException(jsonObject.getString("message"));
|
||||
throw new CzgException(jsonObject.getString("message"));
|
||||
}
|
||||
return WxPayKit.jsApiCreateSign(config.appId, prepayId, config.privateKey);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
log.error("微信V3原生支付失败", e);
|
||||
throw new CzgException("暂无法支付,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,12 +73,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
private MkDistributionWithdrawFlowService withdrawFlowService;
|
||||
@Resource
|
||||
private MkDistributionDeliverService distributionDeliverService;
|
||||
@Resource
|
||||
private ShopUserInviteService shopUserInviteService;
|
||||
|
||||
@Resource
|
||||
private AppWxServiceImpl appWxService;
|
||||
|
||||
@DubboReference
|
||||
private ShopUserService shopUserService;
|
||||
@DubboReference
|
||||
@@ -150,9 +146,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
||||
UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
|
||||
result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount());
|
||||
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
|
||||
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
||||
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUserInvite.getDistributionUserId(), shopId);
|
||||
|
||||
if (shopUser.getParentUserId() != null) {
|
||||
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getParentUserId(), shopId);
|
||||
AssertUtil.isNull(mkDistributionUser, "上级分销员不存在");
|
||||
ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId());
|
||||
result.put("parentName", shopUserParent.getNickName());
|
||||
@@ -181,7 +177,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
if (levelConfig.getId().equals(mkDistributionUser.getDistributionLevelId())) {
|
||||
distributionUser.put("level", levelConfig.getLevel());
|
||||
distributionUser.put("levelName", levelConfig.getName());
|
||||
distributionUser.put("levelOneCommission", levelConfig.getLevelOneCommission());
|
||||
distributionUser.put("levelOneCommission", levelConfig.getCommission());
|
||||
isNextLevel = true;
|
||||
}
|
||||
}
|
||||
@@ -198,18 +194,18 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String getInviteCode(Long shopId, Long shopUserId) {
|
||||
public String getInviteCode(Long shopId, Long shopUserId) throws CzgException, ValidateException {
|
||||
ShopUser shopUser = shopUserService.getById(shopUserId);
|
||||
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
||||
MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId);
|
||||
if (mkDistributionConfigVO == null || mkDistributionConfigVO.getIsEnable() == 0) {
|
||||
throw new CzgException("店铺分销功能未开启");
|
||||
}
|
||||
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
|
||||
throw new CzgException("该店铺不可自行成为分销员");
|
||||
}
|
||||
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId);
|
||||
if (mkDistributionUser == null) {
|
||||
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
|
||||
throw new CzgException("该店铺不可自行成为分销员");
|
||||
}
|
||||
mkDistributionUser = new MkDistributionUser();
|
||||
mkDistributionUser.setId(shopUser.getId());
|
||||
mkDistributionUser.setShopId(shopId);
|
||||
@@ -234,8 +230,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
public void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException {
|
||||
ShopUser shopUser = shopUserService.getById(param.getId());
|
||||
AssertUtil.isNull(shopUser, "店铺用户不存在");
|
||||
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(param.getShopId(), shopUser.getId());
|
||||
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
||||
if (shopUser.getParentUserId() != null) {
|
||||
throw new CzgException("店铺用户已绑定分销员");
|
||||
}
|
||||
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode()));
|
||||
@@ -251,26 +246,28 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
}
|
||||
ShopUser parentShopUser = shopUserService.getById(parent.getId());
|
||||
AssertUtil.isNull(parentShopUser, "邀请人不存在");
|
||||
ShopUserInvite parentShopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(param.getShopId(), parentShopUser.getId());
|
||||
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserId() != null && parentShopUserInvite.getDistributionUserId().equals(shopUser.getId())) {
|
||||
|
||||
if (parentShopUser.getParentUserId() != null && parentShopUser.getParentUserId().equals(shopUser.getId())) {
|
||||
throw new CzgException("存在绑定关系,不可绑定");
|
||||
}
|
||||
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserParentId() != null && parentShopUserInvite.getDistributionUserParentId().equals(shopUser.getId())) {
|
||||
if (parentShopUser.getGradeUserId() != null && parentShopUser.getGradeUserId().equals(shopUser.getId())) {
|
||||
throw new CzgException("存在绑定关系,不可绑定");
|
||||
}
|
||||
//更新自己的上级
|
||||
ShopUserInvite newShopUserInvite = new ShopUserInvite();
|
||||
newShopUserInvite.setShopId(param.getShopId());
|
||||
newShopUserInvite.setShopUserId(shopUser.getId());
|
||||
newShopUserInvite.setDistributionUserId(parentShopUser.getId());
|
||||
newShopUserInvite.setDistributionUserParentId(parentShopUserInvite == null ? null : parentShopUserInvite.getDistributionUserParentId());
|
||||
newShopUserInvite.setInviteTime(LocalDateTime.now());
|
||||
shopUserInviteService.save(newShopUserInvite);
|
||||
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserParentId() != null) {
|
||||
shopUser.setParentUserId(parentShopUser.getId());
|
||||
shopUser.setGradeUserId(parentShopUser.getParentUserId());
|
||||
|
||||
//更新自己的下级 的上级的上级 为自己的上级
|
||||
ShopUser upShopUser1 = new ShopUser();
|
||||
upShopUser1.setParentUserId(parentShopUser.getId());
|
||||
upShopUser1.setGradeUserId(parentShopUser.getParentUserId());
|
||||
shopUserService.update(upShopUser1, QueryWrapper.create().eq(ShopUser::getId, shopUser.getId()));
|
||||
|
||||
if (shopUser.getParentUserId() != null) {
|
||||
//更新自己的下级 的上级的上级 为自己的上级
|
||||
ShopUserInvite childShopUserInvite = new ShopUserInvite();
|
||||
childShopUserInvite.setDistributionUserParentId(parentShopUser.getId());
|
||||
shopUserInviteService.update(childShopUserInvite, QueryWrapper.create().eq(ShopUserInvite::getDistributionUserId, shopUser.getId()));
|
||||
ShopUser upShopUser = new ShopUser();
|
||||
upShopUser.setGradeUserId(shopUser.getParentUserId());
|
||||
shopUserService.update(upShopUser, QueryWrapper.create().eq(ShopUser::getParentUserId, shopUser.getId()));
|
||||
}
|
||||
|
||||
MkDistributionUser newDistributionUser = new MkDistributionUser();
|
||||
@@ -318,9 +315,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
public void costUpgradeLevelBefore(Long userId, Long shopId) {
|
||||
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
|
||||
costUpgradeLevel(shopUser.getId(), shopId);
|
||||
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
|
||||
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
|
||||
costUpgradeLevel(shopUserInvite.getDistributionUserId(), shopId);
|
||||
if (shopUser.getParentUserId() != null) {
|
||||
costUpgradeLevel(shopUser.getParentUserId(), shopId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,70 +565,40 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
|
||||
|
||||
@GlobalTransactional
|
||||
protected void deepReward(ShopUser orderSourceShopUser, MkDistributionLevelConfig parentLevel, MkDistributionConfigVO config,
|
||||
MkDistributionUser currentDistributionUser, BigDecimal amount, Long sourceId, String type, String orderNo, Integer currentLevel) {
|
||||
if (currentLevel > 2) {
|
||||
return;
|
||||
}
|
||||
protected boolean deepReward(ShopUser orderSourceShopUser, BigDecimal commission, MkDistributionConfigVO config,
|
||||
MkDistributionUser currentDistributionUser, BigDecimal amount, Long sourceId,
|
||||
String type, String orderNo, Integer currentLevel) {
|
||||
// 当前分销员
|
||||
AssertUtil.isNull(currentDistributionUser, "分销员不存在");
|
||||
AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启");
|
||||
|
||||
// ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId());
|
||||
ShopUserInvite currentShopUser = shopUserInviteService.getOneByShopIdAndShopUserId(config.getShopId(), currentDistributionUser.getId());
|
||||
MkDistributionLevelConfig level = levelConfigService.getById(currentDistributionUser.getDistributionLevelId());
|
||||
|
||||
// 校验剩余分成比例
|
||||
BigDecimal finalCommission = parentLevel == null ? level.getLevelOneCommission() : level.getLevelOneCommission().subtract(parentLevel.getLevelOneCommission());
|
||||
if (finalCommission.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
log.info("当前分销员: {}, 分销等级: {}, 剩余比例: {}, 不参与分销", currentDistributionUser.getId(), level.getId(), finalCommission);
|
||||
return;
|
||||
if (commission.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 上上级分销员
|
||||
if (currentShopUser != null && currentShopUser.getDistributionUserId() != null) {
|
||||
MkDistributionUser parent = getMkDistributionUserByIdAndShopId(currentShopUser.getDistributionUserId(), config.getShopId());
|
||||
try {
|
||||
deepReward(orderSourceShopUser, level, config, parent, amount, sourceId, type, orderNo, currentLevel + 1);
|
||||
} catch (Exception e) {
|
||||
log.warn("分销奖励失败: {}", e.getMessage());
|
||||
}
|
||||
// 金额
|
||||
BigDecimal rewardAmount = amount.multiply(commission.divide(BigDecimal.valueOf(100))).setScale(2, RoundingMode.FLOOR);
|
||||
if (rewardAmount.compareTo(new BigDecimal("0.01")) < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AssertUtil.isNull(level, "分销等级不存在");
|
||||
log.info("当前分销员: {}, 上级分销员: {}, 分销等级: {}", currentDistributionUser.getId(), currentShopUser == null ? null : currentShopUser.getDistributionUserId(), level.getId());
|
||||
|
||||
if (config.getRewardCount() != null && config.getRewardCount() > 0) {
|
||||
long count = distributionFlowService.count(new QueryWrapper()
|
||||
.eq(MkDistributionFlow::getShopId, config.getShopId()).eq(MkDistributionFlow::getShopUserId, currentDistributionUser.getId()));
|
||||
if (count >= config.getRewardCount()) {
|
||||
log.info("分销员{}已达到奖励次数上限, 次数: {}", currentDistributionUser.getId(), config.getRewardCount());
|
||||
return;
|
||||
} else {
|
||||
log.info("分销员奖励次数: {}", count);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 店铺信息
|
||||
BigDecimal rewardAmount;
|
||||
// if (currentLevel == 1) {
|
||||
// rewardAmount = amount.multiply(level.getLevelOneCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
// } else {
|
||||
// rewardAmount = amount.multiply(level.getLevelTwoCommission().divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
// }
|
||||
rewardAmount = amount.multiply(finalCommission.divide(BigDecimal.valueOf(100), RoundingMode.DOWN));
|
||||
|
||||
// 延时发放时间
|
||||
LocalDateTime delayTime = config.getSettlementDay() == null || config.getSettlementDay() == 0 ? null : DateUtil.offsetDay(DateUtil.date(), config.getSettlementDay()).toLocalDateTime();
|
||||
|
||||
// 用户分账明细
|
||||
ShopUser shopUser = shopUserService.getById(currentDistributionUser.getId());
|
||||
MkDistributionFlow mkDistributionFlow = new MkDistributionFlow().setShopUserId(currentDistributionUser.getId())
|
||||
.setShopId(currentDistributionUser.getShopId()).setDistributionUserId(currentDistributionUser.getId())
|
||||
.setUserId(shopUser.getUserId())
|
||||
.setNickName(shopUser.getNickName()).setSourceShopUserId(orderSourceShopUser.getId()).setSourceNickName(orderSourceShopUser.getNickName())
|
||||
.setCommission(finalCommission).setParentCommission(parentLevel != null ? parentLevel.getLevelOneCommission() : null)
|
||||
.setLevelId(currentDistributionUser.getDistributionLevelId()).setLevel(currentLevel == 1 ? 1 : 2).setOrderNo(orderNo)
|
||||
.setCommission(commission)
|
||||
.setLevelId(currentDistributionUser.getDistributionLevelId()).setLevel(currentLevel).setOrderNo(orderNo)
|
||||
.setSourceId(sourceId).setAmount(amount).setType(type)
|
||||
.setRewardAmount(rewardAmount).setBillNo(IdUtil.simpleUUID());
|
||||
|
||||
@@ -655,6 +621,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
log.info("延时分销开始");
|
||||
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -712,19 +679,24 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
AssertUtil.isTrue(amount.compareTo(BigDecimal.ZERO) == 0, "分销金额不能为0");
|
||||
MkDistributionConfigVO config = mkDistributionConfigService.detail(shopId);
|
||||
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
|
||||
// 当前用户上级分销员
|
||||
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId);
|
||||
if (sourceShopUserInfo == null) {
|
||||
// 产生消费的用户
|
||||
ShopUser curUser = shopUserService.getShopUserInfo(shopId, sourceUserId);
|
||||
if (curUser == null || curUser.getParentUserId() == null) {
|
||||
return;
|
||||
}
|
||||
ShopUserInvite sourceInviteUser = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, sourceShopUserInfo.getId());
|
||||
if (sourceInviteUser.getDistributionUserId() == null) {
|
||||
return;
|
||||
}
|
||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, sourceInviteUser.getDistributionUserId());
|
||||
|
||||
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(sourceInviteUser.getDistributionUserId(), shopId);
|
||||
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
|
||||
log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, curUser.getParentUserId());
|
||||
|
||||
MkDistributionUser distributionUser = getMkDistributionUserByIdAndShopId(curUser.getParentUserId(), shopId);
|
||||
MkDistributionLevelConfig level = levelConfigService.getById(distributionUser.getDistributionLevelId());
|
||||
deepReward(curUser, level.getCommission(), config, distributionUser,
|
||||
amount, sourceId, type, orderNo, 1);
|
||||
if (curUser.getGradeUserId() != null) {
|
||||
MkDistributionUser parentDis = getMkDistributionUserByIdAndShopId(curUser.getGradeUserId(), shopId);
|
||||
MkDistributionLevelConfig parentDisLevel = levelConfigService.getById(parentDis.getDistributionLevelId());
|
||||
deepReward(curUser, parentDisLevel.getCommission().subtract(level.getCommission()), config, parentDis,
|
||||
amount, sourceId, type, orderNo, 2);
|
||||
}
|
||||
});
|
||||
distributionDeliverService.save(deliver);
|
||||
}
|
||||
@@ -732,7 +704,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
|
||||
/**
|
||||
* 分销金额修改
|
||||
*
|
||||
* @param pendingIncome 待入账金额
|
||||
* @param pendingIncome 待入账金额
|
||||
* @param receivedIncome 已入账
|
||||
* @param withdrawIncome 已提现
|
||||
*/
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.ShopUserInvite;
|
||||
import com.czg.market.service.ShopUserInviteService;
|
||||
import com.czg.service.market.mapper.ShopUserInviteMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 邀请与上级关联表 服务层实现。
|
||||
*
|
||||
* @author ww
|
||||
* @since 2025-11-06
|
||||
*/
|
||||
@Service
|
||||
public class ShopUserInviteServiceImpl extends ServiceImpl<ShopUserInviteMapper, ShopUserInvite> implements ShopUserInviteService {
|
||||
|
||||
@Override
|
||||
public ShopUserInvite getOneByShopIdAndShopUserId(Long shopId, Long shopUserId) {
|
||||
return getOne(QueryWrapper.create()
|
||||
.eq(ShopUserInvite::getShopId, shopId)
|
||||
.eq(ShopUserInvite::getShopUserId, shopUserId));
|
||||
}
|
||||
}
|
||||
@@ -296,6 +296,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
|
||||
}
|
||||
if (shopUser.getMemberLevelId() == null) {
|
||||
log.warn("会员等级不存在, 店铺id: {}, 用户id: {}", shopUser.getMainShopId(), shopUser.getUserId());
|
||||
return false;
|
||||
}
|
||||
MemberConfigVO memberConfig = detail(shopUser.getMainShopId());
|
||||
if (memberConfig == null) {
|
||||
|
||||
@@ -4,17 +4,15 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.market.dto.MemberLevelDTO;
|
||||
import com.czg.market.entity.MemberLevelConfig;
|
||||
import com.czg.market.service.MemberLevelConfigService;
|
||||
import com.czg.market.service.ShopCouponService;
|
||||
import com.czg.market.vo.MemberLevelVO;
|
||||
import com.czg.service.market.mapper.TbMemberLevelConfigMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.market.entity.MemberLevelConfig;
|
||||
import com.czg.market.service.MemberLevelConfigService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -33,20 +31,16 @@ public class TbMemberLevelConfigServiceImpl extends ServiceImpl<TbMemberLevelCon
|
||||
@Override
|
||||
public ArrayList<MemberLevelVO> listInfo(Long shopId) {
|
||||
List<MemberLevelConfig> levelConfigs = list(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId));
|
||||
ArrayList<MemberLevelVO> memberLevelVOS = new ArrayList<>();
|
||||
levelConfigs.forEach(memberLevelConfig -> {
|
||||
memberLevelVOS.add(transVO(memberLevelConfig));
|
||||
});
|
||||
return memberLevelVOS;
|
||||
ArrayList<MemberLevelVO> memberLevels = new ArrayList<>();
|
||||
levelConfigs.forEach(memberLevelConfig -> memberLevels.add(transVO(memberLevelConfig)));
|
||||
return memberLevels;
|
||||
}
|
||||
|
||||
private MemberLevelVO transVO(MemberLevelConfig memberLevelConfig) {
|
||||
MemberLevelVO levelVO = BeanUtil.copyProperties(memberLevelConfig, MemberLevelVO.class, "cycleRewardCouponList");
|
||||
if (StrUtil.isNotBlank(memberLevelConfig.getCycleRewardCouponList())) {
|
||||
List<MemberLevelDTO.ConfigCoupon> coupons = JSONArray.parseArray(memberLevelConfig.getCycleRewardCouponList()).toList(MemberLevelDTO.ConfigCoupon.class);
|
||||
coupons.forEach(item -> {
|
||||
item.setCoupon(shopCouponService.getById(item.getCoupon().getId()));
|
||||
});
|
||||
coupons.forEach(item -> item.setCoupon(shopCouponService.getById(item.getCoupon().getId())));
|
||||
levelVO.setCycleRewardCouponList(coupons);
|
||||
}
|
||||
return levelVO;
|
||||
@@ -54,6 +48,7 @@ public class TbMemberLevelConfigServiceImpl extends ServiceImpl<TbMemberLevelCon
|
||||
|
||||
@Override
|
||||
public MemberLevelVO detail(Long memberLevelId) {
|
||||
|
||||
MemberLevelConfig memberLevelConfig = getById(memberLevelId);
|
||||
if (memberLevelConfig == null) {
|
||||
return null;
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.czg.service.market.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.service.RedisService;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.ijpay.core.kit.RsaKit;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
@@ -27,38 +25,25 @@ public class WxServiceImpl extends BaseWx {
|
||||
@DubboReference
|
||||
private SysParamsService paramsService;
|
||||
|
||||
private final Set<String> shopMiniKeys = Set.of(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID, ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE);
|
||||
|
||||
|
||||
public WxServiceImpl(@Autowired RedisService redisService) {
|
||||
this.redisService = redisService;
|
||||
public WxServiceImpl() {
|
||||
config = new Config();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessToken(boolean refresh) {
|
||||
init();
|
||||
Object token = redisService.get("wx:shop:access_token");
|
||||
if (!refresh && token instanceof String) {
|
||||
return (String) token;
|
||||
}
|
||||
|
||||
String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
|
||||
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
|
||||
);
|
||||
|
||||
log.info("获取access_token响应: {}", response);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
String accessToken = jsonObject.getString("access_token");
|
||||
if (accessToken == null) {
|
||||
throw new RuntimeException("获取access_token失败");
|
||||
String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", config.appId, config.appSecret));
|
||||
if (StrUtil.isNotBlank(resp)) {
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
return respInfo.getString("accessToken");
|
||||
} else {
|
||||
String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
|
||||
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
|
||||
);
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
return jsonObject.getString("access_token");
|
||||
}
|
||||
Long expiresIn = jsonObject.getLong("expires_in");
|
||||
if (expiresIn == null) {
|
||||
expiresIn = DEFAULT_EXPIRES_IN;
|
||||
}
|
||||
redisService.set("wx:shop:access_token", accessToken, expiresIn - EXPIRES_OFFSET);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -65,15 +65,13 @@
|
||||
|
||||
<select id="getOrderConsumeAmountByList" resultType="java.math.BigDecimal">
|
||||
SELECT IFNULL(SUM(ord.pay_amount), 0) AS totalAmount
|
||||
FROM tb_shop_user_invite invite
|
||||
INNER JOIN tb_shop_user su on invite.shop_user_id = su.id
|
||||
INNER JOIN tb_order_info ord ON su.user_id = ord.user_id
|
||||
and invite.shop_id = #{shopId}
|
||||
FROM tb_shop_user invite
|
||||
INNER JOIN tb_order_info ord ON invite.user_id = ord.user_id
|
||||
AND ord.shop_id = #{shopId}
|
||||
AND ord.STATUS = 'done'
|
||||
AND ord.pay_type NOT IN ('vip_pay', 'credit_pay')
|
||||
AND ord.paid_time >= invite.invite_time
|
||||
WHERE invite.distribution_user_id = #{inviterId}
|
||||
WHERE invite.parent_user_id = #{inviterId}
|
||||
</select>
|
||||
|
||||
<select id="getOrderConsumeAmountById" resultType="java.math.BigDecimal">
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.market.mapper.ShopUserInviteMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.entity.UserInfo;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.account.service.UserInfoService;
|
||||
import com.czg.constant.TableValueConstant;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.market.service.MkDistributionConfigService;
|
||||
@@ -83,7 +83,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
|
||||
} else {
|
||||
UserInfo userInfo = userInfoService.getById(userId);
|
||||
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo)
|
||||
.setOpenId(SystemConstants.PayType.ALIPAY.equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
||||
.setOpenId(PayCst.Type.ALIPAY.equals(payParam.getPayType()) ? userInfo.getAlipayOpenId() : userInfo.getWechatOpenId());
|
||||
}
|
||||
return initInfo;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
//发送打票信息 后付费推送多次 需要处理
|
||||
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
|
||||
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0"
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_0_0", false);
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_0_0", false, "后付费打印");
|
||||
} else {
|
||||
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId(), "", 60 * 15);
|
||||
}
|
||||
@@ -1066,10 +1066,27 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
// 分销奖励
|
||||
distributionUserService.distribute(orderInfo.getId(), orderInfo.getOrderNo(), payment.getAmount(), orderInfo.getUserId(), orderInfo.getShopId(), "order");
|
||||
}
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType()) || PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
boolean isFree = PayTypeConstants.SourceType.FREE.equals(payment.getSourceType());
|
||||
} else if (PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
if (shopUser == null) {
|
||||
log.error("霸王餐回调失败,会员不存在,会员id:{}", payment.getSourceId());
|
||||
} else {
|
||||
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getId, payment.getRelatedId()));
|
||||
if (orderInfo == null) {
|
||||
log.error("霸王餐支付,订单不存在,支付记录Id,{}", payment.getId());
|
||||
} else {
|
||||
//增加余额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId()).setType(1)
|
||||
.setBizEnum(ShopUserFlowBizEnum.FREE_IN)
|
||||
.setRelationId(orderInfo.getId())
|
||||
.setMoney(BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN));
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
upOrderInfo(orderInfo, BigDecimal.ZERO, LocalDateTime.now(), null, PayEnums.FREE_PAY);
|
||||
}
|
||||
}
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_IN.equals(payment.getSourceType())) {
|
||||
ShopUser shopUser = shopUserService.getById(payment.getSourceId());
|
||||
OrderInfo orderInfo;
|
||||
if (shopUser == null) {
|
||||
log.error("会员充值失败,会员不存在,会员id:{}", payment.getSourceId());
|
||||
} else {
|
||||
@@ -1081,42 +1098,22 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
} else {
|
||||
bizEnum = ShopUserFlowBizEnum.CASH_IN;
|
||||
}
|
||||
if (isFree) {
|
||||
orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getId, payment.getRelatedId()));
|
||||
if (orderInfo == null) {
|
||||
log.error("霸王餐支付,订单不存在,支付记录Id,{}", payment.getId());
|
||||
} else {
|
||||
//增加余额
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setType(1)
|
||||
.setBizEnum(ShopUserFlowBizEnum.FREE_IN)
|
||||
.setRelationId(orderInfo.getId())
|
||||
.setMoney(BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN));
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
upOrderInfo(orderInfo, BigDecimal.ZERO,
|
||||
LocalDateTime.now(), null, PayEnums.FREE_PAY);
|
||||
}
|
||||
} else {
|
||||
//充值并支付 ↓
|
||||
orderInfo = orderInfoService.getOne(new QueryWrapper()
|
||||
.eq(OrderInfo::getPayOrderId, payment.getId())
|
||||
.eq(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue()));
|
||||
if (orderInfo != null) {
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId())
|
||||
.setType(0)
|
||||
.setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
|
||||
.setRelationId(orderInfo.getId())
|
||||
.setMoney(orderInfo.getOrderAmount());
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), null, PayEnums.VIP_PAY);
|
||||
}
|
||||
shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(),
|
||||
BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN),
|
||||
payment.getId(), payment.getSourceType(), bizEnum, orderInfo == null);
|
||||
//充值并支付 ↓
|
||||
OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper()
|
||||
.eq(OrderInfo::getPayOrderId, payment.getId())
|
||||
.eq(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue()));
|
||||
if (orderInfo != null) {
|
||||
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
|
||||
.setId(shopUser.getId()).setType(0)
|
||||
.setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
|
||||
.setRelationId(orderInfo.getId())
|
||||
.setMoney(orderInfo.getOrderAmount());
|
||||
shopUserService.updateMoney(shopUserMoneyEditDTO);
|
||||
upOrderInfo(orderInfo, orderInfo.getOrderAmount(), LocalDateTime.now(), null, PayEnums.VIP_PAY);
|
||||
}
|
||||
shopRechargeService.recharge(payment.getShopId(), payment.getSourceId(), payment.getRelatedId(),
|
||||
BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN),
|
||||
payment.getId(), payment.getSourceType(), bizEnum, orderInfo == null);
|
||||
}
|
||||
} else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
|
||||
//购买会员
|
||||
@@ -1182,6 +1179,10 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
@Override
|
||||
@Transactional
|
||||
public void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType) {
|
||||
if (orderInfo.getStatus().equals(OrderStatusEnums.DONE.getCode())) {
|
||||
log.info("订单{}已完成,不再更新", orderInfo.getId());
|
||||
return;
|
||||
}
|
||||
OrderInfo upOrderInfo = new OrderInfo()
|
||||
.setId(orderInfo.getId())
|
||||
.setPayAmount(payAmount)
|
||||
@@ -1223,16 +1224,20 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
|
||||
if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
|
||||
ThreadUtil.execAsync(() -> exTable(orderInfo));
|
||||
}
|
||||
// 事务成功提交后执行消息发送
|
||||
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint);
|
||||
if (payType != PayEnums.BACK_SCAN) {
|
||||
// 事务成功提交后执行消息发送
|
||||
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint, "事务环境打印");
|
||||
}
|
||||
// log.info("订单{}事务提交后,发送打印消息", orderId);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 非事务环境下直接发送(兼容无事务场景)
|
||||
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint);
|
||||
if (payType != PayEnums.BACK_SCAN) {
|
||||
// 非事务环境下直接发送(兼容无事务场景)
|
||||
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint, "非事务环境打印");
|
||||
}
|
||||
// log.info("非事务环境下,直接发送订单{}打印消息", orderId);
|
||||
}
|
||||
rabbitPublisher.sendOrderDetailStatusMsg(orderInfo.getShopId().toString(), "bc");
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopUser;
|
||||
@@ -113,7 +115,8 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
//发送打票信息
|
||||
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
|
||||
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0"
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_1", orderInfo.getIsPrint() == 1);
|
||||
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_1",
|
||||
orderInfo.getIsPrint() == 1, "0元付款");
|
||||
redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
|
||||
throw new PaySuccessException("支付成功");
|
||||
}
|
||||
@@ -240,7 +243,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
CzgPayBaseReq.ltPayReq(
|
||||
payOrderNo, "充值并支付",
|
||||
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(),
|
||||
"wechatPay".equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
|
||||
PayCst.Type.WECHAT.equals(payParam.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId(), clintIp));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,7 +266,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
upOrderPayInfo(orderInfo.getId(), PayCst.Type.ALIPAY.equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
@@ -287,7 +290,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
upOrderPayInfo(orderInfo.getId(), PayCst.Type.ALIPAY.equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
|
||||
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
@@ -302,7 +305,7 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
|
||||
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
|
||||
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), ""));
|
||||
upOrderPayInfo(orderInfo.getId(), "aliPay".equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
upOrderPayInfo(orderInfo.getId(), PayCst.Type.ALIPAY.equals(payParam.getPayType()) ? PayEnums.ALIPAY_MINI : PayEnums.WECHAT_MINI, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
|
||||
@@ -354,6 +357,9 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
if (mapCzgResult.getCode() == 200) {
|
||||
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
|
||||
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN);
|
||||
// 事务成功提交后执行消息发送
|
||||
String printParam = orderInfo.getId() + "_" + (!"after-pay".equals( orderInfo.getPayMode()) ? 1 : 0) + "_1";
|
||||
rabbitPublisher.sendOrderPrintMsg(printParam, orderInfo.getIsPrint() == 1, "事务环境打印");
|
||||
} else {
|
||||
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
|
||||
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
|
||||
@@ -522,12 +528,11 @@ public class OrderPayServiceImpl implements OrderPayService {
|
||||
}
|
||||
throw new CzgException(refund.getMsg());
|
||||
} else {
|
||||
paymentService.updateChain()
|
||||
.eq(OrderPayment::getId, refundId)
|
||||
.set(OrderPayment::getPayTime, refund.getData().getRefundTime())
|
||||
.set(OrderPayment::getTradeNumber, refund.getData().getThirdRefundNo())
|
||||
.set(OrderPayment::getRespJson, refund.getData().getOriginalData())
|
||||
.update();
|
||||
OrderPayment upPayment = new OrderPayment();
|
||||
upPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime()));
|
||||
upPayment.setTradeNumber(refund.getData().getThirdRefundNo());
|
||||
upPayment.setRespJson(refund.getData().getOriginalData());
|
||||
paymentService.update(upPayment, new QueryWrapper().eq(OrderPayment::getId, refundId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayAdapter;
|
||||
import com.czg.PayAdapterFactory;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.constants.ParamCodeCst;
|
||||
import com.czg.constants.PayTypeConstants;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.order.dto.LtPayOtherDTO;
|
||||
@@ -64,10 +64,13 @@ public class PayServiceImpl implements PayService {
|
||||
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
|
||||
payData = shopMerchant.getPolyPayJson();
|
||||
}
|
||||
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
|
||||
if (payType.equals(CzgPayEnum.MICRO_PAY)) {
|
||||
checkMicroPay(bizData, shopMerchant);
|
||||
}
|
||||
if (!PayCst.Type.WECHAT.equals(bizData.getPayType()) && !PayCst.Type.ALIPAY.equals(bizData.getPayType())) {
|
||||
throw new CzgException("支付方式错误");
|
||||
}
|
||||
bizData.setSubAppid(PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
|
||||
return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ public class PayServiceImpl implements PayService {
|
||||
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
|
||||
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
|
||||
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
|
||||
param.getPrice(), "", null));
|
||||
param.getPrice(), "", param.getRelatedId()));
|
||||
return pay(param.getShopId(), CzgPayEnum.LT_PAY,
|
||||
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
|
||||
param.getPayType(), param.getOpenId(), param.getIp()));
|
||||
@@ -229,11 +232,11 @@ public class PayServiceImpl implements PayService {
|
||||
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
|
||||
//微信支付
|
||||
bizData.setSubAppid(shopMerchant.getWechatAppId());
|
||||
bizData.setPayType(SystemConstants.PayType.WECHAT);
|
||||
bizData.setPayType(PayCst.Type.WECHAT);
|
||||
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
|
||||
//支付宝支付
|
||||
bizData.setSubAppid(shopMerchant.getAlipayAppId());
|
||||
bizData.setPayType(SystemConstants.PayType.ALIPAY);
|
||||
bizData.setPayType(PayCst.Type.ALIPAY);
|
||||
} else {
|
||||
throw new CzgException("扫描码非法或暂不支持");
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.czg.pay.PolyMerchantDTO;
|
||||
import com.czg.service.order.mapper.ShopMerchantMapper;
|
||||
import com.czg.service.order.service.ShopDirectMerchantService;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.CzgStrUtils;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
@@ -75,16 +74,18 @@ public class ShopMerchantServiceImpl extends ServiceImpl<ShopMerchantMapper, Sho
|
||||
ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopMerchantParam.getShopId()));
|
||||
if (shopMerchant == null) {
|
||||
shopMerchant = new ShopMerchant();
|
||||
shopMerchant.setAlipayAppId(SystemConstants.PayType.ALIPAY_APP_ID);
|
||||
shopMerchant.setWechatAppId(SystemConstants.PayType.WECHAT_APP_ID);
|
||||
shopMerchant.setAlipayAppId(SystemConstants.PayAppId.ALIPAY_APP_ID);
|
||||
shopMerchant.setWechatAppId(SystemConstants.PayAppId.WECHAT_APP_ID);
|
||||
shopMerchant.setRelatedId(shopMerchantParam.getShopId());
|
||||
}
|
||||
shopMerchant.setShopId(shopMerchantParam.getShopId());
|
||||
if (isUp) {
|
||||
shopMerchant.setChannel(CzgStrUtils.getStrOrNull(shopMerchantParam.getChannel()));
|
||||
if (StrUtil.isNotBlank(shopMerchantParam.getChannel())) {
|
||||
shopMerchant.setChannel(shopMerchantParam.getChannel());
|
||||
}
|
||||
shopMerchant.setRelatedId(shopMerchantParam.getRelatedId());
|
||||
if (shopMerchantParam.getRelatedId() == null || !shopMerchantParam.getRelatedId().equals(shopMerchant.getRelatedId())) {
|
||||
ShopDirectMerchant shopDirectMerchant = shopDirectMerchantService.getById(shopMerchantParam.getRelatedId());
|
||||
if (shopMerchant.getRelatedId() != null && !shopMerchantParam.getRelatedId().equals(shopMerchant.getRelatedId())) {
|
||||
ShopDirectMerchant shopDirectMerchant = shopDirectMerchantService.getById(shopMerchant.getRelatedId());
|
||||
if (shopDirectMerchant != null) {
|
||||
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
|
||||
nativeMerchantDTO.setWechatMerchantId(shopDirectMerchant.getWechatMerchantId());
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.czg.service.order.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
@@ -158,6 +159,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(memberOrder.getAmount())
|
||||
.setIp(clientIp);
|
||||
payParam1.setRelatedId(memberOrder.getId());
|
||||
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
|
||||
}
|
||||
|
||||
@@ -189,6 +191,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(payParam.getAmount())
|
||||
.setIp(clintIp);
|
||||
payParam1.setRelatedId(isFree ? payParam.getOrderId() : payParam.getRechargeDetailId());
|
||||
return payService.ltPayOther(payParam1, payType, "会员充值");
|
||||
}
|
||||
|
||||
@@ -209,12 +212,13 @@ public class ShopUserServiceImpl implements ShopUserPayService {
|
||||
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
|
||||
|
||||
LtPayOtherDTO payParam = new LtPayOtherDTO()
|
||||
.setOpenId("wechatPay".equals(rechargeDTO.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId())
|
||||
.setOpenId(PayCst.Type.WECHAT.equals(rechargeDTO.getPayType()) ? userInfo.getWechatOpenId() : userInfo.getAlipayOpenId())
|
||||
.setPayType(rechargeDTO.getPayType())
|
||||
.setShopId(rechargeDTO.getShopId())
|
||||
.setRecordId(shopUser.getId())
|
||||
.setPrice(amount)
|
||||
.setIp(clientIp);
|
||||
payParam.setRelatedId(isFree ? rechargeDTO.getOrderId() : rechargeDTO.getRechargeDetailId());
|
||||
return payService.ltPayOther(payParam, payType, "会员充值");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ package com.czg.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.PayAdapter;
|
||||
import com.czg.PayCst;
|
||||
import com.czg.PolyPayUtils;
|
||||
import com.czg.constant.PayChannelCst;
|
||||
import com.czg.constants.SystemConstants;
|
||||
import com.czg.entity.resp.CzgBaseResp;
|
||||
import com.czg.entity.resp.CzgRefundResp;
|
||||
import com.czg.enums.CzgPayEnum;
|
||||
@@ -84,15 +84,15 @@ public class PolyPayAdapter implements PayAdapter {
|
||||
}
|
||||
|
||||
private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||
bizData.setPayType(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||
bizData.setPayType(PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
|
||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||
return PolyPayUtils.jsPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
|
||||
}
|
||||
|
||||
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + ("aliPay".equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
|
||||
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
|
||||
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
|
||||
}
|
||||
|
||||
@@ -53,18 +53,6 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
||||
@Resource
|
||||
private WxAccountUtil wxAccountUtil;
|
||||
|
||||
private QueryWrapper buildQueryWrapper(ConsStockFlowDTO param) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildSortQueryWrapper();
|
||||
/*if (StrUtil.isNotEmpty(param.getName())) {
|
||||
queryWrapper.like(ConsStockFlow::getName, param.getName());
|
||||
}*/
|
||||
Long shopId = StpKit.USER.getShopId(0L);
|
||||
queryWrapper.eq(ConsStockFlow::getShopId, shopId);
|
||||
queryWrapper.orderBy(ConsStockFlow::getId, false);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public ConsInOutStockHeadParam inStock(ConsInOutStockHeadParam param) {
|
||||
@@ -72,7 +60,6 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
||||
Long createUserId = StpKit.USER.getLoginIdAsLong();
|
||||
String createUserName = StpKit.USER.getAccount();
|
||||
ConsStockFlow head = BeanUtil.copyProperties(param, ConsStockFlow.class);
|
||||
List<ConsStockFlow> entityList = BeanUtil.copyToList(param.getBodyList(), ConsStockFlow.class);
|
||||
List<ConsStockFlow> insertList = new ArrayList<>();
|
||||
List<ConsInfo> updateStockList = new ArrayList<>();
|
||||
for (ConsInOutStockBodyParam entity : param.getBodyList()) {
|
||||
@@ -251,15 +238,7 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
||||
Long shopId = entity.getShopId();
|
||||
BigDecimal afterNumber = entity.getAfterNumber();
|
||||
ConsInfo consInfo = consInfoMapper.selectOneById(entity.getConId());
|
||||
String shopName = "";
|
||||
try {
|
||||
shopName = StpKit.USER.getShopName();
|
||||
} catch (Exception e) {
|
||||
log.error("获取店铺名称失败");
|
||||
}
|
||||
if (StrUtil.isEmpty(shopName)) {
|
||||
shopName = productMapper.getShopName(shopId);
|
||||
}
|
||||
String shopName = productMapper.getShopName(shopId);
|
||||
BigDecimal conWarning = consInfo.getConWarning();
|
||||
// 库存小于警告值,发送消息提醒
|
||||
if (NumberUtil.isLess(afterNumber, conWarning)) {
|
||||
@@ -268,12 +247,8 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
|
||||
return;
|
||||
}
|
||||
String conName = StrUtil.format("{}数量<预警值{}", consInfo.getConName(), conWarning);
|
||||
String finalShopName = shopName;
|
||||
ThreadUtil.execAsync(() -> {
|
||||
openIdList.parallelStream().forEach(openId -> {
|
||||
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
|
||||
});
|
||||
});
|
||||
ThreadUtil.execAsync(() -> openIdList.parallelStream().forEach(openId ->
|
||||
wxAccountUtil.sendStockMsg("耗材库存预警", shopName, conName, afterNumber, openId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,8 @@ public class ProductStockFlowServiceImpl extends ServiceImpl<ProductStockFlowMap
|
||||
}
|
||||
String productName = StrUtil.sub(product.getName(), 0, 10).concat("...");
|
||||
String conName = StrUtil.format("{}数量<预警值{}", productName, warnLine);
|
||||
String finalShopName = shopName;
|
||||
ThreadUtil.execAsync(() -> {
|
||||
openIdList.parallelStream().forEach(openId -> {
|
||||
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
|
||||
});
|
||||
});
|
||||
ThreadUtil.execAsync(() -> openIdList.parallelStream().forEach(openId ->
|
||||
wxAccountUtil.sendStockMsg("商品库存预警", shopName, conName, afterNumber, openId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package com.czg.service.product.util;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.czg.service.RedisService;
|
||||
import jakarta.annotation.Resource;
|
||||
import com.czg.exception.CzgException;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -32,6 +28,7 @@ import java.util.Map;
|
||||
@Component
|
||||
public class WxAccountUtil {
|
||||
|
||||
//银收客公众号推送
|
||||
@Value("${wx.ysk.appId}")
|
||||
private String appId = "wx212769170d2c6b2a";
|
||||
@Value("${wx.ysk.secrete}")
|
||||
@@ -41,9 +38,6 @@ public class WxAccountUtil {
|
||||
@Value("${wx.ysk.warnMsgTmpId}")
|
||||
private String warnMsgTmpId;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RedisService redisService;
|
||||
|
||||
static LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
|
||||
|
||||
@@ -59,84 +53,100 @@ public class WxAccountUtil {
|
||||
linkedHashMap.put("47003", "参数错误");
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
String accessToken = Convert.toStr(redisService.get("accessToken"));
|
||||
if (StrUtil.isNotEmpty(accessToken)) {
|
||||
return accessToken;
|
||||
}
|
||||
String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
log.warn("公众号获取token失败, 响应内容: {}", resp);
|
||||
throw new RuntimeException(resp);
|
||||
}
|
||||
accessToken = respInfo.getString("access_token");
|
||||
int expiresIn = respInfo.getInteger("expires_in");
|
||||
redisService.set("accessToken", accessToken, expiresIn - 10);
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
public JSONObject sendTemplateMsg(String templateId, String toUserOpenId, Map<String, Object> data) {
|
||||
log.info("开始发送微信模板消息, 接收用户openId: {}, 消息数据: {}", toUserOpenId, data);
|
||||
String accessToken = getAccessToken();
|
||||
|
||||
JSONObject object1 = new JSONObject();
|
||||
|
||||
object1.put("template_id", templateId);
|
||||
object1.put("touser", toUserOpenId);
|
||||
object1.put("data", data);
|
||||
|
||||
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
log.info("微信模板消息发送成功,响应内容:{}", response);
|
||||
JSONObject resObj = JSONObject.parseObject(response);
|
||||
if (ObjectUtil.isNotEmpty(resObj) && ObjectUtil.isNotNull(resObj) && "0".equals(resObj.get("errcode") + "")) {
|
||||
return resObj;
|
||||
}
|
||||
|
||||
throw new RuntimeException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||
}
|
||||
|
||||
public void sendOperationMsg(List<String> openIdList, String userName, String operationDesc) {
|
||||
openIdList.forEach(openId -> {
|
||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing19", new HashMap<String, Object>() {{
|
||||
put("value", userName);
|
||||
}});
|
||||
put("thing8", new HashMap<String, Object>() {{
|
||||
put("value", StrUtil.sub(operationDesc,0,20));
|
||||
}});
|
||||
put("time21", new HashMap<String, Object>() {{
|
||||
put("value", DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
}});
|
||||
}};
|
||||
log.info("开始发送敏感操作消息, 接收用户openId: {}, 操作用户: {}, 操作描述: {}", openId, userName, operationDesc);
|
||||
Map<String, Object> data = Map.of(
|
||||
"thing19", Map.of("value", userName),
|
||||
"thing8", Map.of("value", StrUtil.sub(operationDesc, 0, 20)),
|
||||
"time21", Map.of("value", DateUtil.format(DateUtil.date(), "yyyy-MM-dd HH:mm:ss"))
|
||||
);
|
||||
try {
|
||||
sendTemplateMsg(operationMsgTmpId, openId, data);
|
||||
sendTemplateMsg("敏感操作", operationMsgTmpId, openId, data);
|
||||
} catch (Exception e) {
|
||||
log.error("发送失败, openId: {}, 响应: {}", openId, e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void sendStockMsg(String shopName, String productName, BigDecimal stockNum, String openId) {
|
||||
public void sendStockMsg(String typeName, String shopName, String productName, BigDecimal stockNum, String openId) {
|
||||
if (stockNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
stockNum = BigDecimal.ZERO;
|
||||
}
|
||||
String stockNumStr = stockNum.toPlainString();
|
||||
Map<String, Object> data = new HashMap<String, Object>() {{
|
||||
put("thing22", new HashMap<String, Object>() {{
|
||||
put("value", shopName);
|
||||
}});
|
||||
put("thing4", new HashMap<String, Object>() {{
|
||||
put("value", productName);
|
||||
}});
|
||||
put("number5", new HashMap<String, Object>() {{
|
||||
put("value", stockNumStr);
|
||||
}});
|
||||
}};
|
||||
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", openId, data);
|
||||
Map<String, Object> data = Map.of(
|
||||
//品名
|
||||
"thing34", Map.of("value", typeName),
|
||||
//商品名称
|
||||
"thing4", Map.of("value", productName),
|
||||
//商品数量
|
||||
"number5", Map.of("value", stockNumStr),
|
||||
//商家名称
|
||||
"thing22", Map.of("value", shopName)
|
||||
);
|
||||
try {
|
||||
sendTemplateMsg(warnMsgTmpId, openId, data);
|
||||
sendTemplateMsg("库存预警", warnMsgTmpId, openId, data);
|
||||
} catch (Exception e) {
|
||||
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public String getAccessToken() {
|
||||
String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", appId, secrete));
|
||||
// 响应 {"accessToken":"100_6C_jltHANT1y2Fot5PXKFDzPXTyWumCsao0oMoNRvJUTuxS0IOVO4nBmjdmx5dZfYItShFVSAKYzNDf7ZGLPlx52ii1Y1qerrbbSmIiLWCrec5qjBY4gV5Tfv8YKKTdABAEEN","appId":"wx212769170d2c6b2a"}
|
||||
if(StrUtil.isNotBlank(resp)){
|
||||
JSONObject respInfo = JSONObject.parseObject(resp);
|
||||
return respInfo.getString("accessToken");
|
||||
}else {
|
||||
String resp1 = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
|
||||
JSONObject respInfo = JSONObject.parseObject(resp1);
|
||||
if (!respInfo.containsKey("access_token")) {
|
||||
log.warn("银收客 公众号获取token失败, 响应内容: {}", resp1);
|
||||
throw new CzgException(resp);
|
||||
}
|
||||
return respInfo.getString("access_token");
|
||||
}
|
||||
}
|
||||
|
||||
public JSONObject sendTemplateMsg(String detail, String templateId, String toUserOpenId, Map<String, Object> data) {
|
||||
log.info("银收客公众号消息推送,消息类型:{} 接收用户openId: {}, 消息数据: {}", detail, toUserOpenId, data);
|
||||
String accessToken = getAccessToken();
|
||||
JSONObject object1 = new JSONObject();
|
||||
object1.put("template_id", templateId);
|
||||
object1.put("touser", toUserOpenId);
|
||||
object1.put("data", data);
|
||||
|
||||
String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
log.info("银收客公众号消息推送,响应内容:{}", response);
|
||||
JSONObject resObj = JSONObject.parseObject(response);
|
||||
if (ObjectUtil.isNotEmpty(resObj) && ObjectUtil.isNotNull(resObj) && "0".equals(resObj.get("errcode") + "")) {
|
||||
return resObj;
|
||||
}
|
||||
throw new CzgException(linkedHashMap.getOrDefault(resObj.get("errcode") + "", "未知错误"));
|
||||
}
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
//// String appId = "wx212769170d2c6b2a";
|
||||
//// String secrete = "8492a7e8d55bbb1b57f5c8276ea1add0";
|
||||
//// String resp = HttpUtil.get(StrUtil.format("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={}&secret={}", appId, secrete));
|
||||
//// System.out.println(resp);
|
||||
//
|
||||
// String accessToken = "100_ZGAKcjfJBViY-W_4TPDRnZJvnveRsVFAQzUY0SeosUMfVId4LN-TLD1Ajp-7t7aZL4yiBIjbAaTiK-FQ4S1KnbaDDobfYjD2jqMvbgXHFxiActwaDmdJfYpt6QcWNKcAHAQHE";
|
||||
// JSONObject object1 = new JSONObject();
|
||||
// object1.put("template_id", "C08OUr80x6wGmUN1zpFhSZyFA2G6b9_jiZgEppzLB70");
|
||||
// object1.put("touser", "ojC-S6r36TauETXV8G4e6J-U8Qa0");
|
||||
// object1.put("data", Map.of(
|
||||
// //品名
|
||||
// "thing34", Map.of("value", "耗材"),
|
||||
// //商品名称
|
||||
// "thing4", Map.of("value", "名称"),
|
||||
// //商品数量
|
||||
// "number5", Map.of("value", 1),
|
||||
// //商家名称
|
||||
// "thing22", Map.of("value", "412341324")
|
||||
// ));
|
||||
//
|
||||
// String response = HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||
// log.info("银收客公众号消息推送,响应内容:{}", response);
|
||||
// JSONObject resObj = JSONObject.parseObject(response);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
and t1.shop_id = #{shopId}
|
||||
</where>
|
||||
<if test="idList != null">
|
||||
and t1.id in
|
||||
and (t1.id in
|
||||
<foreach item="item" collection="idList" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
@@ -157,6 +157,7 @@
|
||||
<foreach item="item" collection="idList" separator="," open="(" close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
order by t1.sort desc,t1.id desc
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user