60 Commits

Author SHA1 Message Date
gong
fcd70b24a8 Merge remote-tracking branch 'origin/test' into test 2026-01-29 09:42:59 +08:00
gong
2d15315b79 商品导出 2026-01-29 09:42:50 +08:00
abcd0fbc7b 不知道 2026-01-28 17:27:54 +08:00
fc8599d36c 空指针 2026-01-28 17:07:50 +08:00
66d3c8ad0b 用户端获取分享的基础配置 2026-01-28 14:40:54 +08:00
abdbe89082 Merge remote-tracking branch 'origin/test' into test 2026-01-28 14:40:06 +08:00
e3887148c1 用户端获取分享的基础配置 2026-01-28 14:39:55 +08:00
gong
c984867e4e 用户列表导出接口1 2026-01-28 13:57:30 +08:00
gong
9e2cf024eb 用户列表导出接口 2026-01-28 13:47:33 +08:00
25b9a5b389 分销员添加报错 2026-01-28 11:40:29 +08:00
6cd6ac74ea 分销更名 全民股东
新增全民股东群聊配置
2026-01-28 10:54:58 +08:00
ae67fb6f8e 微信 获取token 2026-01-27 17:03:08 +08:00
52e8a209fb 分享 领取 2026-01-27 16:22:56 +08:00
f2024d5be5 小程序 页面修改
分享配置
轮播图配置
2026-01-27 14:16:25 +08:00
c015c9d907 微信模板消息 数量不能为负数 2026-01-26 18:06:51 +08:00
08eec1b338 银收客 公众号消息推送问题 2026-01-26 17:41:29 +08:00
782fd5a0e5 银收客 模板消息修改 2026-01-26 15:54:25 +08:00
4c65d3226a 异常 抛出 2026-01-26 09:29:26 +08:00
74156e207a 分销 2026-01-23 17:10:58 +08:00
b74367b9cd 更新分销上下级 2026-01-23 16:54:46 +08:00
1c7d3ac374 分销 2026-01-23 16:47:13 +08:00
1a18449d65 邀请问题 2026-01-23 16:35:56 +08:00
3b28287f22 会员等级不存在的问题 2026-01-23 14:14:19 +08:00
b9e768bd47 渠道 兼容 2026-01-23 10:15:53 +08:00
3dcc649224 添加支付信息 2026-01-23 10:09:43 +08:00
5cb95a31f1 事务结束后 2026-01-22 17:56:45 +08:00
f2ab7bdcd5 事务结束后 响应2 2026-01-22 17:41:31 +08:00
10cb6aa8cc 事务结束后 响应 2026-01-22 17:35:28 +08:00
ff95440732 绑定 响应 2026-01-22 17:23:08 +08:00
5fe6b48786 记得删除 /user/distribution/clean 2026-01-22 17:13:47 +08:00
6bd1959fc3 Merge remote-tracking branch 'origin/test' into test 2026-01-22 17:04:29 +08:00
c78b7a1ec3 记得删除 /user/distribution/clean 2026-01-22 17:04:19 +08:00
gong
bae925695a 查询 关联商品 sync_id bug 2026-01-22 15:57:30 +08:00
a94a9197b8 优惠券详情 2026-01-21 16:10:26 +08:00
3a1579d281 优惠券详情 2026-01-21 16:06:20 +08:00
f092fdc0e9 必填 2026-01-21 15:51:30 +08:00
bb673d805a 积分商品详情 2026-01-21 15:33:30 +08:00
0ba52b85b2 检查登录 2026-01-21 13:36:59 +08:00
0345ab85ec 标识 2026-01-21 10:39:02 +08:00
6f64c8be81 莫名其妙的问题 2026-01-21 10:37:37 +08:00
1ce9b023ab token问题 2026-01-21 10:33:11 +08:00
a1aebd16de token问题 2026-01-21 10:26:01 +08:00
0549a077b2 会员充值/霸王餐支付 关联id问题
统一异常拦截 rootCause 值
CLIENT_LOGIC 与 USER_LOGIC 问题
2026-01-21 10:17:09 +08:00
45965fb426 异常信息尝试获取 2026-01-20 18:25:02 +08:00
034a8c4650 报错 2026-01-20 17:51:39 +08:00
4cd71ad35a 兼容 2026-01-20 17:43:36 +08:00
64830203f3 详细日志 2026-01-20 17:39:39 +08:00
c542f18938 获取邀请码 失败的问题日志 2026-01-20 15:44:08 +08:00
cc40a8a7f0 不报错 获取邀请码 2026-01-20 15:13:22 +08:00
f10bafce52 Merge branch 'prod' into test 2026-01-20 14:49:54 +08:00
3e42b534e0 台桌排序
分享绑定
2026-01-20 10:19:33 +08:00
a367a286ce v3报错 2026-01-19 11:09:07 +08:00
37651e0e02 支付方式问题 2026-01-17 17:52:24 +08:00
9bcbad42ad 支付方式问题 2026-01-17 17:43:03 +08:00
8242a4f905 支付类型 2026-01-17 17:32:31 +08:00
cf3c58169d BACK_SCAN支付 主扫直接成功的 没有异步通知 2026-01-17 15:49:08 +08:00
f1e9d0f4cf bacn scan 打印两次问题 2026-01-17 15:25:05 +08:00
de21e0a202 bacn scan 打印两次问题 2026-01-17 15:01:32 +08:00
fff14043b5 触发打印位置 2026-01-17 14:36:04 +08:00
5da3b447c7 退款更新问题 2026-01-17 14:18:27 +08:00
101 changed files with 2363 additions and 719 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,6 +3,7 @@ package com.czg.controller.user;
import com.czg.account.entity.UserInfo; import com.czg.account.entity.UserInfo;
import com.czg.market.dto.MkDistributionUserDTO; import com.czg.market.dto.MkDistributionUserDTO;
import com.czg.market.dto.MkDistributionWithdrawFlowDTO; import com.czg.market.dto.MkDistributionWithdrawFlowDTO;
import com.czg.market.entity.MkDistributionUser;
import com.czg.market.entity.MkDistributionWithdrawFlow; import com.czg.market.entity.MkDistributionWithdrawFlow;
import com.czg.market.service.MkDistributionConfigService; import com.czg.market.service.MkDistributionConfigService;
import com.czg.market.service.MkDistributionFlowService; import com.czg.market.service.MkDistributionFlowService;
@@ -16,17 +17,20 @@ import com.czg.sa.StpKit;
import com.czg.task.DistributionTask; import com.czg.task.DistributionTask;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Map; import java.util.Map;
/** /**
* 分销相关 * 全民股东相关
* *
* @author Administrator * @author Administrator
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/user/distribution") @RequestMapping("/user/distribution")
public class UDistributionController { public class UDistributionController {
@@ -42,7 +46,7 @@ public class UDistributionController {
private DistributionTask distributionTask; private DistributionTask distributionTask;
/** /**
* 分销员中心-获取配置 * 测试方法-分销流水入账
*/ */
@GetMapping("/task") @GetMapping("/task")
public CzgResult<String> task(@RequestParam Long shopId) { public CzgResult<String> task(@RequestParam Long shopId) {
@@ -56,7 +60,7 @@ public class UDistributionController {
/** /**
* 分销员中心-获取配置 * 全民股东=-获取配置
*/ */
@GetMapping("/getConfig") @GetMapping("/getConfig")
public CzgResult<MkDistributionConfigVO> getConfig(@RequestParam Long shopId) { public CzgResult<MkDistributionConfigVO> getConfig(@RequestParam Long shopId) {
@@ -64,7 +68,7 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-首页 * 全民股东-首页
*/ */
@PostMapping("/centerUser") @PostMapping("/centerUser")
public CzgResult<Map<String, Object>> centerUser() { public CzgResult<Map<String, Object>> centerUser() {
@@ -72,7 +76,7 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-已开通的店铺 * 全民股东界-已开通的店铺
*/ */
@GetMapping("/centerUser/activates") @GetMapping("/centerUser/activates")
public CzgResult<Page<DistributionCenterShopVO>> activates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) { public CzgResult<Page<DistributionCenterShopVO>> activates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
@@ -80,7 +84,7 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-未开通的店铺 * 全民股东-未开通的店铺
*/ */
@GetMapping("/centerUser/unActivates") @GetMapping("/centerUser/unActivates")
public CzgResult<Page<DistributionCenterShopVO>> unActivates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) { public CzgResult<Page<DistributionCenterShopVO>> unActivates(@RequestParam(required = false, defaultValue = "1") Integer page, @RequestParam(required = false, defaultValue = "10") Integer size) {
@@ -88,7 +92,7 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-配置信息 * 全民股东-配置信息
*/ */
@GetMapping("/centerConfig") @GetMapping("/centerConfig")
public CzgResult<Map<String, Object>> centerConfig(@RequestParam Long shopId) { public CzgResult<Map<String, Object>> centerConfig(@RequestParam Long shopId) {
@@ -96,15 +100,27 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-获取邀请码 * 全民股东界面-进入过标识
*/
@GetMapping("/editIn")
public CzgResult<Boolean> editIn(@RequestParam Long shopUserId) {
MkDistributionUser distributionUser = new MkDistributionUser();
distributionUser.setFirstIn(1);
distributionUserService.update(distributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, shopUserId));
return CzgResult.success();
}
/**
* 全民股东-获取邀请码
*/ */
@GetMapping("/getInviteCode") @GetMapping("/getInviteCode")
public CzgResult<String> getInviteCode(@RequestParam Long shopId, @RequestParam Long shopUserId) { public CzgResult<String> getInviteCode(@RequestParam Long shopId, @RequestParam Long shopUserId) {
return CzgResult.success(distributionUserService.getInviteCode(shopId, shopUserId)); return CzgResult.success(distributionUserService.getInviteCode(shopId, shopUserId));
} }
/** /**
* 分销员中心-实名认证 * 全民股东-实名认证
*/ */
@PostMapping("/realNameAuth") @PostMapping("/realNameAuth")
public CzgResult<Map<String, Object>> realNameAuth(@RequestBody UserInfo userInfo) { public CzgResult<Map<String, Object>> realNameAuth(@RequestBody UserInfo userInfo) {
@@ -116,7 +132,7 @@ public class UDistributionController {
} }
/** /**
* 分销员中心-绑定邀请人 * 全民股东-绑定邀请人
*/ */
@PostMapping("/bindInviteUser") @PostMapping("/bindInviteUser")
public CzgResult<Map<String, Object>> bindInviteUser(@RequestBody MkDistributionUserDTO param) { public CzgResult<Map<String, Object>> bindInviteUser(@RequestBody MkDistributionUserDTO param) {
@@ -128,7 +144,7 @@ public class UDistributionController {
} }
/** /**
* 分销员:获取邀请人分页列表 * 全民股东:获取邀请人分页列表
*/ */
@GetMapping("/inviteUser") @GetMapping("/inviteUser")
public CzgResult<Page<InviteUserVO>> getInviteUser( public CzgResult<Page<InviteUserVO>> getInviteUser(
@@ -172,10 +188,7 @@ public class UDistributionController {
/** /**
* 收益明细 * 收益明细
* *
* @param startTime * @param status pending待入账 success已入账
* @param endTime
* @param shopId
* @param status pending待入账 success已入账
*/ */
@GetMapping("/distributionFlow") @GetMapping("/distributionFlow")
public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime, public CzgResult<Map<String, Object>> distributionFlow(@RequestParam(required = false) String startTime, @RequestParam(required = false) String endTime,

View File

@@ -79,7 +79,7 @@ public class UPpPackageController {
* 取消订单 * 取消订单
*/ */
@GetMapping("/cancel") @GetMapping("/cancel")
public CzgResult<Boolean> cancelOrder(Long orderId) { public CzgResult<Boolean> cancelOrder(@RequestParam Long orderId) {
return CzgResult.success(ppPackageOrderService.cancelOrder(orderId)); return CzgResult.success(ppPackageOrderService.cancelOrder(orderId));
} }
@@ -95,7 +95,7 @@ public class UPpPackageController {
* 获取订单详情 * 获取订单详情
*/ */
@GetMapping("/order/detail") @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())); return CzgResult.success(ppPackageOrderService.getOrderDetailById(orderId, StpKit.USER.getLoginIdAsLong()));
} }

View File

@@ -68,7 +68,7 @@ public class NotifyController {
*/ */
@RequestMapping("/native/pay/{platform}") @RequestMapping("/native/pay/{platform}")
public String pay(@PathVariable String platform, @RequestBody JSONObject json) { 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); WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto)); log.info("【微信支付回调】收到微信支付回调 data: {}", JSONObject.toJSONString(reqDto));
@@ -80,7 +80,7 @@ public class NotifyController {
PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO(); PayNotifyRespDTO respDTO = dataDto.convertToPayNotifyRespDTO();
orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0); orderInfoCustomService.payCallBackOrder(respDTO.getMchOrderNo(), respDTO, PayChannelCst.NATIVE, 0);
return "success"; return "success";
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) { } else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝 // 支付宝
return "success"; return "success";
} }
@@ -92,7 +92,7 @@ public class NotifyController {
*/ */
@RequestMapping("/native/refund/{platform}") @RequestMapping("/native/refund/{platform}")
public String refund(@PathVariable String platform, @RequestBody JSONObject json) { 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); WechatNotifyReqDto reqDto = JSONObject.parseObject(json.toJSONString(), WechatNotifyReqDto.class);
log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto)); log.info("【微信退款回调】收到微信退款回调 data: {}", JSONObject.toJSONString(reqDto));
@@ -100,7 +100,7 @@ public class NotifyController {
log.info("【微信退款回调】解密数据 {}", decrypted); log.info("【微信退款回调】解密数据 {}", decrypted);
return "success"; return "success";
} else if (PayCst.Platform.ALIPAY.equalsIgnoreCase(platform)) { } else if (PayCst.Type.ALIPAY.equalsIgnoreCase(platform)) {
// 支付宝 // 支付宝
return "success"; return "success";
} }

View File

@@ -30,7 +30,7 @@ public class DistributionPayController {
/** /**
* 小程序支付 * 小程序支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/ltPayOrder") @PostMapping("/ltPayOrder")
@@ -42,7 +42,7 @@ public class DistributionPayController {
/** /**
* 运营端小程序余额充值 * 运营端小程序余额充值
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
*/ */
@PostMapping("/mchRecharge") @PostMapping("/mchRecharge")
@Debounce(value = "#payParam.userId") @Debounce(value = "#payParam.userId")

View File

@@ -2,8 +2,10 @@ package com.czg.controller.pay;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.URLUtil; import cn.hutool.core.util.URLUtil;
import com.czg.PayCst;
import com.czg.annotation.Debounce; import com.czg.annotation.Debounce;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.market.service.OrderInfoService; import com.czg.market.service.OrderInfoService;
import com.czg.order.dto.CheckOrderPay; import com.czg.order.dto.CheckOrderPay;
import com.czg.order.entity.OrderInfo; import com.czg.order.entity.OrderInfo;
@@ -59,7 +61,7 @@ public class OrderPayController {
/** /**
* 充值并付款 * 充值并付款
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/rechargePayOrder") @PostMapping("/rechargePayOrder")
@@ -99,7 +101,7 @@ public class OrderPayController {
/** /**
* js支付 * js支付
* <p> * <p>
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/jsPay") @PostMapping("/jsPay")
@@ -111,7 +113,7 @@ public class OrderPayController {
/** /**
* 小程序支付 * 小程序支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/ltPayOrder") @PostMapping("/ltPayOrder")
@@ -167,13 +169,21 @@ public class OrderPayController {
} }
/** /**
* payType 必填 支付方式aliPay 支付宝wechatPay 微信 * 空订单支付/h5页面支付
* payType 必填 支付方式ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
* checkOrderPay.orderAmount 必填 * checkOrderPay.orderAmount 必填
*/ */
@PostMapping("/shopPayApi/js2Pay") @PostMapping("/shopPayApi/js2Pay")
@Debounce(value = "#payParam.checkOrderPay.orderId") @Debounce(value = "#payParam.checkOrderPay.orderId")
public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) { public CzgResult<Map<String, Object>> js2PayOrder(HttpServletRequest request, @RequestBody OrderPayParamDTO payParam) {
if ("alipay".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.ALIPAY);
} else if ("wechatPay".equals(payParam.getPayType())) {
payParam.setPayType(PayCst.Type.WECHAT);
} else {
throw new CzgException(payParam.getPayType() + "支付方式错误");
}
return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam); return orderPayService.js2PayOrder(ServletUtil.getClientIP(request), payParam);
} }

View File

@@ -53,7 +53,7 @@ public class VipPayController {
/** /**
* js支付 * js支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/jsPayVip") @PostMapping("/jsPayVip")
@@ -66,7 +66,7 @@ public class VipPayController {
/** /**
* 小程序支付 * 小程序支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/ltPayVip") @PostMapping("/ltPayVip")
@@ -139,6 +139,7 @@ public class VipPayController {
} }
/** /**
* 会员退款
* cashRefund 是否是现金退款 * cashRefund 是否是现金退款
* 会员退款(先调用 退款前置接口 refundVipBefore) * 会员退款(先调用 退款前置接口 refundVipBefore)
* 最大退款金额为 充值金额 inAmount * 最大退款金额为 充值金额 inAmount

View File

@@ -90,7 +90,7 @@ public class UGbOrderController {
/** /**
* 生成订单 * 生成订单
* 小程序支付 * 小程序支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/exchange") @PostMapping("/exchange")

View File

@@ -1,8 +1,11 @@
package com.czg.controller.user; package com.czg.controller.user;
import com.czg.market.entity.MkPointsGoods;
import com.czg.market.entity.MkPointsGoodsRecord; import com.czg.market.entity.MkPointsGoodsRecord;
import com.czg.market.entity.ShopCoupon;
import com.czg.market.service.MkPointsGoodsRecordService; import com.czg.market.service.MkPointsGoodsRecordService;
import com.czg.market.service.MkPointsGoodsService; import com.czg.market.service.MkPointsGoodsService;
import com.czg.market.service.ShopCouponService;
import com.czg.order.dto.CommonRefundDTO; import com.czg.order.dto.CommonRefundDTO;
import com.czg.order.dto.LtPayOtherDTO; import com.czg.order.dto.LtPayOtherDTO;
import com.czg.order.service.PointsGoodPayService; import com.czg.order.service.PointsGoodPayService;
@@ -34,6 +37,8 @@ public class UPointGoodsController {
private MkPointsGoodsRecordService goodsRecordService; private MkPointsGoodsRecordService goodsRecordService;
@Resource @Resource
private PointsGoodPayService goodPayService; private PointsGoodPayService goodPayService;
@Resource
private ShopCouponService shopCouponService;
/** /**
* 商品列表 * 商品列表
@@ -51,10 +56,26 @@ public class UPointGoodsController {
return CzgResult.success(data); 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 必填 * openId 必填
*/ */
@PostMapping("/exchange") @PostMapping("/exchange")

View File

@@ -45,7 +45,7 @@ public class UPpOrderController {
/** /**
* 小程序支付 * 小程序支付
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
*/ */
@PostMapping("/pay") @PostMapping("/pay")

View File

@@ -62,11 +62,11 @@ public class EntryManagerMqListener {
channel.basicNack(deliveryTag, false, false); channel.basicNack(deliveryTag, false, false);
return; return;
} }
Long shopId = Long.valueOf(split[0]); if (split[0]==null) {
if (shopId == null) {
channel.basicNack(deliveryTag, false, false); channel.basicNack(deliveryTag, false, false);
return; return;
} }
Long shopId = Long.valueOf(split[0]);
if (hasMessageId(msg)) { if (hasMessageId(msg)) {
return; return;
} }
@@ -81,10 +81,10 @@ public class EntryManagerMqListener {
EntryManager.uploadParamImage(entry); EntryManager.uploadParamImage(entry);
List<String> platform = new ArrayList<>(); List<String> platform = new ArrayList<>();
if (PayCst.EntryStatus.WAIT.equals(entry.getAlipayStatus())) { if (PayCst.EntryStatus.WAIT.equals(entry.getAlipayStatus())) {
platform.add(PayCst.Platform.ALIPAY); platform.add(PayCst.Type.ALIPAY);
} }
if (PayCst.EntryStatus.WAIT.equals(entry.getWechatStatus())) { 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])); EntryRespDto resp = EntryManager.entryMerchant(entry, platform.toArray(new String[0]));
ShopDirectMerchant merchant = new ShopDirectMerchant(); ShopDirectMerchant merchant = new ShopDirectMerchant();

View File

@@ -2,6 +2,7 @@ package com.czg.controller.admin;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.entity.ShopInfo; import com.czg.account.entity.ShopInfo;
import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopInfoService;
import com.czg.config.RabbitPublisher; import com.czg.config.RabbitPublisher;
@@ -26,10 +27,12 @@ import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup; import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
@@ -66,9 +69,24 @@ public class ProductController {
@GetMapping("page") @GetMapping("page")
@OperationLog("商品-分页") @OperationLog("商品-分页")
//@SaAdminCheckPermission("product:page") //@SaAdminCheckPermission("product:page")
public CzgResult<Page<ProductDTO>> getProductPage(ProductDTO param) { public CzgResult<Map<String, Object>> getProductPage(ProductDTO param) {
Page<ProductDTO> data = productService.getProductPage(param); Page<ProductDTO> data = productService.getProductPage(param);
return CzgResult.success(data); Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(data), Map.class);
if(data.getRecords() != null){
ProductDTO first = data.getRecords().getFirst();
map.put("warnLine", first.getWarnLine());
}else {
map.put("warnLine", 0);
}
return CzgResult.success(map);
}
/**
* 导出商品
*/
@GetMapping("export")
public void exportProduct(ProductDTO param, HttpServletResponse response) {
productService.exportProductList(param, response);
} }
/** /**
@@ -82,9 +100,7 @@ public class ProductController {
param.setShopId(shopId); param.setShopId(shopId);
List<ProductDTO> productList = productService.getProductCacheList(param); List<ProductDTO> productList = productService.getProductCacheList(param);
productService.refreshProductStock(param, productList); productService.refreshProductStock(param, productList);
productList.forEach(prod -> { productList.forEach(prod -> prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime())));
prod.setIsSaleTime(uProductService.calcIsSaleTime(prod.getDays(), prod.getStartTime(), prod.getEndTime()));
});
return CzgResult.success(productList); return CzgResult.success(productList);
} }
@@ -111,13 +127,11 @@ public class ProductController {
for (ProdSkuDTO prodSkuDTO : dto.getSkuList()) { for (ProdSkuDTO prodSkuDTO : dto.getSkuList()) {
ValidatorUtil.validateEntity(prodSkuDTO, DefaultGroup.class); ValidatorUtil.validateEntity(prodSkuDTO, DefaultGroup.class);
} }
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
dto.setShopId(shopId); dto.setShopId(shopId);
productService.addProduct(dto); productService.addProduct(dto);
asyncProductToShop(dto.getId()); asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -140,13 +154,11 @@ public class ProductController {
if (dto.getStockNumber() != null) { if (dto.getStockNumber() != null) {
StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_shang_pin_ku_cun"); StpKit.USER.checkStaffPermission("yun_xu_xiu_gai_shang_pin_ku_cun");
} }
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
dto.setShopId(shopId); dto.setShopId(shopId);
productService.updateProduct(dto); productService.updateProduct(dto);
asyncProductToShop(dto.getId()); asyncProductToShop(dto.getId());
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -155,12 +167,10 @@ public class ProductController {
//@SaStaffCheckPermission("yun_xu_xiu_gai_shang_pin") //@SaStaffCheckPermission("yun_xu_xiu_gai_shang_pin")
public CzgResult<Void> updateProductStock(@RequestBody ProductModifyStockParam param) { public CzgResult<Void> updateProductStock(@RequestBody ProductModifyStockParam param) {
ValidatorUtil.validateEntity(param, DefaultGroup.class); ValidatorUtil.validateEntity(param, DefaultGroup.class);
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId); param.setShopId(shopId);
productService.updateProductStock(param); productService.updateProductStock(param);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -176,12 +186,10 @@ public class ProductController {
public CzgResult<Void> deleteProduct(@PathVariable("id") Long id) { public CzgResult<Void> deleteProduct(@PathVariable("id") Long id) {
//效验数据 //效验数据
AssertUtil.isNull(id, "{}不能为空", "id"); AssertUtil.isNull(id, "{}不能为空", "id");
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
productService.deleteProduct(shopId, id); productService.deleteProduct(shopId, id);
asyncProductToShop(id); asyncProductToShop(id);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -193,12 +201,10 @@ public class ProductController {
//@SaStaffCheckPermission("yun_xu_shang_xia_jia_shang_pin") //@SaStaffCheckPermission("yun_xu_shang_xia_jia_shang_pin")
//@SaAdminCheckPermission("product:on-off") //@SaAdminCheckPermission("product:on-off")
public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) { public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId); param.setShopId(shopId);
productService.onOffProduct(param); productService.onOffProduct(param);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -210,12 +216,10 @@ public class ProductController {
//@SaStaffCheckPermission("yun_xu_shou_qing_shang_pin") //@SaStaffCheckPermission("yun_xu_shou_qing_shang_pin")
//@SaAdminCheckPermission("product:markIsSoldOut") //@SaAdminCheckPermission("product:markIsSoldOut")
public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) { public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
param.setShopId(shopId); param.setShopId(shopId);
productService.markProductIsSoldOut(param); productService.markProductIsSoldOut(param);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId)));
rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(shopId));
});
return CzgResult.success(); return CzgResult.success();
} }
@@ -312,9 +316,7 @@ public class ProductController {
if (shopInfo.getMainId() == null || shopId == shopInfo.getMainId()) { if (shopInfo.getMainId() == null || shopId == shopInfo.getMainId()) {
throw new CzgException("不存在主子店铺关系,无需同步商品信息"); throw new CzgException("不存在主子店铺关系,无需同步商品信息");
} }
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> shopSyncService.sync(shopInfo.getMainId(), shopId, shopId));
shopSyncService.sync(shopInfo.getMainId(), shopId, shopId);
});
CzgResult<Void> ret = CzgResult.success(); CzgResult<Void> ret = CzgResult.success();
ret.setMsg("操作成功,数据正在后台同步中..."); ret.setMsg("操作成功,数据正在后台同步中...");
return ret; return ret;
@@ -322,15 +324,11 @@ public class ProductController {
private void asyncProductToShop(Long id) { private void asyncProductToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L); long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> shopSyncService.syncProductBySourceShop(shopId, id, shopId));
shopSyncService.syncProductBySourceShop(shopId, id, shopId);
});
} }
private void asyncConsProToShop(Long id) { private void asyncConsProToShop(Long id) {
long shopId = StpKit.USER.getShopId(0L); long shopId = StpKit.USER.getShopId(0L);
ThreadUtil.execAsync(() -> { ThreadUtil.execAsync(() -> shopSyncService.syncConsProBySourceShop(shopId, id, shopId));
shopSyncService.syncConsProBySourceShop(shopId, id, shopId);
});
} }
} }

View File

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

View File

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

View File

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

View File

@@ -56,8 +56,8 @@ public class RabbitPublisher {
* @param orderId 订单id * @param orderId 订单id
* @param printOrder 是否打印结算单 * @param printOrder 是否打印结算单
*/ */
public void sendOrderPrintMsg(String orderId, boolean printOrder) { public void sendOrderPrintMsg(String orderId, boolean printOrder, String source) {
log.info("开始发送打印mq消息, orderId: {}, printOrder: {}", orderId, printOrder); 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()); 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,sendMarkSms 发送营销短信 shop_id,sms_push_event.id,sendMarkSms
* 1,2,sendWechatTemp 发送微信模版消息 shop_id,ac_push_event.id,sendWechatTemp * 1,2,sendWechatTemp 发送微信模版消息 shop_id,ac_push_event.id,sendWechatTemp
* 1,2,groupBuyYes 发送微信模版消息 shop_id,gb_order.id,groupBuyYes * 1,2,groupBuyYes 发送微信模版消息 shop_id,gb_order.id,groupBuyYes
*
* @param param 店铺Id,主键Id * @param param 店铺Id,主键Id
* @param type applySmsTemp,sendMarkSms,sendWechatTemp,groupBuyYes * @param type applySmsTemp,sendMarkSms,sendWechatTemp,groupBuyYes
*/ */
public void sendApplySmsMsg(String param, String type) { public void sendApplySmsMsg(String param, String type) {
sendMsg(RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, param + "," + type); sendMsg(RabbitConstants.Queue.APPLY_SMS_TEMPLATE_QUEUE, param + "," + type);

View File

@@ -43,7 +43,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
userConfig.setIsShare(true); userConfig.setIsShare(true);
// config2.setTimeout(2000); // config2.setTimeout(2000);
userConfig.setTokenStyle("simple-uuid"); userConfig.setTokenStyle("simple-uuid");
MyStpLogic.CLIENT_LOGIC.setConfig(userConfig); MyStpLogic.USER_LOGIC.setConfig(userConfig);
} }
@PostConstruct @PostConstruct
@@ -62,21 +62,25 @@ public class SaTokenConfigure implements WebMvcConfigurer {
// 重置根路径防止satoken切割根路径导致匹配不到路径 // 重置根路径防止satoken切割根路径导致匹配不到路径
ApplicationInfo.routePrefix = ""; ApplicationInfo.routePrefix = "";
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**", "/user/home/**", "/user/dict/**", "/user/openId") SaRouter
.notMatch("/pay/**") // 完全开放的路径(不需要任何认证)
.notMatch("/notify/**") .match("/user/login", "/user/geo/**", "/user/home/**",
.check(r -> MyStpLogic.CLIENT_LOGIC.checkLogin()) "/user/dict/**", "/user/openId","/admin/auth/**",
.setHit(true) "/admin/shopMsgPush/subscribe/**",
// .match("/**") "/admin/coupon/grant",
.notMatch("/user/**") "/pay/**",
.notMatch("/pay/**") "/notify/**")
.notMatch("/notify/**") .stop() // 直接放行,不检查登录
.notMatch("/admin/auth/**")
.notMatch("/admin/shopMsgPush/subscribe/**") // 用户认证路径
.notMatch("/admin/coupon/grant") .match("/user/**")
.check(r -> MyStpLogic.USER_LOGIC.checkLogin())
// 管理端认证内网IP免认证
.match("/**")
.check(r -> { .check(r -> {
ServletRequestAttributes attributes = ServletRequestAttributes attributes = (ServletRequestAttributes)
(ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); RequestContextHolder.getRequestAttributes();
if (attributes == null || (!ServletUtil.getClientIP(attributes.getRequest()).contains("192.168") && !ServletUtil.getClientIP(attributes.getRequest()).contains("127.0.0.1"))) { if (attributes == null || (!ServletUtil.getClientIP(attributes.getRequest()).contains("192.168") && !ServletUtil.getClientIP(attributes.getRequest()).contains("127.0.0.1"))) {
MyStpLogic.ADMIN_LOGIC.checkLogin(); MyStpLogic.ADMIN_LOGIC.checkLogin();
} }

View File

@@ -27,7 +27,7 @@ import java.util.function.Consumer;
@Slf4j @Slf4j
@Getter @Getter
public class MyStpLogic { 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 static final StpLogic ADMIN_LOGIC = new StpLogic("admin");
public Object isPC() { public Object isPC() {
@@ -42,7 +42,7 @@ public class MyStpLogic {
private StpLogic getLogic() { private StpLogic getLogic() {
boolean hit = SaRouter.match("/user/**").isHit(); boolean hit = SaRouter.match("/user/**").isHit();
if (hit) { if (hit) {
return CLIENT_LOGIC; return USER_LOGIC;
} }
return ADMIN_LOGIC; return ADMIN_LOGIC;
} }

View File

@@ -28,5 +28,4 @@ public class ShopUserDTO extends ShopUser {
private String nextMemberLevelName; private String nextMemberLevelName;
private Long nextExperience; private Long nextExperience;
private Long pointBalance; private Long pointBalance;
private boolean isNew;
} }

View File

@@ -0,0 +1,116 @@
package com.czg.account.dto.shopuser;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
* @author yjjie
* @date 2026/1/28 11:30
*/
@Data
public class ShopUserExportDTO {
@ExcelProperty("手机号")
private String phone;
@ExcelProperty("会员生日")
private String birthDay;
@ExcelProperty("用户昵称")
private String nickName;
@ExcelIgnore
private Integer status;
@ExcelProperty("会员状态")
private String statusRemark;
@ExcelIgnore
private Integer isVip;
@ExcelProperty("是否会员")
private String vipRemark;
@ExcelProperty("会员编号")
private String code;
@ExcelProperty("余额")
private BigDecimal amount;
@ExcelProperty("充值次数")
private Integer rechargeCount;
@ExcelProperty("消费累计")
private BigDecimal consumeAmount;
@ExcelProperty("消费次数")
private Integer consumeCount;
@ExcelProperty("经验值")
private Long experience;
@ExcelIgnore
private String distributionShops;
@ExcelProperty("是否分销员")
private String distributionShopsRemark;
@ExcelProperty("优惠券数量")
private Long couponNum;
@ExcelProperty("订单数量")
private Long orderNumber;
@ExcelProperty("充值金额")
private BigDecimal rechargeAmount;
@ExcelProperty("会员等级")
private String memberLevelName;
@ExcelProperty("下一级会员等级")
private String nextMemberLevelName;
@ExcelProperty("升级所需经验值")
private Long nextExperience;
@ExcelProperty("积分余额")
private Long pointBalance;
@ExcelProperty("加入会员时间")
private LocalDateTime joinTime;
@ExcelProperty("创建时间")
private LocalDateTime createTime;
public String getVipRemark() {
if (isVip == null || isVip == 0) {
return "";
}
return "";
}
public String getStatusRemark() {
if (status == null || status == 0) {
return "禁用";
}
return "正常";
}
public String getDistributionShopsRemark() {
if (StrUtil.isBlank(distributionShops) || !distributionShops.contains("_")) {
return "";
}
String[] split = distributionShops.split("_");
if (split.length < 2) {
return "";
}
if ("0".equals(split[1])) {
return "";
}
return "";
}
}

View File

@@ -152,6 +152,23 @@ public class ShopUser implements Serializable {
private LocalDateTime nextDeliverTime; private LocalDateTime nextDeliverTime;
// 是否分销员 // 是否分销员
private String distributionShops; private String distributionShops;
/**
* 上级分销员id
*/
private Long parentUserId;
/**
* 上上级分销员id
*/
private Long gradeUserId;
/**
* 一级分销收入
*/
private BigDecimal oneIncome;
/**
* 二级分销收入
*/
private BigDecimal twoIncome;
private String memberCircleName; private String memberCircleName;
private Integer memberCircleReward; private Integer memberCircleReward;

View File

@@ -4,6 +4,7 @@ import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.market.entity.SmsPushEventUser; import com.czg.market.entity.SmsPushEventUser;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import jakarta.servlet.http.HttpServletResponse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List; import java.util.List;
@@ -22,6 +23,8 @@ public interface AShopUserService {
Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser); Page<ShopUser> getPushEventUser(SmsPushEventUser smsPushEventUser);
Page<ShopUser> getAcPushEventUser(SmsPushEventUser smsPushEventUser); Page<ShopUser> getAcPushEventUser(SmsPushEventUser smsPushEventUser);
void exportUserList(String key, Integer isVip, HttpServletResponse response);
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO); Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);

View File

@@ -2,9 +2,9 @@ package com.czg.account.service;
import com.czg.account.entity.ShopConfig; import com.czg.account.entity.ShopConfig;
import com.czg.account.entity.ShopInfo; import com.czg.account.entity.ShopInfo;
import com.czg.exception.CzgException;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@@ -15,7 +15,7 @@ import java.util.List;
*/ */
public interface ShopConfigService extends IService<ShopConfig> { public interface ShopConfigService extends IService<ShopConfig> {
ShopInfo getShopInfoAndConfig(Serializable id); ShopInfo getShopInfoAndConfig(Long id) throws CzgException;
void editStatusByShopIdList(Long mainShopId, Integer isEnable, boolean onyUpValid, String name, String useShopType, List<Long> shopIdList); void editStatusByShopIdList(Long mainShopId, Integer isEnable, boolean onyUpValid, String name, String useShopType, List<Long> shopIdList);

View File

@@ -46,18 +46,9 @@ public interface SystemConstants {
/** /**
* 三方支付类型 * 小程序APPID
*/ */
class PayType { class PayAppId {
/**
* 微信支付
*/
public static final String WECHAT = "wechatPay";
/**
* 支付宝支付
*/
public static final String ALIPAY = "alipay";
/** /**
* 微信小程序支付 * 微信小程序支付

View File

@@ -0,0 +1,46 @@
package com.czg.market.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serial;
import java.io.Serializable;
/**
* 轮播图配置表 实体类。
*
* @author ww
* @since 2026-01-27
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MkCarouselDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 店铺Id
*/
private Long shopId;
/**
* 轮播图名称20字内
*/
private String name;
/**
* 是否可分享 1=开启 0=关闭
*/
private Integer isShareable;
/**
* 启用状态 1=启用 0=禁用
*/
private Integer isEnabled;
}

View File

@@ -0,0 +1,97 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 轮播图配置表 实体类。
*
* @author ww
* @since 2026-01-27
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mk_carousel")
public class MkCarousel implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@Id(keyType = KeyType.Auto)
private BigInteger id;
/**
* 店铺Id
*/
private Long shopId;
/**
* 轮播图名称20字内
*/
private String name;
/**
* 轮播图片地址
*/
private String imageUrl;
/**
* 是否可分享 1=开启 0=关闭
*/
private Integer isShareable;
/**
* 跳转页面 tb_mini_app_pages的 id
*/
private Long jumpPageId;
/**
* 跳转页面路径
*/
@Column(ignore = true)
private String jumpPagePath;
/**
* 扩展参数
*/
private String extendParam;
/**
* 排序值,值越大越靠前
*/
private Integer sort;
/**
* 启用状态 1=启用 0=禁用
*/
private Integer isEnabled;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@@ -110,8 +110,10 @@ public class MkDistributionFlow implements Serializable {
private String nickName; private String nickName;
/**
* 分成比例
*/
private BigDecimal commission; private BigDecimal commission;
private BigDecimal parentCommission;
private LocalDateTime deliverTime; private LocalDateTime deliverTime;
private Long userId; private Long userId;
} }

View File

@@ -0,0 +1,67 @@
package com.czg.market.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.io.Serial;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 分销员管理群(全民股东管理) 实体类。
*
* @author ww
* @since 2026-01-28
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mk_distribution_group")
public class MkDistributionGroup implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
@Id
private Long shopId;
/**
* 群二维码地址
*/
private String groupUrl;
/**
* 模块标题 15字以内
*/
private String title;
/**
* 模块内容 20字以内
*/
private String content;
/**
* 是否开启
*/
private Integer isEnable;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@@ -62,12 +62,8 @@ public class MkDistributionLevelConfig implements Serializable {
/** /**
* 一级分销比例 * 一级分销比例
*/ */
private BigDecimal levelOneCommission; private BigDecimal commission;
/**
* 二级分销比例
*/
private BigDecimal levelTwoCommission;
/** /**
* 创建时间 * 创建时间

View File

@@ -1,7 +1,6 @@
package com.czg.market.entity; package com.czg.market.entity;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@@ -117,5 +116,9 @@ public class MkDistributionUser implements Serializable {
* 邀请码 * 邀请码
*/ */
private String inviteCode; private String inviteCode;
/**
* 是否第一次进入全民股东界面
*/
private Integer firstIn;
} }

View File

@@ -0,0 +1,114 @@
package com.czg.market.entity;
import com.czg.market.dto.ShopCouponDTO;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 分享奖励基础配置 实体类。
*
* @author ww
* @since 2026-01-27
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("mk_share_base")
public class MkShareBase implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 店铺id
*/
@Id
private Long shopId;
/**
* 功能开启状态 1=开启 0=关闭
*/
private Integer isEnabled;
/**
* 可获得奖励的分享页面,用逗号分隔,
* 店铺首页 index
* 我的 dine
* 点餐页 eat
* 点餐页 eat-detail
* 套餐推广-列表 pp-list
* 套餐推广-详情 pp-detail
* 商品拼团-列表 gb-list
* 商品拼团-详情 gb-detail
* 全民股东 dis
*/
private String rewardSharePages;
/**
* 分享人奖励的优惠券ID关联优惠券表
*/
private Long sharerCouponId;
/**
* 分享人奖励的优惠券信息
*/
@Column(ignore = true)
private ShopCouponDTO sharerCoupon;
/**
* 分享人奖励的优惠券名称
*/
@Column(ignore = true)
private String sharerCouponName;
/**
* 分享人单次获得优惠券数量
*/
private Integer sharerCouponNum;
/**
* 可获得奖励次数 1=仅1次 2=每次分享成功
*/
private Integer rewardTimesType;
/**
* 被分享人奖励的优惠券ID关联优惠券表可选
*/
private Long sharedUserCouponId;
/**
* 被分享人奖励的优惠券名称
*/
@Column(ignore = true)
private String sharedUserCouponName;
/**
* 被分享人单次获得优惠券数量(可选)
*/
private Integer sharedUserCouponNum;
/**
* 被分享人弹窗开关 1=开启 0=关闭
*/
private Integer isSharedUserPopup;
/**
* 创建时间
*/
@Column(onInsertValue = "now()")
private LocalDateTime createTime;
/**
* 更新时间
*/
@Column(onInsertValue = "now()", onUpdateValue = "now()")
private LocalDateTime updateTime;
}

View File

@@ -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;
}

View File

@@ -0,0 +1,19 @@
package com.czg.market.service;
import com.czg.market.dto.MkCarouselDTO;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkCarousel;
import java.util.List;
/**
* 轮播图配置表 服务层。
*
* @author ww
* @since 2026-01-27
*/
public interface MkCarouselService extends IService<MkCarousel> {
List<MkCarousel> getCarousels(MkCarouselDTO mkCarouselDTO);
}

View File

@@ -0,0 +1,14 @@
package com.czg.market.service;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkDistributionGroup;
/**
* 分销员管理群(全民股东管理) 服务层。
*
* @author ww
* @since 2026-01-28
*/
public interface MkDistributionGroupService extends IService<MkDistributionGroup> {
}

View File

@@ -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 ;
/** /**
* 分销员中心-实名认证 * 分销员中心-实名认证
@@ -60,9 +60,18 @@ public interface MkDistributionUserService extends IService<MkDistributionUser>
/** /**
* 分销员中心-绑定邀请人 * 分销员中心-绑定邀请人
* 通过邀请码
*/ */
void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException; void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException;
/**
* 分销员中心-绑定邀请人
* 通过邀请人id
* @param fromUserId shopUserId 邀请人
* @param toUserId 被邀请人邀请人
*/
void bindInviteUser(Long fromUserId, Long toUserId, Long shopId) throws CzgException, ValidateException;
/** /**
* 获取分销员分页列表 * 获取分销员分页列表
*/ */

View File

@@ -0,0 +1,17 @@
package com.czg.market.service;
import com.mybatisflex.core.service.IService;
import com.czg.market.entity.MkShareBase;
/**
* 分享奖励基础配置 服务层。
*
* @author ww
* @since 2026-01-27
*/
public interface MkShareBaseService extends IService<MkShareBase> {
MkShareBase getShareBase(Long shopId);
void shareClaim(String tagType, Long shopId, Long fromUserId, Long toUserId);
}

View File

@@ -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);
}

View File

@@ -9,7 +9,7 @@ import java.math.BigDecimal;
/** /**
* 小程序支付 其它类型 * 小程序支付 其它类型
* payType 必填 支付方式,aliPay 支付宝wechatPay 微信 * payType 必填 支付方式,ALIPAY 支付宝WECHAT 微信
* openId 必填 * openId 必填
* @author ww * @author ww
*/ */
@@ -32,7 +32,7 @@ public class LtPayOtherDTO {
@NotNull(message = "兑换数量不能为空") @NotNull(message = "兑换数量不能为空")
private int number; private int number;
/** /**
* 支付方式 支付方式aliPay 支付宝wechatPay 微信 * 支付方式ALIPAY 支付宝WECHAT 微信
*/ */
private String payType; private String payType;
/** /**
@@ -58,8 +58,13 @@ public class LtPayOtherDTO {
* 对应的记录Id 支付回调向该内容进行回填 * 对应的记录Id 支付回调向该内容进行回填
* 积分商品为 mk_points_goods_record 主键id * 积分商品为 mk_points_goods_record 主键id
* 团购商品为 gb_order_detail 主键id * 团购商品为 gb_order_detail 主键id
*
*/ */
private Long recordId; private Long recordId;
/**
* 霸王餐充值为 订单id 会员充值为 活动id
*/
private Long relatedId;
public void checkPayInfo(){ public void checkPayInfo(){
AssertUtil.isBlank(payType, "支付方式不能为空"); AssertUtil.isBlank(payType, "支付方式不能为空");

View File

@@ -1,7 +1,6 @@
package com.czg.order.dto; package com.czg.order.dto;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -26,7 +25,7 @@ public class MkDistributionPayDTO implements Serializable {
private Long userId; private Long userId;
/** /**
* 支付类型 * 支付类型
* {@link com.czg.constants.SystemConstants.PayType} * {@link com.czg.PayCst.Type}
*/ */
private String payType; private String payType;
private String returnUrl; private String returnUrl;

View File

@@ -0,0 +1,173 @@
package com.czg.product.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
/**
* 商品导出
* @author yjjie
* @date 2026/1/28 14:30
*/
@Data
public class ProductExportDTO {
@Data
public static class ProductSkuExportDTO {
@ExcelProperty("条形码")
private String barCode;
@ExcelProperty("原价")
private BigDecimal originPrice;
@ExcelProperty("成本价")
private BigDecimal costPrice;
@ExcelProperty("会员价")
private BigDecimal memberPrice;
@ExcelProperty("售价")
private BigDecimal salePrice;
@ExcelProperty("起售数量")
private Integer suitNum;
@ExcelProperty("规格详情")
private String specInfo;
@ExcelProperty("是否上架")
private Integer isGrounding;
@ExcelProperty("规格名称")
private String name;
}
@Data
public static class ProductGroupExportDTO {
@ExcelProperty("套餐内商品总数")
private Integer count;
@ExcelProperty("套餐选几")
private Integer number;
@ExcelProperty("套餐名称")
private String title;
@ExcelProperty("套餐内商品列表")
private List<FoodExportDTO> goods = new ArrayList<>();
@Data
public static class FoodExportDTO {
@ExcelProperty("商品名称")
private String proName;
@ExcelProperty("规格名称")
private String skuName;
}
}
@ExcelProperty("商品名称")
private String name;
@ExcelProperty("商品分类名称")
private String categoryName;
@ExcelProperty("条码")
private String barCode;
@ExcelProperty("商品规格名称")
private String specFullName;
@ExcelProperty("售价")
private BigDecimal price;
@ExcelProperty("会员价")
private BigDecimal memberPrice;
@ExcelProperty("商品单位名称")
private String unitName;
/**
* 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品 weight-称重商品 coupon-团购券
*/
@ExcelProperty("商品类型")
private String type;
/**
* 套餐类型 0 固定套餐 1可选套餐
*/
@ExcelIgnore
private Integer groupType;
@ExcelProperty("套餐类型")
private String groupTypeRemark;
/**
* 可用开始时间
*/
@ExcelProperty("可用开始时间")
private LocalTime startTime;
/**
* 可用结束时间
*/
@ExcelProperty("可用结束时间")
private LocalTime endTime;
/**
* 商品级库存数量
*/
@ExcelProperty("库存数量")
private Integer stockNumber;
/**
* 是否上架
*/
@ExcelIgnore
private Integer isSale;
@ExcelProperty("是否上架")
private String isSaleRemark;
@ExcelIgnore
private List<ProductSkuExportDTO> skuList;
@ExcelIgnore
private List<ProductGroupExportDTO> proGroupVo;
public String getType() {
return switch (type) {
case "single" -> "单规格商品";
case "sku" -> "多规格商品";
case "package" -> "套餐商品";
case "weight" -> "称重商品";
case "coupon" -> "团购券";
case null, default -> "未知类型";
};
}
public String getGroupTypeRemark() {
if (!"package".equals(type)) {
return "";
}
return switch (groupType) {
case 0 -> "固定套餐";
case 1 -> "可选套餐";
case null, default -> "未知类型";
};
}
public String getIsSaleRemark() {
return switch (isSale) {
case 0 -> "下架";
case 1 -> "上架";
case null, default -> "未知状态";
};
}
}

View File

@@ -1,13 +1,13 @@
package com.czg.product.service; package com.czg.product.service;
import com.czg.product.dto.ProductDTO; import com.czg.product.dto.ProductDTO;
import com.czg.product.dto.RelatedProductDTO;
import com.czg.product.entity.Product; import com.czg.product.entity.Product;
import com.czg.product.entity.ProductStockFlow; import com.czg.product.entity.ProductStockFlow;
import com.czg.product.param.*; import com.czg.product.param.*;
import com.czg.product.vo.ProductStatisticsVo; import com.czg.product.vo.ProductStatisticsVo;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import jakarta.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -34,6 +34,8 @@ public interface ProductService extends IService<Product> {
*/ */
List<ProductDTO> getProductList(ProductDTO param); List<ProductDTO> getProductList(ProductDTO param);
void exportProductList(ProductDTO param, HttpServletResponse response);
/** /**
* 从缓存里面获取商品列表 * 从缓存里面获取商品列表
* *

View File

@@ -95,6 +95,11 @@
<artifactId>mybatis-flex-processor</artifactId> <artifactId>mybatis-flex-processor</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -0,0 +1,21 @@
package com.czg.excel;
import java.util.List;
/**
* 数据提供者接口(用于分批获取数据)
* @author yjjie
* @date 2026/1/28 10:51
*/
@FunctionalInterface
public interface DataSupplier<T> {
/**
* 获取指定页的数据
*
* @param pageNum 页码
* @param pageSize 每页大小
* @return 数据列表
*/
List<T> getData(int pageNum, int pageSize);
}

View File

@@ -0,0 +1,40 @@
package com.czg.excel;
import lombok.Data;
/**
* Excel导出配置类
* @author yjjie
* @date 2026/1/28 10:47
*/
@Data
public class ExcelExportConfig {
/**
* 默认工作表名称
*/
private String defaultSheetName = "Sheet1";
/**
* 默认文件名
*/
private String defaultFileName = "export_data";
/**
* 是否自动关闭流
*/
private boolean autoCloseStream = true;
/**
* 响应头编码
*/
private String charset = "UTF-8";
public ExcelExportConfig() {}
public ExcelExportConfig(String defaultSheetName, String defaultFileName) {
this.defaultSheetName = defaultSheetName;
this.defaultFileName = defaultFileName;
}
}

View File

@@ -0,0 +1,303 @@
package com.czg.excel;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
import com.czg.exception.CzgException;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.List;
/**
* EasyExcel导出工具类
* @author yjjie
* @date 2026/1/28 10:48
*/
@Slf4j
public class ExcelExportUtil {
private static final ExcelExportConfig DEFAULT_CONFIG = new ExcelExportConfig();
/**
* 导出Excel到HttpServletResponse
*
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名(不含扩展名)
* @param response HttpServletResponse
* @param <T> 数据类型
*/
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
String fileName, HttpServletResponse response) {
exportToResponse(data, clazz, fileName, DEFAULT_CONFIG, response);
}
/**
* 导出Excel到HttpServletResponse自定义配置
*
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名(不含扩展名)
* @param config 配置信息
* @param response HttpServletResponse
* @param <T> 数据类型
*/
public static <T> void exportToResponse(List<T> data, Class<T> clazz,
String fileName, ExcelExportConfig config,
HttpServletResponse response) {
if (data == null) {
data = Collections.emptyList();
}
setResponseHeader(response, fileName, config);
try (OutputStream outputStream = response.getOutputStream()) {
ExcelWriter excelWriter = EasyExcel.write(outputStream, clazz)
.autoCloseStream(config.isAutoCloseStream())
.build();
WriteSheet writeSheet = EasyExcel.writerSheet(config.getDefaultSheetName()).build();
excelWriter.write(data, writeSheet);
excelWriter.finish();
log.info("Excel导出成功文件名{},数据量:{}", fileName, data.size());
} catch (IOException e) {
log.error("Excel导出失败", e);
throw new CzgException("Excel导出失败", e);
}
}
/**
* 导出Excel到文件
*
* @param data 数据列表
* @param clazz 数据类型
* @param filePath 文件路径
* @param <T> 数据类型
*/
public static <T> void exportToFile(List<T> data, Class<T> clazz, String filePath) {
exportToFile(data, clazz, filePath, DEFAULT_CONFIG);
}
/**
* 导出Excel到文件自定义配置
*
* @param data 数据列表
* @param clazz 数据类型
* @param filePath 文件路径
* @param config 配置信息
* @param <T> 数据类型
*/
public static <T> void exportToFile(List<T> data, Class<T> clazz,
String filePath, ExcelExportConfig config) {
if (data == null) {
data = Collections.emptyList();
}
try {
EasyExcel.write(filePath, clazz)
.sheet(config.getDefaultSheetName())
.doWrite(data);
log.info("Excel文件导出成功路径{},数据量:{}", filePath, data.size());
} catch (Exception e) {
log.error("Excel文件导出失败", e);
throw new CzgException("Excel文件导出失败", e);
}
}
/**
* 带样式的Excel导出到Response
*
* @param data 数据列表
* @param clazz 数据类型
* @param fileName 文件名
* @param response HttpServletResponse
* @param <T> 数据类型
*/
public static <T> void exportWithStyleToResponse(List<T> data, Class<T> clazz,
String fileName, HttpServletResponse response) {
if (data == null) {
data = Collections.emptyList();
}
setResponseHeader(response, fileName, DEFAULT_CONFIG);
try (OutputStream outputStream = response.getOutputStream()) {
// 设置表格样式
HorizontalCellStyleStrategy styleStrategy = createCellStyleStrategy();
ExcelWriter excelWriter = EasyExcel.write(outputStream, clazz)
.registerWriteHandler(styleStrategy)
.autoCloseStream(true)
.build();
WriteSheet writeSheet = EasyExcel.writerSheet(DEFAULT_CONFIG.getDefaultSheetName()).build();
excelWriter.write(data, writeSheet);
excelWriter.finish();
log.info("带样式Excel导出成功文件名{},数据量:{}", fileName, data.size());
} catch (IOException e) {
log.error("带样式Excel导出失败", e);
throw new CzgException("Excel导出失败", e);
}
}
/**
* 大数据量分批导出(避免内存溢出)
*
* @param dataSupplier 数据提供者(分页获取数据)
* @param clazz 数据类型
* @param fileName 文件名
* @param response HttpServletResponse
* @param batchSize 每批大小
* @param <T> 数据类型
*/
public static <T> void exportBigDataToResponse(DataSupplier<T> dataSupplier,
Class<T> clazz, String fileName,
HttpServletResponse response, int batchSize) {
setResponseHeader(response, fileName, DEFAULT_CONFIG);
try (OutputStream outputStream = response.getOutputStream()) {
ExcelWriter excelWriter = EasyExcel.write(outputStream, clazz)
.autoCloseStream(true)
.build();
WriteSheet writeSheet = EasyExcel.writerSheet(DEFAULT_CONFIG.getDefaultSheetName()).build();
int pageNum = 1;
List<T> batchData;
boolean hasNext = true;
while (hasNext) {
batchData = dataSupplier.getData(pageNum, batchSize);
if (batchData != null && !batchData.isEmpty()) {
excelWriter.write(batchData, writeSheet);
pageNum++;
} else {
hasNext = false;
}
}
excelWriter.finish();
log.info("大数据量Excel导出成功文件名{},总页数:{}", fileName, pageNum - 1);
} catch (IOException e) {
log.error("大数据量Excel导出失败", e);
throw new CzgException("Excel导出失败", e);
}
}
/**
* 设置响应头
*/
private static void setResponseHeader(HttpServletResponse response, String fileName, ExcelExportConfig config) {
try {
String encodedFileName = URLEncoder.encode(fileName, config.getCharset())
.replaceAll("\\+", "%20");
String contentDisposition = "attachment;filename*=utf-8''" + encodedFileName + ".xlsx";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding(config.getCharset());
response.setHeader("Content-Disposition", contentDisposition);
} catch (Exception e) {
log.warn("设置响应头失败", e);
}
}
/**
* 创建表格样式策略
*/
private static HorizontalCellStyleStrategy createCellStyleStrategy() {
// 表头样式
WriteCellStyle headStyle = new WriteCellStyle();
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);
// 内容样式
WriteCellStyle contentStyle = new WriteCellStyle();
contentStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
contentStyle.setVerticalAlignment(VerticalAlignment.CENTER);
return new HorizontalCellStyleStrategy(headStyle, contentStyle);
}
/**
* 获取数据总行数(用于前端显示进度)
*/
public static <T> int getDataCount(Class<T> clazz) {
Field[] fields = clazz.getDeclaredFields();
int count = 0;
for (Field field : fields) {
if (field.isAnnotationPresent(ExcelProperty.class)) {
count++;
}
}
return count;
}
/**
* 带合并单元格的商品导出到Response
*
* @param data 数据列表
* @param fileName 文件名
* @param response HttpServletResponse
* @param <T> 数据类型
*/
public static <T> void exportProductWithMergeToResponse(List<T> data, Class<T> clazz,
String fileName,
HttpServletResponse response, List<SheetWriteHandler> handlers) {
if (data == null) {
data = Collections.emptyList();
}
setResponseHeader(response, fileName, DEFAULT_CONFIG);
try (OutputStream outputStream = response.getOutputStream()) {
// 创建样式策略 - 设置表头和内容都居中
WriteCellStyle headStyle = new WriteCellStyle();
headStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteCellStyle contentStyle = new WriteCellStyle();
contentStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
HorizontalCellStyleStrategy styleStrategy = new HorizontalCellStyleStrategy(headStyle, contentStyle);
// 创建写入器 - 必须指定clazz
ExcelWriterBuilder builder = EasyExcel.write(outputStream, clazz)
.autoCloseStream(true)
.registerConverter(new LocalTimeConverter())
.registerWriteHandler(styleStrategy);
if (handlers != null && !handlers.isEmpty()) {
for (SheetWriteHandler h : handlers) {
builder.registerWriteHandler(h);
}
}
ExcelWriter excelWriter = builder.build();
WriteSheet writeSheet = EasyExcel.writerSheet(DEFAULT_CONFIG.getDefaultSheetName()).build();
excelWriter.write(data, writeSheet);
excelWriter.finish();
log.info("带合并单元格的商品Excel导出成功文件名{},数据量:{}", fileName, data.size());
} catch (IOException e) {
log.error("带合并单元格的商品Excel导出失败", e);
throw new CzgException("Excel导出失败", e);
}
}
}

View File

@@ -0,0 +1,47 @@
package com.czg.excel;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/**
* @author yjjie
* @date 2026/1/28 16:16
*/
public class LocalTimeConverter implements Converter<LocalTime> {
private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
@Override
public Class<LocalTime> supportJavaTypeKey() {
return LocalTime.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public LocalTime convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
String stringValue = cellData.getStringValue();
if (stringValue == null || stringValue.trim().isEmpty()) {
return null;
}
return LocalTime.parse(stringValue, FORMATTER);
}
@Override
public WriteCellData<?> convertToExcelData(LocalTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
if (value == null) {
return new WriteCellData<>("");
}
return new WriteCellData<>(value.format(FORMATTER));
}
}

View File

@@ -3,6 +3,7 @@ package com.czg.utils;
import cn.hutool.core.lang.func.Func0; import cn.hutool.core.lang.func.Func0;
import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.thread.ThreadUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.NestedExceptionUtils;
import org.springframework.transaction.support.TransactionSynchronization; import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.transaction.support.TransactionSynchronizationManager;
@@ -27,11 +28,17 @@ public class FunUtils {
return value; return value;
} }
public static void asyncSafeRunVoid(Runnable func, String... msg) {
ThreadUtil.execAsync(() -> safeRunVoid(func, msg));
}
public static void safeRunVoid(Runnable func, String... msg) { public static void safeRunVoid(Runnable func, String... msg) {
try { try {
func.run(); func.run();
} catch (Exception e) { } 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 方法 * @param func 方法
*/ */

View File

@@ -44,6 +44,7 @@
<netty.version>4.1.128.Final</netty.version> <netty.version>4.1.128.Final</netty.version>
<wechatpay.version>0.2.17</wechatpay.version> <wechatpay.version>0.2.17</wechatpay.version>
<apipay-v3.version>3.1.65.ALL</apipay-v3.version> <apipay-v3.version>3.1.65.ALL</apipay-v3.version>
<easyexcel.version>4.0.3</easyexcel.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@@ -282,6 +283,12 @@
<artifactId>alipay-sdk-java-v3</artifactId> <artifactId>alipay-sdk-java-v3</artifactId>
<version>${apipay-v3.version}</version> <version>${apipay-v3.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>${easyexcel.version}</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>

View File

@@ -80,13 +80,13 @@ public class EntryManager {
List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>(); List<Supplier<EntryThirdRespDto>> tasks = new ArrayList<>();
if (platform == null || platform.length == 0) { 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)); 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)); tasks.add(() -> AlipayIsvEntryManager.entryMerchant(null, reqDto));
} }
@@ -102,11 +102,11 @@ public class EntryManager {
for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) { for (AsyncTaskExecutor.TaskResult<EntryThirdRespDto> result : results) {
// 合并两个进件结果 // 合并两个进件结果
EntryThirdRespDto respDto = result.result(); EntryThirdRespDto respDto = result.result();
if (PayCst.Platform.WECHAT.equals(respDto.getPlatform())) { if (PayCst.Type.WECHAT.equals(respDto.getPlatform())) {
entryRespDto.setWechatApplyId(respDto.getEntryId()); entryRespDto.setWechatApplyId(respDto.getEntryId());
entryRespDto.setWechatStatus(respDto.getStatus()); entryRespDto.setWechatStatus(respDto.getStatus());
entryRespDto.setWechatErrorMsg(respDto.getErrorMsg()); 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.setAlipayOrderId(respDto.getEntryId());
entryRespDto.setAlipayStatus(respDto.getStatus()); entryRespDto.setAlipayStatus(respDto.getStatus());
entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg()); entryRespDto.setAlipayErrorMsg(respDto.getErrorMsg());
@@ -384,9 +384,9 @@ public class EntryManager {
// verifyEntryParam(merchantDto); // verifyEntryParam(merchantDto);
// uploadParamImage(merchantDto); // uploadParamImage(merchantDto);
//// System.out.println(merchantDto); //// System.out.println(merchantDto);
EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Platform.WECHAT); // EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.WECHAT);
// entryMerchant(merchantDto, PayCst.Platform.ALIPAY); EntryRespDto respDto = entryMerchant(merchantDto, PayCst.Type.ALIPAY);
// entryMerchant(merchantDto, PayCst.Platform.WECHAT, PayCst.Platform.ALIPAY); // entryMerchant(merchantDto, PayCst.Type.WECHAT, PayCst.Type.ALIPAY);
System.out.println(respDto); System.out.println(respDto);
} }

View File

@@ -21,15 +21,16 @@ public interface PayCst {
String ALIPAY_ERROR_MSG_KEY = "message"; String ALIPAY_ERROR_MSG_KEY = "message";
/** /**
* 平台 * 支付类型
*/ */
class Platform { class Type {
/** /**
* 微信 * 微信支付
*/ */
public static final String WECHAT = "WECHAT"; public static final String WECHAT = "WECHAT";
/** /**
* 支付宝 * 支付宝支付
*/ */
public static final String ALIPAY = "ALIPAY"; public static final String ALIPAY = "ALIPAY";
} }

View File

@@ -1,6 +1,5 @@
package com.czg; package com.czg;
import com.czg.constants.SystemConstants;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.pay.*; import com.czg.pay.*;
import com.czg.third.alipay.AlipayIsvPayManager; import com.czg.third.alipay.AlipayIsvPayManager;
@@ -21,9 +20,9 @@ public class PayManager {
* @return 结果 * @return 结果
*/ */
public static Map<String, Object> jsapiPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) { 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); 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); return AlipayIsvPayManager.jsapiPay(null, paramsDto, merchantDTO);
} else { } else {
throw new CzgException("不支持的支付平台"); throw new CzgException("不支持的支付平台");
@@ -37,9 +36,9 @@ public class PayManager {
* @return 结果 * @return 结果
*/ */
public static Map<String, Object> barPay(CzgPayBaseReq paramsDto, NativeMerchantDTO merchantDTO) { 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); 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); return AlipayIsvPayManager.barPay(null, paramsDto, merchantDTO);
} else { } else {
throw new CzgException("不支持的支付平台"); throw new CzgException("不支持的支付平台");
@@ -50,9 +49,9 @@ public class PayManager {
* 查询订单状态 * 查询订单状态
*/ */
public static QueryOrderRespDTO queryOrderStatus(String platform, String orderNo, NativeMerchantDTO merchantDTO) { 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); 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); return AlipayIsvPayManager.queryOrder(null, orderNo, merchantDTO);
} else { } else {
throw new CzgException("不支持的支付平台"); throw new CzgException("不支持的支付平台");
@@ -63,9 +62,9 @@ public class PayManager {
* 退款 * 退款
*/ */
public static RefundRespDTO refund(CzgRefundReq paramsDto, String notifyUrl, NativeMerchantDTO merchantDTO) { 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); 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); return AlipayIsvPayManager.refundOrder(null, paramsDto, notifyUrl, merchantDTO);
} else { } else {
throw new CzgException("不支持的支付平台"); throw new CzgException("不支持的支付平台");

View File

@@ -106,9 +106,9 @@ public class PayParamsDto {
AssertUtil.isBlank(appId, "appId不能为空"); AssertUtil.isBlank(appId, "appId不能为空");
AssertUtil.isBlank(openId, "用户唯一标识不能为空"); AssertUtil.isBlank(openId, "用户唯一标识不能为空");
if (PayCst.Platform.WECHAT.equals(platform)) { if (PayCst.Type.WECHAT.equals(platform)) {
AssertUtil.isBlank(merchantId, "商户ID不能为空"); AssertUtil.isBlank(merchantId, "商户ID不能为空");
} else if (PayCst.Platform.ALIPAY.equals(platform)) { } else if (PayCst.Type.ALIPAY.equals(platform)) {
AssertUtil.isBlank(payParams, "支付参数不能为空"); AssertUtil.isBlank(payParams, "支付参数不能为空");
alipayAuthInfo = JSONObject.parseObject(payParams, AlipayAuthInfoDto.class); alipayAuthInfo = JSONObject.parseObject(payParams, AlipayAuthInfoDto.class);
AssertUtil.isNull(alipayAuthInfo, "支付参数错误"); AssertUtil.isNull(alipayAuthInfo, "支付参数错误");

View File

@@ -129,7 +129,7 @@ public class WechatPayNotifyDataDto {
.setMchOrderNo(outTradeNo) .setMchOrderNo(outTradeNo)
.setThirdOrderNo(transactionId) .setThirdOrderNo(transactionId)
.setAmount(getPayAmount()) .setAmount(getPayAmount())
.setPlatform(PayCst.Platform.WECHAT) .setPlatform(PayCst.Type.WECHAT)
.setExtData(attach) .setExtData(attach)
.setPaySuccessTime(time) .setPaySuccessTime(time)
.setErrorMsg(tradeStateDesc); .setErrorMsg(tradeStateDesc);

View File

@@ -31,7 +31,6 @@ import com.czg.dto.resp.EntryThirdRespDto;
import com.czg.dto.resp.QueryStatusResp; import com.czg.dto.resp.QueryStatusResp;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.third.alipay.dto.config.AlipayConfigDto; import com.czg.third.alipay.dto.config.AlipayConfigDto;
import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
import com.czg.utils.UploadFileUtil; import com.czg.utils.UploadFileUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -60,7 +59,7 @@ public class AlipayEntryManager {
*/ */
public static QueryStatusResp queryMerchantEntryStatus(AlipayConfigDto configDto, String merchantCode) { public static QueryStatusResp queryMerchantEntryStatus(AlipayConfigDto configDto, String merchantCode) {
QueryStatusResp queryStatusResp = new QueryStatusResp(); QueryStatusResp queryStatusResp = new QueryStatusResp();
queryStatusResp.setPlatform(PayCst.Platform.ALIPAY); queryStatusResp.setPlatform(PayCst.Type.ALIPAY);
queryStatusResp.setMerchantCode(merchantCode); queryStatusResp.setMerchantCode(merchantCode);
AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest(); AntMerchantExpandIndirectZftorderQueryRequest request = new AntMerchantExpandIndirectZftorderQueryRequest();
@@ -158,7 +157,7 @@ public class AlipayEntryManager {
public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) { public static EntryThirdRespDto entryMerchant(AlipayConfigDto configDto, AggregateMerchantDto reqDto) {
AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto); AntMerchantExpandIndirectZftCreateModel entryReqDto = buildEntryParams(reqDto);
EntryThirdRespDto respDto = new EntryThirdRespDto() EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.ALIPAY); .setPlatform(PayCst.Type.ALIPAY);
try { try {
AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest(); AntMerchantExpandIndirectZftCreateRequest request = new AntMerchantExpandIndirectZftCreateRequest();

View File

@@ -1,5 +1,6 @@
package com.czg.third.alipay; package com.czg.third.alipay;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.alipay.v3.ApiException; import com.alipay.v3.ApiException;
import com.alipay.v3.api.*; import com.alipay.v3.api.*;
@@ -30,7 +31,7 @@ public class AlipayIsvEntryManager {
configDto = AlipayConfigDto.getThirdDefaultConfig(); configDto = AlipayConfigDto.getThirdDefaultConfig();
} }
QueryStatusResp respDto = new QueryStatusResp() QueryStatusResp respDto = new QueryStatusResp()
.setPlatform(PayCst.Platform.ALIPAY); .setPlatform(PayCst.Type.ALIPAY);
AlipayClient.setApiClient(configDto); AlipayClient.setApiClient(configDto);
try { try {
@@ -104,13 +105,16 @@ public class AlipayIsvEntryManager {
} }
AlipayClient.setApiClient(configDto); AlipayClient.setApiClient(configDto);
EntryThirdRespDto respDto = new EntryThirdRespDto() EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.ALIPAY); .setPlatform(PayCst.Type.ALIPAY);
try { try {
String batchNo = createRequest(configDto, reqDto); String batchNo = createRequest(configDto, reqDto);
respDto.setEntryId(batchNo); respDto.setEntryId(batchNo);
AlipayOpenAgentFacetofaceSignModel signModel = buildFaceToFaceModel(reqDto, batchNo); AlipayOpenAgentFacetofaceSignModel signModel = buildFaceToFaceModel(reqDto, batchNo);
File businessLicensePic = UploadFileUtil.getFileByUrl(reqDto.getBusinessLicenceInfo().getLicensePic().getUrl()); File businessLicensePic = null;
if (reqDto.getBusinessLicenceInfo() != null && reqDto.getBusinessLicenceInfo().getLicensePic() != null && StrUtil.isNotBlank(reqDto.getBusinessLicenceInfo().getLicensePic().getUrl())) {
businessLicensePic = UploadFileUtil.getFileByUrl(reqDto.getBusinessLicenceInfo().getLicensePic().getUrl());
}
File shopScenePic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getInsidePic().getUrl()); File shopScenePic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getInsidePic().getUrl());
File shopSignBoardPic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getDoorPic().getUrl()); File shopSignBoardPic = UploadFileUtil.getFileByUrl(reqDto.getStoreInfo().getDoorPic().getUrl());
@@ -237,10 +241,12 @@ public class AlipayIsvEntryManager {
signModel.setRate("0.38"); signModel.setRate("0.38");
signModel.setSignAndAuth(true); signModel.setSignAndAuth(true);
signModel.setBusinessLicenseNo(licenceInfo.getLicenceNo()); if (licenceInfo != null) {
signModel.setBusinessLicenseMobile(legalPersonInfo.getLegalPersonPhone()); signModel.setBusinessLicenseNo(licenceInfo.getLicenceNo());
signModel.setLongTerm(PayCst.LONG_TERM_DATE.equals(licenceInfo.getLicenceEndDate())); signModel.setBusinessLicenseMobile(legalPersonInfo.getLegalPersonPhone());
signModel.setDateLimitation(licenceInfo.getLicenceStartDate()); signModel.setLongTerm(PayCst.LONG_TERM_DATE.equals(licenceInfo.getLicenceEndDate()));
signModel.setDateLimitation(licenceInfo.getLicenceStartDate());
}
signModel.setShopName(baseInfo.getShortName()); signModel.setShopName(baseInfo.getShortName());
@@ -258,6 +264,32 @@ public class AlipayIsvEntryManager {
public static void main(String[] args) { public static void main(String[] args) {
// confirmRequest("2026010815384505500018243"); // confirmRequest("2026010815384505500018243");
queryMerchantBatchStatus(null, "2026010815384505500018243"); queryMerchantBatchStatus(null, "2026012310512107600067177");
// AggregateMerchantDto merchantDto = new AggregateMerchantDto();
// merchantDto.setMerchantCode("CZG20260112151202099");
//
// MerchantBaseInfoDto baseInfoDto = new MerchantBaseInfoDto();
// baseInfoDto.setUserType("3");
// baseInfoDto.setShortName("巩奕杰_商户");
// baseInfoDto.setMccCode("A0001_B0199");
// baseInfoDto.setAlipayAccount("15596653310");
// baseInfoDto.setContactPersonType("SUPER");
// baseInfoDto.setContactName("巩奕杰");
// baseInfoDto.setCertType("0");
// baseInfoDto.setContactPhone("15596653310");
// baseInfoDto.setContactEmail("sankejuzi@163.com");
// merchantDto.setMerchantBaseInfo(baseInfoDto);
//
// StoreInfoDto storeInfoDto = new StoreInfoDto();
// storeInfoDto.setBusinessAddress("陕西省西安市浐灞欧亚国际");
// storeInfoDto.setMercAreaCode("610113");
// storeInfoDto.setMercProvCode("610000");
// storeInfoDto.setMercCityCode("610100");
// storeInfoDto.setDoorPic(new ImageDto().setUrl("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/2c207c6f4a764ad18e501ed10fbfad59.png"));
// storeInfoDto.setInsidePic(new ImageDto().setUrl("https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/1/394b4834698a47e9b75419a5fd7f7de7.jpg"));
// merchantDto.setStoreInfo(storeInfoDto);
//
// entryMerchant(null, merchantDto);
} }
} }

View File

@@ -43,7 +43,7 @@ public class AlipayIsvPayManager {
model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount())); model.setTotalAmount(getYuanAmountByFen(paramsDto.getAmount()));
model.setSubject(paramsDto.getSubject()); model.setSubject(paramsDto.getSubject());
model.setBody(paramsDto.getBody()); model.setBody(paramsDto.getBody());
model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Platform.ALIPAY); model.setNotifyUrl(paramsDto.getNotifyUrl() + "/" + PayCst.Type.ALIPAY);
model.setExtendParams(new ExtendParams()); model.setExtendParams(new ExtendParams());
CustomizedParams customizedParams = new CustomizedParams(); CustomizedParams customizedParams = new CustomizedParams();

View File

@@ -1,7 +1,6 @@
package com.czg.third.wechat; package com.czg.third.wechat;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.JSONWriter;
import com.czg.PayCst; 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.WechatEntryBusinessReqDto;
import com.czg.third.wechat.dto.req.entry.business.WechatEntryIdentityReqDto; 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.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.req.entry.id.WechatEntryIdCardReqDto;
import com.czg.third.wechat.dto.resp.WechatAuditDetail; import com.czg.third.wechat.dto.resp.WechatAuditDetail;
import com.czg.third.wechat.dto.resp.WechatQueryStateResp; import com.czg.third.wechat.dto.resp.WechatQueryStateResp;
@@ -50,7 +52,7 @@ public class WechatEntryManager {
*/ */
public static QueryStatusResp queryMerchantEntryStatus(WechatPayConfigDto configDto, String applyId) { public static QueryStatusResp queryMerchantEntryStatus(WechatPayConfigDto configDto, String applyId) {
QueryStatusResp queryStatusResp = new QueryStatusResp(); QueryStatusResp queryStatusResp = new QueryStatusResp();
queryStatusResp.setPlatform(PayCst.Platform.WECHAT); queryStatusResp.setPlatform(PayCst.Type.WECHAT);
queryStatusResp.setMerchantCode(applyId); queryStatusResp.setMerchantCode(applyId);
String resp = WechatReqUtils.getReq(configDto, "/v3/applyment4sub/applyment/applyment_id/" + applyId, Map.of()); 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) { public static EntryThirdRespDto entryMerchant(WechatPayConfigDto configDto, AggregateMerchantDto reqDto) {
EntryThirdRespDto respDto = new EntryThirdRespDto() EntryThirdRespDto respDto = new EntryThirdRespDto()
.setPlatform(PayCst.Platform.WECHAT); .setPlatform(PayCst.Type.WECHAT);
try { try {
WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto); WechatEntryReqDto entryReqDto = buildEntryParams(configDto, reqDto);
log.info("微信进件参数:{}", JSONObject.toJSONString(entryReqDto)); log.info("微信进件参数:{}", JSONObject.toJSONString(entryReqDto));

View File

@@ -56,7 +56,7 @@ public class WechatPayManager {
reqData.put("sub_mchid", merchantDTO.getWechatMerchantId()); reqData.put("sub_mchid", merchantDTO.getWechatMerchantId());
reqData.put("description", paramsDto.getSubject()); reqData.put("description", paramsDto.getSubject());
reqData.put("out_trade_no", paramsDto.getMchOrderNo()); 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()); reqData.put("attach", paramsDto.getExtParam());
JSONObject amount = new JSONObject(); JSONObject amount = new JSONObject();
@@ -267,7 +267,7 @@ public class WechatPayManager {
refundParam.put("out_trade_no", paramsDto.getMchOrderNo()); refundParam.put("out_trade_no", paramsDto.getMchOrderNo());
refundParam.put("out_refund_no", paramsDto.getMchRefundNo()); refundParam.put("out_refund_no", paramsDto.getMchRefundNo());
refundParam.put("reason", paramsDto.getRefundReason()); 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(); JSONObject amount = new JSONObject();
amount.put("total", paramsDto.getOrderTotalAmount()); amount.put("total", paramsDto.getOrderTotalAmount());
@@ -291,7 +291,7 @@ public class WechatPayManager {
.setThirdRefundNo(object.getString("refund_id")) .setThirdRefundNo(object.getString("refund_id"))
.setRefundTime(object.getString("success_time")) .setRefundTime(object.getString("success_time"))
.setOriginalData(resp) .setOriginalData(resp)
.setPlatform(PayCst.Platform.WECHAT); .setPlatform(PayCst.Type.WECHAT);
JSONObject resAmount = object.getJSONObject("amount"); JSONObject resAmount = object.getJSONObject("amount");
if (resAmount != null) { if (resAmount != null) {

View File

@@ -4,12 +4,14 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.shopuser.*; import com.czg.account.dto.shopuser.*;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo; import com.czg.account.entity.UserInfo;
import com.czg.account.service.AShopUserService; import com.czg.account.service.AShopUserService;
import com.czg.account.service.ShopInfoService; import com.czg.account.service.ShopInfoService;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.market.entity.MemberLevelConfig; import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.entity.MkShopCouponRecord; import com.czg.market.entity.MkShopCouponRecord;
@@ -28,6 +30,7 @@ import com.github.pagehelper.PageInfo;
import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -124,6 +127,18 @@ public class AShopUserServiceImpl implements AShopUserService {
} }
} }
@Override
public void exportUserList(String key, Integer isVip, HttpServletResponse response) {
Long mainIdByShopId = shopInfoService.getMainIdByShopId(StpKit.USER.getShopId());
ShopInfo shopInfo = shopInfoService.getById(StpKit.USER.getShopId());
PageHelper.startPage(PageUtil.buildPageHelp());
List<ShopUserDTO> dtoList = shopUserMapper.selectPageByKeyAndIsVip(mainIdByShopId, isVip, key, null);
// 将 dtoList 转换为 ShopUserExportDTO 列表
List<ShopUserExportDTO> exportList = BeanUtil.copyToList(dtoList, ShopUserExportDTO.class);
ExcelExportUtil.exportToResponse(exportList, ShopUserExportDTO.class, shopInfo == null ? "店铺用户列表" : shopInfo.getShopName() + "_用户列表", response);
}
@Override @Override
public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) { public Boolean updateInfo(Long shopId, ShopUserEditDTO shopUserEditDTO) {

View File

@@ -14,7 +14,6 @@ import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -37,7 +36,7 @@ public class ShopConfigServiceImpl extends ServiceImpl<ShopConfigMapper, ShopCon
@Override @Override
@Cacheable(cacheNames = "shopInfo",key = "#id") @Cacheable(cacheNames = "shopInfo",key = "#id")
public ShopInfo getShopInfoAndConfig(Serializable id) throws CzgException { public ShopInfo getShopInfoAndConfig(Long id) throws CzgException {
ShopInfo shopInfo = shopInfoMapper.selectOneById(id); ShopInfo shopInfo = shopInfoMapper.selectOneById(id);
if (shopInfo == null) { if (shopInfo == null) {
throw new CzgException("店铺不存在"); throw new CzgException("店铺不存在");

View File

@@ -83,7 +83,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
@Override @Override
public ShopInfo getById(Serializable id) throws CzgException { public ShopInfo getById(Serializable id) throws CzgException {
return shopConfigService.getShopInfoAndConfig(id); return shopConfigService.getShopInfoAndConfig((Long) id);
} }
@Override @Override

View File

@@ -1,17 +1,13 @@
package com.czg.service.account.util; package com.czg.service.account.util;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService; import com.czg.system.service.SysParamsService;
import jakarta.annotation.Resource;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -26,9 +22,7 @@ import java.util.Map;
@Slf4j @Slf4j
@Component @Component
public class AcAccountUtil { public class AcAccountUtil {
@Resource
@Lazy
private RedisService redisService;
@DubboReference @DubboReference
private SysParamsService paramsService; private SysParamsService paramsService;
@@ -54,7 +48,7 @@ public class AcAccountUtil {
String accessToken = getAccessToken(); String accessToken = getAccessToken();
// String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR"; // String accessToken = "97_HZVThQrtvOiCZGrr23ZHN0cVpHBJHc18RSFHU6dvkQDMAme4GsG0NU-Dax1HP5Wx-aGa1l35KaqiMVv61TCj0Qk8DK1LC6kQ8uKLDfgRYVJjX3QjcelmIjp4PCkERBeABAUHR";
if (StrUtil.isBlank(accessToken)) { if (StrUtil.isBlank(accessToken)) {
log.error("获取 access_token 失败"); log.error("银收客czg 公众号获取 access_token 失败");
return ""; return "";
} }
String bodyJson = "{\"action_info\":{\"scene\":{\"scene_str\":\"" + userId + "\"}},\"action_name\":\"QR_STR_SCENE\",\"expire_seconds\":\"2592000\"}"; 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() { 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); 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 acAppId = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_APP_ID);
String acSecrete = userAc.get(ParamCodeCst.Wechat.Ac.USER_WX_AC_SECRETE); 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); String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", acAppId, acSecrete));
if (!respInfo.containsKey("access_token")) { // 响应 {"accessToken":"100_6C_jltHANT1y2Fot5PXKFDzPXTyWumCsao0oMoNRvJUTuxS0IOVO4nBmjdmx5dZfYItShFVSAKYzNDf7ZGLPlx52ii1Y1qerrbbSmIiLWCrec5qjBY4gV5Tfv8YKKTdABAEEN","appId":"wx212769170d2c6b2a"}
log.warn("公众号获取token失败, 响应内容: {}", resp); if (StrUtil.isNotBlank(resp)) {
return ""; 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;
} }
} }

View File

@@ -1,7 +1,6 @@
package com.czg.service.account.util; package com.czg.service.account.util;
import cn.hutool.core.codec.Base64; import cn.hutool.core.codec.Base64;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.symmetric.AES; import cn.hutool.crypto.symmetric.AES;
@@ -11,6 +10,7 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.config.RedisCst; import com.czg.config.RedisCst;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.czg.system.dto.SysParamsDTO; import com.czg.system.dto.SysParamsDTO;
@@ -140,7 +140,7 @@ public class WechatMiniMsgUtil {
public String getAccountOpenId(String code) { public String getAccountOpenId(String code) {
Map<String, String> shopAc = sysParamsService.getParamsByMap("shop_ac_key_set", ParamCodeCst.SHOP_AC_KEY_SET); 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 accountSecrete = shopAc.get(ParamCodeCst.Wechat.Ac.SHOP_WX_AC_SECRETE);
String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?"; String requestUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?";
Map<String, Object> requestUrlParam = new HashMap<>(); Map<String, Object> requestUrlParam = new HashMap<>();
@@ -162,25 +162,23 @@ public class WechatMiniMsgUtil {
//获取小程序token //获取小程序token
private String getAccessToken() { 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); 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 appId = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_APP_ID);
String secrete = shopMiniKeyMap.get(ParamCodeCst.Wechat.Mini.SHOP_WX_SECRETE); 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 resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", appId, secrete));
String response = HttpUtil.get(url); if (StrUtil.isNotBlank(resp)) {
JSONObject jsonResponse = JSONObject.parseObject(response); JSONObject respInfo = JSONObject.parseObject(resp);
if (!jsonResponse.containsKey("access_token")) { return respInfo.getString("accessToken");
throw new RuntimeException("Failed to retrieve access token: " + response); } 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;
} }
/** /**

View File

@@ -27,7 +27,7 @@
and a.table_code is not null and a.table_code is not null
</if> </if>
group by a.id group by a.id
ORDER BY a.create_time ORDER BY a.area_id,a.id
</select> </select>
</mapper> </mapper>

View File

@@ -18,7 +18,7 @@
and amount - #{money} >= 0 and amount - #{money} >= 0
</update> </update>
<update id="updateOneOrTwoAmount"> <update id="updateOneOrTwoAmount">
update tb_shop_user_invite update tb_shop_user
<set> <set>
<if test="isOne != null and isOne == 1"> <if test="isOne != null and isOne == 1">
one_income = one_income + #{amount} one_income = one_income + #{amount}
@@ -27,8 +27,7 @@
two_income = two_income + #{amount} two_income = two_income + #{amount}
</if> </if>
</set> </set>
where shop_user_id = #{shopUserId} where id = #{shopUserId}
and shop_id = #{shopId}
</update> </update>
@@ -257,10 +256,10 @@
</select> </select>
<select id="getInviteUser" resultType="com.czg.market.vo.InviteUserVO"> <select id="getInviteUser" resultType="com.czg.market.vo.InviteUserVO">
SELECT SELECT
u.id AS shopUserId, invite.id AS shopUserId,
u.head_img AS headImg, invite.head_img AS headImg,
u.nick_name AS shopUserName, invite.nick_name AS shopUserName,
u.phone AS shopUserPhone, invite.phone AS shopUserPhone,
invite.one_income AS oneIncome, invite.one_income AS oneIncome,
invite.invite_time AS inviteTime, invite.invite_time AS inviteTime,
dist.total_income AS totalIncome, dist.total_income AS totalIncome,
@@ -270,13 +269,12 @@
dist.status AS status, dist.status AS status,
dist.distribution_level_id AS levelId, dist.distribution_level_id AS levelId,
dist.distribution_level_name AS levelName, dist.distribution_level_name AS levelName,
u.distribution_shops AS distributionShops invite.distribution_shops AS distributionShops
FROM tb_shop_user_invite invite FROM tb_shop_user invite
left join tb_shop_user u on invite.shop_user_id = u.id left join mk_distribution_user dist on invite.id = dist.id and dist.shop_id = #{shopId}
left join mk_distribution_user dist on u.id = dist.id and dist.shop_id = #{shopId} WHERE invite.`parent_user_id` = #{distributionUserId}
WHERE invite.`distribution_user_id` = #{distributionUserId} and invite.shop_id = #{shopId}
<if test="distributionLevelId != null">and dist.distribution_level_id = #{distributionLevelId}</if> <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 ORDER BY invite.`invite_time` DESC
</select> </select>
</mapper> </mapper>

View File

@@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.MkCarousel;
/**
* 轮播图配置表 映射层。
*
* @author ww
* @since 2026-01-27
*/
public interface MkCarouselMapper extends BaseMapper<MkCarousel> {
}

View File

@@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.MkDistributionGroup;
/**
* 分销员管理群(全民股东管理) 映射层。
*
* @author ww
* @since 2026-01-28
*/
public interface MkDistributionGroupMapper extends BaseMapper<MkDistributionGroup> {
}

View File

@@ -0,0 +1,14 @@
package com.czg.service.market.mapper;
import com.mybatisflex.core.BaseMapper;
import com.czg.market.entity.MkShareBase;
/**
* 分享奖励基础配置 映射层。
*
* @author ww
* @since 2026-01-27
*/
public interface MkShareBaseMapper extends BaseMapper<MkShareBase> {
}

View File

@@ -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> {
}

View File

@@ -1,15 +1,14 @@
package com.czg.service.market.service.impl; package com.czg.service.market.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService; import com.czg.system.service.SysParamsService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -17,6 +16,7 @@ import java.util.Map;
/** /**
* 微信支付service * 微信支付service
*
* @author Administrator * @author Administrator
*/ */
@Component @Component
@@ -27,35 +27,26 @@ public class AppWxServiceImpl extends BaseWx {
@DubboReference @DubboReference
private SysParamsService paramsService; private SysParamsService paramsService;
public AppWxServiceImpl(@Autowired RedisService autoRedisService) { public AppWxServiceImpl() {
this.redisService = autoRedisService;
config = new Config(); config = new Config();
} }
@Override @Override
public String getAccessToken(boolean refresh) { public String getAccessToken(boolean refresh) {
init(); 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, String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", config.appId, config.appSecret));
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret) // 响应 {"accessToken":"100_6C_jltHANT1y2Fot5PXKFDzPXTyWumCsao0oMoNRvJUTuxS0IOVO4nBmjdmx5dZfYItShFVSAKYzNDf7ZGLPlx52ii1Y1qerrbbSmIiLWCrec5qjBY4gV5Tfv8YKKTdABAEEN","appId":"wx212769170d2c6b2a"}
); if (StrUtil.isNotBlank(resp)) {
JSONObject respInfo = JSONObject.parseObject(resp);
log.info("获取access_token响应: {}", response); return respInfo.getString("accessToken");
JSONObject jsonObject = JSONObject.parseObject(response); } else {
String accessToken = jsonObject.getString("access_token"); String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
if (accessToken == null) { Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
throw new RuntimeException("获取access_token失败"); );
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 @Override

View File

@@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.constants.ParamCodeCst;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.service.RedisService; import com.czg.service.RedisService;
import com.ijpay.core.IJPayHttpResponse; import com.ijpay.core.IJPayHttpResponse;
@@ -35,7 +34,6 @@ import java.security.cert.X509Certificate;
import java.util.Base64; import java.util.Base64;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* 微信支付相关 * 微信支付相关
@@ -139,12 +137,13 @@ public abstract class BaseWx {
JSONObject jsonObject = JSONObject.parseObject(body); JSONObject jsonObject = JSONObject.parseObject(body);
String prepayId = jsonObject.getString("prepay_id"); String prepayId = jsonObject.getString("prepay_id");
if (StrUtil.isBlank(prepayId)) { if (StrUtil.isBlank(prepayId)) {
throw new RuntimeException(jsonObject.getString("message")); throw new CzgException(jsonObject.getString("message"));
} }
return WxPayKit.jsApiCreateSign(config.appId, prepayId, config.privateKey); return WxPayKit.jsApiCreateSign(config.appId, prepayId, config.privateKey);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); log.error("微信V3原生支付失败", e);
throw new CzgException("暂无法支付,请联系管理员");
} }
} }

View File

@@ -0,0 +1,48 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.util.StrUtil;
import com.czg.market.dto.MkCarouselDTO;
import com.czg.system.entity.MiniAppPages;
import com.czg.system.service.MiniAppPageService;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MkCarousel;
import com.czg.market.service.MkCarouselService;
import com.czg.service.market.mapper.MkCarouselMapper;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 轮播图配置表 服务层实现。
*
* @author ww
* @since 2026-01-27
*/
@Service
public class MkCarouselServiceImpl extends ServiceImpl<MkCarouselMapper, MkCarousel> implements MkCarouselService {
@DubboReference
private MiniAppPageService miniAppPageService;
@Override
public List<MkCarousel> getCarousels(MkCarouselDTO mkCarouselDTO) {
QueryWrapper queryWrapper = query().eq(MkCarousel::getShopId, mkCarouselDTO.getShopId())
.eq(MkCarousel::getIsEnabled, mkCarouselDTO.getIsEnabled())
.eq(MkCarousel::getIsShareable, mkCarouselDTO.getIsShareable())
.orderBy(MkCarousel::getSort, false);
if (StrUtil.isNotBlank(mkCarouselDTO.getName())) {
queryWrapper.like(MkCarousel::getName, mkCarouselDTO.getName());
}
List<MkCarousel> list = list(queryWrapper);
list.forEach(mkCarousel -> {
if (mkCarousel.getJumpPageId() != null) {
MiniAppPages miniAppPages = miniAppPageService.getById(mkCarousel.getJumpPageId());
if (miniAppPages != null) {
mkCarousel.setJumpPagePath(miniAppPages.getPath());
}
}
});
return list;
}
}

View File

@@ -0,0 +1,18 @@
package com.czg.service.market.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MkDistributionGroup;
import com.czg.market.service.MkDistributionGroupService;
import com.czg.service.market.mapper.MkDistributionGroupMapper;
import org.springframework.stereotype.Service;
/**
* 分销员管理群(全民股东管理) 服务层实现。
*
* @author ww
* @since 2026-01-28
*/
@Service
public class MkDistributionGroupServiceImpl extends ServiceImpl<MkDistributionGroupMapper, MkDistributionGroup> implements MkDistributionGroupService{
}

View File

@@ -61,6 +61,8 @@ import java.util.stream.Collectors;
@Service @Service
public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUserMapper, MkDistributionUser> implements MkDistributionUserService { public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUserMapper, MkDistributionUser> implements MkDistributionUserService {
@Resource
private MkDistributionGroupService mkDistributionGroupService;
@Resource @Resource
private MkDistributionConfigService mkDistributionConfigService; private MkDistributionConfigService mkDistributionConfigService;
@Resource @Resource
@@ -73,12 +75,8 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
private MkDistributionWithdrawFlowService withdrawFlowService; private MkDistributionWithdrawFlowService withdrawFlowService;
@Resource @Resource
private MkDistributionDeliverService distributionDeliverService; private MkDistributionDeliverService distributionDeliverService;
@Resource
private ShopUserInviteService shopUserInviteService;
@Resource @Resource
private AppWxServiceImpl appWxService; private AppWxServiceImpl appWxService;
@DubboReference @DubboReference
private ShopUserService shopUserService; private ShopUserService shopUserService;
@DubboReference @DubboReference
@@ -150,9 +148,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isNull(shopUser, "店铺用户不存在"); AssertUtil.isNull(shopUser, "店铺用户不存在");
UserInfo userInfo = userInfoService.getById(shopUser.getUserId()); UserInfo userInfo = userInfoService.getById(shopUser.getUserId());
result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount()); result.put("cashOutAmount", userInfo.getDistributionAmount() == null ? 0.0 : userInfo.getDistributionAmount());
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId());
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) { if (shopUser.getParentUserId() != null) {
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUserInvite.getDistributionUserId(), shopId); MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getParentUserId(), shopId);
AssertUtil.isNull(mkDistributionUser, "上级分销员不存在"); AssertUtil.isNull(mkDistributionUser, "上级分销员不存在");
ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId()); ShopUser shopUserParent = shopUserService.getById(mkDistributionUser.getId());
result.put("parentName", shopUserParent.getNickName()); result.put("parentName", shopUserParent.getNickName());
@@ -160,6 +158,9 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
} }
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId); MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId);
MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId); MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId);
MkDistributionGroup group = mkDistributionGroupService.getById(shopId);
result.put("config", mkDistributionConfigVO);
result.put("group", group);
if (mkDistributionUser != null) { if (mkDistributionUser != null) {
Map<String, Object> distributionUser = new HashMap<>(); Map<String, Object> distributionUser = new HashMap<>();
distributionUser.put("distributionId", mkDistributionUser.getId()); distributionUser.put("distributionId", mkDistributionUser.getId());
@@ -169,6 +170,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
distributionUser.put("totalIncome", mkDistributionUser.getTotalIncome()); distributionUser.put("totalIncome", mkDistributionUser.getTotalIncome());
distributionUser.put("pendingIncome", mkDistributionUser.getPendingIncome()); distributionUser.put("pendingIncome", mkDistributionUser.getPendingIncome());
distributionUser.put("isAssignLevel", mkDistributionUser.getIsAssignLevel()); distributionUser.put("isAssignLevel", mkDistributionUser.getIsAssignLevel());
distributionUser.put("firstIn", mkDistributionUser.getFirstIn());
if (mkDistributionUser.getDistributionLevelId() != null) { if (mkDistributionUser.getDistributionLevelId() != null) {
List<MkDistributionLevelConfig> levelConfigList = mkDistributionConfigVO.getLevelConfigList(); List<MkDistributionLevelConfig> levelConfigList = mkDistributionConfigVO.getLevelConfigList();
@@ -181,7 +183,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
if (levelConfig.getId().equals(mkDistributionUser.getDistributionLevelId())) { if (levelConfig.getId().equals(mkDistributionUser.getDistributionLevelId())) {
distributionUser.put("level", levelConfig.getLevel()); distributionUser.put("level", levelConfig.getLevel());
distributionUser.put("levelName", levelConfig.getName()); distributionUser.put("levelName", levelConfig.getName());
distributionUser.put("levelOneCommission", levelConfig.getLevelOneCommission()); distributionUser.put("levelOneCommission", levelConfig.getCommission());
isNextLevel = true; isNextLevel = true;
} }
} }
@@ -190,26 +192,24 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
distributionUser.put("levelName", ""); distributionUser.put("levelName", "");
} }
result.put("distributionUser", distributionUser); result.put("distributionUser", distributionUser);
} else {
result.put("config", mkDistributionConfigVO);
} }
return result; return result;
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @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); ShopUser shopUser = shopUserService.getById(shopUserId);
AssertUtil.isNull(shopUser, "店铺用户不存在"); AssertUtil.isNull(shopUser, "店铺用户不存在");
MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId); MkDistributionConfigVO mkDistributionConfigVO = mkDistributionConfigService.detail(shopId);
if (mkDistributionConfigVO == null || mkDistributionConfigVO.getIsEnable() == 0) { if (mkDistributionConfigVO == null || mkDistributionConfigVO.getIsEnable() == 0) {
throw new CzgException("店铺分销功能未开启"); throw new CzgException("店铺分销功能未开启");
} }
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
throw new CzgException("该店铺不可自行成为分销员");
}
MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId); MkDistributionUser mkDistributionUser = getMkDistributionUserByIdAndShopId(shopUser.getId(), shopId);
if (mkDistributionUser == null) { if (mkDistributionUser == null) {
if (!"auto".equals(mkDistributionConfigVO.getOpenType())) {
throw new CzgException("该店铺不可自行成为分销员");
}
mkDistributionUser = new MkDistributionUser(); mkDistributionUser = new MkDistributionUser();
mkDistributionUser.setId(shopUser.getId()); mkDistributionUser.setId(shopUser.getId());
mkDistributionUser.setShopId(shopId); mkDistributionUser.setShopId(shopId);
@@ -234,8 +234,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
public void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException { public void bindInviteUser(MkDistributionUserDTO param) throws CzgException, ValidateException {
ShopUser shopUser = shopUserService.getById(param.getId()); ShopUser shopUser = shopUserService.getById(param.getId());
AssertUtil.isNull(shopUser, "店铺用户不存在"); AssertUtil.isNull(shopUser, "店铺用户不存在");
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(param.getShopId(), shopUser.getId()); if (shopUser.getParentUserId() != null) {
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) {
throw new CzgException("店铺用户已绑定分销员"); throw new CzgException("店铺用户已绑定分销员");
} }
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode())); MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getInviteCode, param.getInviteCode()));
@@ -251,26 +250,28 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
} }
ShopUser parentShopUser = shopUserService.getById(parent.getId()); ShopUser parentShopUser = shopUserService.getById(parent.getId());
AssertUtil.isNull(parentShopUser, "邀请人不存在"); 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("存在绑定关系,不可绑定"); 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("存在绑定关系,不可绑定"); throw new CzgException("存在绑定关系,不可绑定");
} }
//更新自己的上级 //更新自己的上级
ShopUserInvite newShopUserInvite = new ShopUserInvite(); shopUser.setParentUserId(parentShopUser.getId());
newShopUserInvite.setShopId(param.getShopId()); shopUser.setGradeUserId(parentShopUser.getParentUserId());
newShopUserInvite.setShopUserId(shopUser.getId());
newShopUserInvite.setDistributionUserId(parentShopUser.getId()); //更新自己的下级 的上级的上级 为自己的上级
newShopUserInvite.setDistributionUserParentId(parentShopUserInvite == null ? null : parentShopUserInvite.getDistributionUserParentId()); ShopUser upShopUser1 = new ShopUser();
newShopUserInvite.setInviteTime(LocalDateTime.now()); upShopUser1.setParentUserId(parentShopUser.getId());
shopUserInviteService.save(newShopUserInvite); upShopUser1.setGradeUserId(parentShopUser.getParentUserId());
if (parentShopUserInvite != null && parentShopUserInvite.getDistributionUserParentId() != null) { shopUserService.update(upShopUser1, QueryWrapper.create().eq(ShopUser::getId, shopUser.getId()));
if (shopUser.getParentUserId() != null) {
//更新自己的下级 的上级的上级 为自己的上级 //更新自己的下级 的上级的上级 为自己的上级
ShopUserInvite childShopUserInvite = new ShopUserInvite(); ShopUser upShopUser = new ShopUser();
childShopUserInvite.setDistributionUserParentId(parentShopUser.getId()); upShopUser.setGradeUserId(shopUser.getParentUserId());
shopUserInviteService.update(childShopUserInvite, QueryWrapper.create().eq(ShopUserInvite::getDistributionUserId, shopUser.getId())); shopUserService.update(upShopUser, QueryWrapper.create().eq(ShopUser::getParentUserId, shopUser.getId()));
} }
MkDistributionUser newDistributionUser = new MkDistributionUser(); MkDistributionUser newDistributionUser = new MkDistributionUser();
@@ -314,13 +315,98 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
.eq(MkDistributionUser::getShopId, parent.getShopId())); .eq(MkDistributionUser::getShopId, parent.getShopId()));
} }
@Override
@GlobalTransactional
public void bindInviteUser(Long fromUserId, Long toUserId, Long shopId) throws CzgException, ValidateException {
ShopUser shopUser = shopUserService.getById(fromUserId);
AssertUtil.isNull(shopUser, "店铺用户不存在");
if (shopUser.getParentUserId() != null) {
throw new CzgException("店铺用户已绑定上级");
}
MkDistributionUser parent = getOne(QueryWrapper.create().eq(MkDistributionUser::getId, toUserId));
AssertUtil.isNull(parent, "邀请人不存在");
if (!parent.getShopId().equals(shopId)) {
throw new CzgException("邀请人不是本店铺的分销员");
}
if (parent.getId().equals(shopUser.getId())) {
throw new CzgException("不能绑定自己为上级");
}
if (parent.getStatus() == 9) {
throw new CzgException("绑定失败该邀请人分销身份已被取消");
}
ShopUser parentShopUser = shopUserService.getById(parent.getId());
AssertUtil.isNull(parentShopUser, "邀请人不存在");
if (parentShopUser.getParentUserId() != null && parentShopUser.getParentUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
if (parentShopUser.getGradeUserId() != null && parentShopUser.getGradeUserId().equals(shopUser.getId())) {
throw new CzgException("存在绑定关系,不可绑定");
}
//更新自己的上级
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) {
//更新自己的下级 的上级的上级 为自己的上级
ShopUser upShopUser = new ShopUser();
upShopUser.setGradeUserId(shopUser.getParentUserId());
shopUserService.update(upShopUser, QueryWrapper.create().eq(ShopUser::getParentUserId, shopUser.getId()));
}
MkDistributionUser newDistributionUser = new MkDistributionUser();
newDistributionUser.setId(parent.getId());
newDistributionUser.setInviteCount(parent.getInviteCount() + 1);
MkDistributionConfig mkDistributionConfig = mkDistributionConfigService.getOne(QueryWrapper.create()
.eq(MkDistributionConfig::getShopId, parent.getShopId()));
if ("自主申请".equals(parent.getOpeningMethod()) && parent.getStatus() == 0 && mkDistributionConfig != null) {
if (newDistributionUser.getInviteCount() >= mkDistributionConfig.getInviteCount()) {
ShopUser parentShopUser1 = new ShopUser();
parentShopUser1.setId(parentShopUser.getId());
parentShopUser1.upDistributionShop(shopId, 1);
shopUserService.updateById(parentShopUser1);
}
}
if (mkDistributionConfig != null && !"not_upgrade".equals(mkDistributionConfig.getUpgradeType()) && parent.getIsAssignLevel() == 0) {
if ("invite".equals(mkDistributionConfig.getUpgradeType())) {
if (mkDistributionConfig.getInviteConsume() == 1) {
long count = orderInfoService.count(QueryWrapper.create()
.eq(OrderInfo::getUserId, shopUser.getUserId())
.eq(OrderInfo::getShopId, parent.getShopId())
.eq(OrderInfo::getStatus, OrderStatusEnums.DONE.getCode()));
if (count < 1) {
throw new CzgException("绑定失败,被邀请人需要成功支付一笔订单");
}
}
MkDistributionLevelConfig levelConfig = levelConfigService.getOne(QueryWrapper.create()
.eq(MkDistributionLevelConfig::getShopId, parent.getShopId())
.le(MkDistributionLevelConfig::getInviteCount, newDistributionUser.getInviteCount())
.orderBy(MkDistributionLevelConfig::getId).desc().limit(1));
if (levelConfig != null) {
newDistributionUser.setDistributionLevelId(levelConfig.getId());
newDistributionUser.setDistributionLevelName(levelConfig.getName());
newDistributionUser.setStatus(1);
}
} else if ("cost".equals(mkDistributionConfig.getUpgradeType())) {
costUpgradeLevel(parent.getId(), parent.getShopId());
}
}
update(newDistributionUser, QueryWrapper.create().eq(MkDistributionUser::getId, parent.getId())
.eq(MkDistributionUser::getShopId, parent.getShopId()));
}
@Override @Override
public void costUpgradeLevelBefore(Long userId, Long shopId) { public void costUpgradeLevelBefore(Long userId, Long shopId) {
ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId); ShopUser shopUser = shopUserService.getShopUserInfo(shopId, userId);
costUpgradeLevel(shopUser.getId(), shopId); costUpgradeLevel(shopUser.getId(), shopId);
ShopUserInvite shopUserInvite = shopUserInviteService.getOneByShopIdAndShopUserId(shopId, shopUser.getId()); if (shopUser.getParentUserId() != null) {
if (shopUserInvite != null && shopUserInvite.getDistributionUserId() != null) { costUpgradeLevel(shopUser.getParentUserId(), shopId);
costUpgradeLevel(shopUserInvite.getDistributionUserId(), shopId);
} }
} }
@@ -381,8 +467,10 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
.map(MkDistributionUserDTO::getId) .map(MkDistributionUserDTO::getId)
.filter(Objects::nonNull) .filter(Objects::nonNull)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
shopUserMap = shopUserService.list(QueryWrapper.create().in(ShopUser::getId, shopUserIds)) List<ShopUser> shopUserList = shopUserService.list(QueryWrapper.create().in(ShopUser::getId, shopUserIds));
.stream().collect(Collectors.toMap(ShopUser::getId, shopUser -> shopUser)); if (CollUtil.isNotEmpty(shopUserList)) {
shopUserMap = shopUserList.stream().collect(Collectors.toMap(ShopUser::getId, shopUser -> shopUser));
}
} }
for (MkDistributionUserDTO record : page.getRecords()) { for (MkDistributionUserDTO record : page.getRecords()) {
ShopUser shopUser = shopUserMap.get(record.getId()); ShopUser shopUser = shopUserMap.get(record.getId());
@@ -569,70 +657,40 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
@GlobalTransactional @GlobalTransactional
protected void deepReward(ShopUser orderSourceShopUser, MkDistributionLevelConfig parentLevel, MkDistributionConfigVO config, protected boolean deepReward(ShopUser orderSourceShopUser, BigDecimal commission, MkDistributionConfigVO config,
MkDistributionUser currentDistributionUser, BigDecimal amount, Long sourceId, String type, String orderNo, Integer currentLevel) { MkDistributionUser currentDistributionUser, BigDecimal amount, Long sourceId,
if (currentLevel > 2) { String type, String orderNo, Integer currentLevel) {
return;
}
// 当前分销员 // 当前分销员
AssertUtil.isNull(currentDistributionUser, "分销员不存在"); AssertUtil.isNull(currentDistributionUser, "分销员不存在");
AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启"); AssertUtil.isTrue(currentDistributionUser.getStatus() != 1, "分销员未开启");
if (commission.compareTo(BigDecimal.ZERO) <= 0) {
// ShopUser currentShopUser = shopUserService.getById(currentDistributionUser.getId()); return false;
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;
} }
// 金额
// 上上级分销员 BigDecimal rewardAmount = amount.multiply(commission.divide(BigDecimal.valueOf(100))).setScale(2, RoundingMode.FLOOR);
if (currentShopUser != null && currentShopUser.getDistributionUserId() != null) { if (rewardAmount.compareTo(new BigDecimal("0.01")) < 0) {
MkDistributionUser parent = getMkDistributionUserByIdAndShopId(currentShopUser.getDistributionUserId(), config.getShopId()); return false;
try {
deepReward(orderSourceShopUser, level, config, parent, amount, sourceId, type, orderNo, currentLevel + 1);
} catch (Exception e) {
log.warn("分销奖励失败: {}", e.getMessage());
}
} }
AssertUtil.isNull(level, "分销等级不存在");
log.info("当前分销员: {}, 上级分销员: {}, 分销等级: {}", currentDistributionUser.getId(), currentShopUser == null ? null : currentShopUser.getDistributionUserId(), level.getId());
if (config.getRewardCount() != null && config.getRewardCount() > 0) { if (config.getRewardCount() != null && config.getRewardCount() > 0) {
long count = distributionFlowService.count(new QueryWrapper() long count = distributionFlowService.count(new QueryWrapper()
.eq(MkDistributionFlow::getShopId, config.getShopId()).eq(MkDistributionFlow::getShopUserId, currentDistributionUser.getId())); .eq(MkDistributionFlow::getShopId, config.getShopId()).eq(MkDistributionFlow::getShopUserId, currentDistributionUser.getId()));
if (count >= config.getRewardCount()) { if (count >= config.getRewardCount()) {
log.info("分销员{}已达到奖励次数上限, 次数: {}", currentDistributionUser.getId(), config.getRewardCount()); log.info("分销员{}已达到奖励次数上限, 次数: {}", currentDistributionUser.getId(), config.getRewardCount());
return; return false;
} else {
log.info("分销员奖励次数: {}", count);
} }
} }
// 店铺信息
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(); LocalDateTime delayTime = config.getSettlementDay() == null || config.getSettlementDay() == 0 ? null : DateUtil.offsetDay(DateUtil.date(), config.getSettlementDay()).toLocalDateTime();
// 用户分账明细 // 用户分账明细
ShopUser shopUser = shopUserService.getById(currentDistributionUser.getId()); ShopUser shopUser = shopUserService.getById(currentDistributionUser.getId());
MkDistributionFlow mkDistributionFlow = new MkDistributionFlow().setShopUserId(currentDistributionUser.getId()) MkDistributionFlow mkDistributionFlow = new MkDistributionFlow().setShopUserId(currentDistributionUser.getId())
.setShopId(currentDistributionUser.getShopId()).setDistributionUserId(currentDistributionUser.getId()) .setShopId(currentDistributionUser.getShopId()).setDistributionUserId(currentDistributionUser.getId())
.setUserId(shopUser.getUserId()) .setUserId(shopUser.getUserId())
.setNickName(shopUser.getNickName()).setSourceShopUserId(orderSourceShopUser.getId()).setSourceNickName(orderSourceShopUser.getNickName()) .setNickName(shopUser.getNickName()).setSourceShopUserId(orderSourceShopUser.getId()).setSourceNickName(orderSourceShopUser.getNickName())
.setCommission(finalCommission).setParentCommission(parentLevel != null ? parentLevel.getLevelOneCommission() : null) .setCommission(commission)
.setLevelId(currentDistributionUser.getDistributionLevelId()).setLevel(currentLevel == 1 ? 1 : 2).setOrderNo(orderNo) .setLevelId(currentDistributionUser.getDistributionLevelId()).setLevel(currentLevel).setOrderNo(orderNo)
.setSourceId(sourceId).setAmount(amount).setType(type) .setSourceId(sourceId).setAmount(amount).setType(type)
.setRewardAmount(rewardAmount).setBillNo(IdUtil.simpleUUID()); .setRewardAmount(rewardAmount).setBillNo(IdUtil.simpleUUID());
@@ -655,6 +713,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
log.info("延时分销开始"); log.info("延时分销开始");
updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2); updateIncome(rewardAmount, BigDecimal.ZERO, BigDecimal.ZERO, currentDistributionUser.getId(), shopUser.getUserId(), shopUser.getId(), config.getShopId(), currentLevel == 1 ? 1 : 2);
} }
return true;
} }
@Override @Override
@@ -712,19 +771,24 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
AssertUtil.isTrue(amount.compareTo(BigDecimal.ZERO) == 0, "分销金额不能为0"); AssertUtil.isTrue(amount.compareTo(BigDecimal.ZERO) == 0, "分销金额不能为0");
MkDistributionConfigVO config = mkDistributionConfigService.detail(shopId); MkDistributionConfigVO config = mkDistributionConfigService.detail(shopId);
AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启"); AssertUtil.isTrue(config.getIsEnable() != 1, "分销未开启");
// 当前用户上级分销员 // 产生消费的用户
ShopUser sourceShopUserInfo = shopUserService.getShopUserInfo(shopId, sourceUserId); ShopUser curUser = shopUserService.getShopUserInfo(shopId, sourceUserId);
if (sourceShopUserInfo == null) { if (curUser == null || curUser.getParentUserId() == null) {
return; 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); log.info("开始分销, 当前来源用户: {}, shopId: {}, 邀请人id: {}", sourceUserId, shopId, curUser.getParentUserId());
deepReward(sourceShopUserInfo, null, config, distributionUser, amount, sourceId, type, orderNo, 1);
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); distributionDeliverService.save(deliver);
} }
@@ -732,7 +796,7 @@ public class MkDistributionUserServiceImpl extends ServiceImpl<MkDistributionUse
/** /**
* 分销金额修改 * 分销金额修改
* *
* @param pendingIncome 待入账金额 * @param pendingIncome 待入账金额
* @param receivedIncome 已入账 * @param receivedIncome 已入账
* @param withdrawIncome 已提现 * @param withdrawIncome 已提现
*/ */

View File

@@ -0,0 +1,128 @@
package com.czg.service.market.service.impl;
import cn.hutool.core.util.StrUtil;
import com.czg.market.dto.MkShopCouponGiftDTO;
import com.czg.market.dto.ShopCouponDTO;
import com.czg.market.entity.MkShopCouponRecord;
import com.czg.market.service.MkDistributionUserService;
import com.czg.market.service.MkShopCouponRecordService;
import com.czg.market.service.ShopCouponService;
import com.czg.utils.FunUtils;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MkShareBase;
import com.czg.market.service.MkShareBaseService;
import com.czg.service.market.mapper.MkShareBaseMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
/**
* 分享奖励基础配置 服务层实现。
*
* @author ww
* @since 2026-01-27
*/
@Service
public class MkShareBaseServiceImpl extends ServiceImpl<MkShareBaseMapper, MkShareBase> implements MkShareBaseService {
@Resource
private ShopCouponService shopCouponService;
@Resource
private MkDistributionUserService distributionUserService;
@Resource
private MkShopCouponRecordService mkShopCouponRecordService;
@Override
public MkShareBase getShareBase(Long shopId) {
MkShareBase shareBase = getById(shopId);
if (shareBase != null) {
if (shareBase.getSharerCouponId() != null) {
ShopCouponDTO sharerCoupon = shopCouponService.getCouponById(shareBase.getSharerCouponId());
if (sharerCoupon != null) {
shareBase.setSharerCouponName(sharerCoupon.getTitle());
shareBase.setSharerCoupon(sharerCoupon);
}
}
if (shareBase.getSharedUserCouponId() != null) {
ShopCouponDTO shareUserCoupon = shopCouponService.getCouponById(shareBase.getSharedUserCouponId());
if (shareUserCoupon != null) {
shareBase.setSharedUserCouponName(shareUserCoupon.getTitle());
}
}
}
return shareBase;
}
@Override
public void shareClaim(String tagType, Long shopId, Long fromUserId, Long toUserId) {
//获取邀请码
String inviteCode = null;
try {
inviteCode = distributionUserService.getInviteCode(shopId, fromUserId);
} catch (Exception _) {
}
//绑定上下级
if (StrUtil.isNotBlank(inviteCode)) {
FunUtils.asyncSafeRunVoid(() -> distributionUserService.bindInviteUser(fromUserId, toUserId, shopId));
}
MkShareBase shareBase = getById(shopId);
if (shareBase == null || shareBase.getIsEnabled().equals(1) || StrUtil.isBlank(shareBase.getRewardSharePages())) {
return;
}
if (!shareBase.getRewardSharePages().contains(tagType)) {
return;
}
FunUtils.safeRun(() -> {
//发放分享人优惠券
if (shareBase.getSharerCouponId() != null) {
boolean grant = true;
if (shareBase.getRewardTimesType().equals(1)) {
boolean exists = mkShopCouponRecordService.exists(query()
.eq(MkShopCouponRecord::getShopId, shopId)
.eq(MkShopCouponRecord::getShopUserId, fromUserId)
.eq(MkShopCouponRecord::getSource, "邀请获得"));
grant = !exists;
}
if (grant) {
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO();
giftDTO.setShopId(shopId)
.setSourceId(shareBase.getShopId())
.setSourceFlowId(toUserId)
.setShopUserId(fromUserId)
.setCouponId(shareBase.getSharerCouponId())
.setSource("邀请获得");
int receiveNum = 1;
if (shareBase.getSharerCouponNum() != null && shareBase.getSharerCouponNum() > 0) {
receiveNum = shareBase.getSharerCouponNum();
}
mkShopCouponRecordService.receiveCoupon(giftDTO, receiveNum, false);
}
}
return null;
}, "邀请人获取优惠券");
FunUtils.safeRun(() -> {
//发放被分享人优惠券
if (shareBase.getSharedUserCouponId() != null) {
boolean exists = mkShopCouponRecordService.exists(query()
.eq(MkShopCouponRecord::getShopId, shopId)
.eq(MkShopCouponRecord::getShopUserId, toUserId)
.eq(MkShopCouponRecord::getSourceFlowId, fromUserId)
.eq(MkShopCouponRecord::getSource, "参与分享获得"));
if (!exists) {
MkShopCouponGiftDTO giftDTO = new MkShopCouponGiftDTO();
giftDTO.setShopId(shopId)
.setSourceId(shareBase.getShopId())
.setShopUserId(toUserId)
.setSourceFlowId(fromUserId)
.setCouponId(shareBase.getSharedUserCouponId())
.setSource("参与分享获得");
int receiveNum = 1;
if (shareBase.getSharedUserCouponNum() != null && shareBase.getSharedUserCouponNum() > 0) {
receiveNum = shareBase.getSharedUserCouponNum();
}
mkShopCouponRecordService.receiveCoupon(giftDTO, receiveNum, false);
}
}
return null;
}, "被分享人获取优惠券");
}
}

View File

@@ -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));
}
}

View File

@@ -296,6 +296,7 @@ public class TbMemberConfigServiceImpl extends ServiceImpl<TbMemberConfigMapper,
} }
if (shopUser.getMemberLevelId() == null) { if (shopUser.getMemberLevelId() == null) {
log.warn("会员等级不存在, 店铺id: {}, 用户id: {}", shopUser.getMainShopId(), shopUser.getUserId()); log.warn("会员等级不存在, 店铺id: {}, 用户id: {}", shopUser.getMainShopId(), shopUser.getUserId());
return false;
} }
MemberConfigVO memberConfig = detail(shopUser.getMainShopId()); MemberConfigVO memberConfig = detail(shopUser.getMainShopId());
if (memberConfig == null) { if (memberConfig == null) {

View File

@@ -4,17 +4,15 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.czg.market.dto.MemberLevelDTO; 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.service.ShopCouponService;
import com.czg.market.vo.MemberLevelVO; import com.czg.market.vo.MemberLevelVO;
import com.czg.service.market.mapper.TbMemberLevelConfigMapper; import com.czg.service.market.mapper.TbMemberLevelConfigMapper;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MemberLevelConfig;
import com.czg.market.service.MemberLevelConfigService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -33,20 +31,16 @@ public class TbMemberLevelConfigServiceImpl extends ServiceImpl<TbMemberLevelCon
@Override @Override
public ArrayList<MemberLevelVO> listInfo(Long shopId) { public ArrayList<MemberLevelVO> listInfo(Long shopId) {
List<MemberLevelConfig> levelConfigs = list(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId)); List<MemberLevelConfig> levelConfigs = list(new QueryWrapper().eq(MemberLevelConfig::getShopId, shopId));
ArrayList<MemberLevelVO> memberLevelVOS = new ArrayList<>(); ArrayList<MemberLevelVO> memberLevels = new ArrayList<>();
levelConfigs.forEach(memberLevelConfig -> { levelConfigs.forEach(memberLevelConfig -> memberLevels.add(transVO(memberLevelConfig)));
memberLevelVOS.add(transVO(memberLevelConfig)); return memberLevels;
});
return memberLevelVOS;
} }
private MemberLevelVO transVO(MemberLevelConfig memberLevelConfig) { private MemberLevelVO transVO(MemberLevelConfig memberLevelConfig) {
MemberLevelVO levelVO = BeanUtil.copyProperties(memberLevelConfig, MemberLevelVO.class, "cycleRewardCouponList"); MemberLevelVO levelVO = BeanUtil.copyProperties(memberLevelConfig, MemberLevelVO.class, "cycleRewardCouponList");
if (StrUtil.isNotBlank(memberLevelConfig.getCycleRewardCouponList())) { if (StrUtil.isNotBlank(memberLevelConfig.getCycleRewardCouponList())) {
List<MemberLevelDTO.ConfigCoupon> coupons = JSONArray.parseArray(memberLevelConfig.getCycleRewardCouponList()).toList(MemberLevelDTO.ConfigCoupon.class); List<MemberLevelDTO.ConfigCoupon> coupons = JSONArray.parseArray(memberLevelConfig.getCycleRewardCouponList()).toList(MemberLevelDTO.ConfigCoupon.class);
coupons.forEach(item -> { coupons.forEach(item -> item.setCoupon(shopCouponService.getById(item.getCoupon().getId())));
item.setCoupon(shopCouponService.getById(item.getCoupon().getId()));
});
levelVO.setCycleRewardCouponList(coupons); levelVO.setCycleRewardCouponList(coupons);
} }
return levelVO; return levelVO;
@@ -54,6 +48,7 @@ public class TbMemberLevelConfigServiceImpl extends ServiceImpl<TbMemberLevelCon
@Override @Override
public MemberLevelVO detail(Long memberLevelId) { public MemberLevelVO detail(Long memberLevelId) {
MemberLevelConfig memberLevelConfig = getById(memberLevelId); MemberLevelConfig memberLevelConfig = getById(memberLevelId);
if (memberLevelConfig == null) { if (memberLevelConfig == null) {
return null; return null;

View File

@@ -1,18 +1,16 @@
package com.czg.service.market.service.impl; package com.czg.service.market.service.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.service.RedisService;
import com.czg.system.service.SysParamsService; import com.czg.system.service.SysParamsService;
import com.ijpay.core.kit.RsaKit; import com.ijpay.core.kit.RsaKit;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference; import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
@@ -27,38 +25,25 @@ public class WxServiceImpl extends BaseWx {
@DubboReference @DubboReference
private SysParamsService paramsService; 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() {
public WxServiceImpl(@Autowired RedisService redisService) {
this.redisService = redisService;
config = new Config(); config = new Config();
} }
@Override @Override
public String getAccessToken(boolean refresh) { public String getAccessToken(boolean refresh) {
init(); 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, String resp = HttpUtil.get(StrUtil.format("https://access-token.sxczgkj.com/accessToken?appId={}&appSecret={}", config.appId, config.appSecret));
Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret) if (StrUtil.isNotBlank(resp)) {
); JSONObject respInfo = JSONObject.parseObject(resp);
return respInfo.getString("accessToken");
log.info("获取access_token响应: {}", response); } else {
JSONObject jsonObject = JSONObject.parseObject(response); String response = HttpUtil.get(WX_ACCESS_TOKEN_URL,
String accessToken = jsonObject.getString("access_token"); Map.of("grant_type", "client_credential", "appid", config.appId, "secret", config.appSecret)
if (accessToken == null) { );
throw new RuntimeException("获取access_token失败"); 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 @Override

View File

@@ -2,6 +2,6 @@
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.czg.service.market.mapper.ShopUserInviteMapper"> <mapper namespace="com.czg.service.market.mapper.MkCarouselMapper">
</mapper> </mapper>

View File

@@ -0,0 +1,7 @@
<?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.MkDistributionGroupMapper">
</mapper>

View File

@@ -65,15 +65,13 @@
<select id="getOrderConsumeAmountByList" resultType="java.math.BigDecimal"> <select id="getOrderConsumeAmountByList" resultType="java.math.BigDecimal">
SELECT IFNULL(SUM(ord.pay_amount), 0) AS totalAmount SELECT IFNULL(SUM(ord.pay_amount), 0) AS totalAmount
FROM tb_shop_user_invite invite FROM tb_shop_user invite
INNER JOIN tb_shop_user su on invite.shop_user_id = su.id INNER JOIN tb_order_info ord ON invite.user_id = ord.user_id
INNER JOIN tb_order_info ord ON su.user_id = ord.user_id
and invite.shop_id = #{shopId}
AND ord.shop_id = #{shopId} AND ord.shop_id = #{shopId}
AND ord.STATUS = 'done' AND ord.STATUS = 'done'
AND ord.pay_type NOT IN ('vip_pay', 'credit_pay') AND ord.pay_type NOT IN ('vip_pay', 'credit_pay')
AND ord.paid_time >= invite.invite_time AND ord.paid_time >= invite.invite_time
WHERE invite.distribution_user_id = #{inviterId} WHERE invite.parent_user_id = #{inviterId}
</select> </select>
<select id="getOrderConsumeAmountById" resultType="java.math.BigDecimal"> <select id="getOrderConsumeAmountById" resultType="java.math.BigDecimal">

View File

@@ -0,0 +1,7 @@
<?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.MkShareBaseMapper">
</mapper>

View File

@@ -1,13 +1,13 @@
package com.czg.service.order.service.impl; package com.czg.service.order.service.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.czg.PayCst;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
import com.czg.account.entity.UserInfo; import com.czg.account.entity.UserInfo;
import com.czg.account.service.ShopUserService; import com.czg.account.service.ShopUserService;
import com.czg.account.service.UserInfoService; import com.czg.account.service.UserInfoService;
import com.czg.constant.TableValueConstant; import com.czg.constant.TableValueConstant;
import com.czg.constants.PayTypeConstants; import com.czg.constants.PayTypeConstants;
import com.czg.constants.SystemConstants;
import com.czg.enums.CzgPayEnum; import com.czg.enums.CzgPayEnum;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.market.service.MkDistributionConfigService; import com.czg.market.service.MkDistributionConfigService;
@@ -83,7 +83,7 @@ public class DistributionPayServiceImpl implements DistributionPayService {
} else { } else {
UserInfo userInfo = userInfoService.getById(userId); UserInfo userInfo = userInfoService.getById(userId);
initInfo.setPayment(orderPayment).setShopUser(shopUserInfo) 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; return initInfo;
} }

View File

@@ -327,7 +327,7 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
//发送打票信息 后付费推送多次 需要处理 //发送打票信息 后付费推送多次 需要处理
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成 //orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0" //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 { } else {
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId(), "", 60 * 15); 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"); 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())) { } else if (PayTypeConstants.SourceType.FREE.equals(payment.getSourceType())) {
boolean isFree = 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()); ShopUser shopUser = shopUserService.getById(payment.getSourceId());
OrderInfo orderInfo;
if (shopUser == null) { if (shopUser == null) {
log.error("会员充值失败会员不存在会员id{}", payment.getSourceId()); log.error("会员充值失败会员不存在会员id{}", payment.getSourceId());
} else { } else {
@@ -1081,42 +1098,22 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
} else { } else {
bizEnum = ShopUserFlowBizEnum.CASH_IN; bizEnum = ShopUserFlowBizEnum.CASH_IN;
} }
if (isFree) { //充值并支付 ↓
orderInfo = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo::getId, payment.getRelatedId())); OrderInfo orderInfo = orderInfoService.getOne(new QueryWrapper()
if (orderInfo == null) { .eq(OrderInfo::getPayOrderId, payment.getId())
log.error("霸王餐支付订单不存在支付记录Id,{}", payment.getId()); .eq(OrderInfo::getPayType, PayEnums.VIP_PAY.getValue()));
} else { if (orderInfo != null) {
//增加余额 ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO() .setId(shopUser.getId()).setType(0)
.setId(shopUser.getId()) .setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
.setType(1) .setRelationId(orderInfo.getId())
.setBizEnum(ShopUserFlowBizEnum.FREE_IN) .setMoney(orderInfo.getOrderAmount());
.setRelationId(orderInfo.getId()) shopUserService.updateMoney(shopUserMoneyEditDTO);
.setMoney(BigDecimal.valueOf(notifyRespDTO.getAmount()).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN)); upOrderInfo(orderInfo, orderInfo.getOrderAmount(), LocalDateTime.now(), null, PayEnums.VIP_PAY);
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);
} }
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())) { } else if (PayTypeConstants.SourceType.MEMBER_PAY.equals(payment.getSourceType())) {
//购买会员 //购买会员
@@ -1182,6 +1179,10 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
@Override @Override
@Transactional @Transactional
public void upOrderInfo(OrderInfo orderInfo, BigDecimal payAmount, LocalDateTime payTime, Long payOrderId, PayEnums payType) { 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() OrderInfo upOrderInfo = new OrderInfo()
.setId(orderInfo.getId()) .setId(orderInfo.getId())
.setPayAmount(payAmount) .setPayAmount(payAmount)
@@ -1223,16 +1224,20 @@ public class OrderInfoCustomServiceImpl implements OrderInfoCustomService {
if (StrUtil.isNotBlank(orderInfo.getTableCode())) { if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
ThreadUtil.execAsync(() -> exTable(orderInfo)); ThreadUtil.execAsync(() -> exTable(orderInfo));
} }
// 事务成功提交后执行消息发送 if (payType != PayEnums.BACK_SCAN) {
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1"; // 事务成功提交后执行消息发送
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint); String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint, "事务环境打印");
}
// log.info("订单{}事务提交后,发送打印消息", orderId); // log.info("订单{}事务提交后,发送打印消息", orderId);
} }
}); });
} else { } else {
// 非事务环境下直接发送(兼容无事务场景) if (payType != PayEnums.BACK_SCAN) {
String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1"; // 非事务环境下直接发送(兼容无事务场景)
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint); String printParam = orderId + "_" + (!"after-pay".equals(payMode) ? 1 : 0) + "_1";
rabbitPublisher.sendOrderPrintMsg(printParam, isPrint, "非事务环境打印");
}
// log.info("非事务环境下,直接发送订单{}打印消息", orderId); // log.info("非事务环境下,直接发送订单{}打印消息", orderId);
} }
rabbitPublisher.sendOrderDetailStatusMsg(orderInfo.getShopId().toString(), "bc"); rabbitPublisher.sendOrderDetailStatusMsg(orderInfo.getShopId().toString(), "bc");

View File

@@ -2,11 +2,13 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5; import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.PayCst;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.ShopInfo; import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopUser; import com.czg.account.entity.ShopUser;
@@ -113,7 +115,8 @@ public class OrderPayServiceImpl implements OrderPayService {
//发送打票信息 //发送打票信息
//orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成 //orderId_0_0 订单ID_先付后付(1先付0后付)_订单状态 0未完成 1完成
//orderInfo.getId() + "_" + (!"after-pay".equals(orderInfo.getPayMode()) ? 1 : 0) + "_0" //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()); redisService.del(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId());
throw new PaySuccessException("支付成功"); throw new PaySuccessException("支付成功");
} }
@@ -240,7 +243,7 @@ public class OrderPayServiceImpl implements OrderPayService {
CzgPayBaseReq.ltPayReq( CzgPayBaseReq.ltPayReq(
payOrderNo, "充值并支付", payOrderNo, "充值并支付",
rechargeDetail.getAmount().multiply(PayService.MONEY_RATE).longValue(), payParam.getPayType(), 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 @Override
@@ -263,7 +266,7 @@ public class OrderPayServiceImpl implements OrderPayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空"); AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake(); String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), "")); 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()); payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY, return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), 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(); String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), "")); 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()); payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY, return payService.pay(payParam.getShopId(), CzgPayEnum.JS_PAY,
CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), CzgPayBaseReq.jsPayReq(payOrderNo, "扫码支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
@@ -302,7 +305,7 @@ public class OrderPayServiceImpl implements OrderPayService {
AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空"); AssertUtil.isBlank(payParam.getOpenId(), "用户小程序ID不能为空");
String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake(); String payOrderNo = orderInfo.getPlatformType() + CzgRandomUtils.snowflake();
Long paymentId = payService.initPayment(OrderPayment.orderPay(payParam.getShopId(), orderInfo.getId(), payOrderNo, orderInfo.getOrderAmount(), "")); 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()); payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY, return payService.pay(payParam.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(), CzgPayBaseReq.ltPayReq(payOrderNo, "点餐支付", orderInfo.getOrderAmount().multiply(PayService.MONEY_RATE).longValue(),
@@ -354,6 +357,9 @@ public class OrderPayServiceImpl implements OrderPayService {
if (mapCzgResult.getCode() == 200) { if (mapCzgResult.getCode() == 200) {
orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(), orderInfoCustomService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
LocalDateTime.now(), paymentId, PayEnums.BACK_SCAN); 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 { } else {
upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId, upOrderPayInfo(orderInfo.getId(), PayEnums.BACK_SCAN, paymentId,
payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark()); payParam.getCheckOrderPay() == null ? null : payParam.getCheckOrderPay().getRemark());
@@ -522,12 +528,11 @@ public class OrderPayServiceImpl implements OrderPayService {
} }
throw new CzgException(refund.getMsg()); throw new CzgException(refund.getMsg());
} else { } else {
paymentService.updateChain() OrderPayment upPayment = new OrderPayment();
.eq(OrderPayment::getId, refundId) upPayment.setPayTime(LocalDateTimeUtil.parse(refund.getData().getRefundTime()));
.set(OrderPayment::getPayTime, refund.getData().getRefundTime()) upPayment.setTradeNumber(refund.getData().getThirdRefundNo());
.set(OrderPayment::getTradeNumber, refund.getData().getThirdRefundNo()) upPayment.setRespJson(refund.getData().getOriginalData());
.set(OrderPayment::getRespJson, refund.getData().getOriginalData()) paymentService.update(upPayment, new QueryWrapper().eq(OrderPayment::getId, refundId));
.update();
} }
} }

View File

@@ -6,10 +6,10 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.PayAdapter; import com.czg.PayAdapter;
import com.czg.PayAdapterFactory; import com.czg.PayAdapterFactory;
import com.czg.PayCst;
import com.czg.constant.PayChannelCst; import com.czg.constant.PayChannelCst;
import com.czg.constants.ParamCodeCst; import com.czg.constants.ParamCodeCst;
import com.czg.constants.PayTypeConstants; import com.czg.constants.PayTypeConstants;
import com.czg.constants.SystemConstants;
import com.czg.enums.CzgPayEnum; import com.czg.enums.CzgPayEnum;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.order.dto.LtPayOtherDTO; import com.czg.order.dto.LtPayOtherDTO;
@@ -64,10 +64,13 @@ public class PayServiceImpl implements PayService {
} else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) { } else if (shopMerchant.getChannel().equals(PayChannelCst.POLY)) {
payData = shopMerchant.getPolyPayJson(); payData = shopMerchant.getPolyPayJson();
} }
bizData.setSubAppid(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? shopMerchant.getAlipayAppId() : shopMerchant.getWechatAppId());
if (payType.equals(CzgPayEnum.MICRO_PAY)) { if (payType.equals(CzgPayEnum.MICRO_PAY)) {
checkMicroPay(bizData, shopMerchant); 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); return adapter.pay(payType, payData, getDomain(), getNotifyUrl(shopMerchant.getChannel()), bizData);
} }
@@ -78,7 +81,7 @@ public class PayServiceImpl implements PayService {
AssertUtil.isBlank(param.getPayType(), "支付方式不能为空"); AssertUtil.isBlank(param.getPayType(), "支付方式不能为空");
String payOrderNo = "LT" + IdUtil.getSnowflakeNextId(); String payOrderNo = "LT" + IdUtil.getSnowflakeNextId();
initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo, initPayment(OrderPayment.pay(param.getShopId(), param.getRecordId(), payType, payOrderNo,
param.getPrice(), "", null)); param.getPrice(), "", param.getRelatedId()));
return pay(param.getShopId(), CzgPayEnum.LT_PAY, return pay(param.getShopId(), CzgPayEnum.LT_PAY,
CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(), CzgPayBaseReq.ltPayReq(payOrderNo, detail, param.getPrice().multiply(MONEY_RATE).longValue(),
param.getPayType(), param.getOpenId(), param.getIp())); param.getPayType(), param.getOpenId(), param.getIp()));
@@ -229,11 +232,11 @@ public class PayServiceImpl implements PayService {
if (firstTwoDigits >= 10 && firstTwoDigits <= 15) { if (firstTwoDigits >= 10 && firstTwoDigits <= 15) {
//微信支付 //微信支付
bizData.setSubAppid(shopMerchant.getWechatAppId()); bizData.setSubAppid(shopMerchant.getWechatAppId());
bizData.setPayType(SystemConstants.PayType.WECHAT); bizData.setPayType(PayCst.Type.WECHAT);
} else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) { } else if (firstTwoDigits >= 25 && firstTwoDigits <= 30) {
//支付宝支付 //支付宝支付
bizData.setSubAppid(shopMerchant.getAlipayAppId()); bizData.setSubAppid(shopMerchant.getAlipayAppId());
bizData.setPayType(SystemConstants.PayType.ALIPAY); bizData.setPayType(PayCst.Type.ALIPAY);
} else { } else {
throw new CzgException("扫描码非法或暂不支持"); throw new CzgException("扫描码非法或暂不支持");
} }

View File

@@ -14,7 +14,6 @@ import com.czg.pay.PolyMerchantDTO;
import com.czg.service.order.mapper.ShopMerchantMapper; import com.czg.service.order.mapper.ShopMerchantMapper;
import com.czg.service.order.service.ShopDirectMerchantService; import com.czg.service.order.service.ShopDirectMerchantService;
import com.czg.utils.AssertUtil; import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotBlank; 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())); ShopMerchant shopMerchant = getOne(query().eq(ShopMerchant::getShopId, shopMerchantParam.getShopId()));
if (shopMerchant == null) { if (shopMerchant == null) {
shopMerchant = new ShopMerchant(); shopMerchant = new ShopMerchant();
shopMerchant.setAlipayAppId(SystemConstants.PayType.ALIPAY_APP_ID); shopMerchant.setAlipayAppId(SystemConstants.PayAppId.ALIPAY_APP_ID);
shopMerchant.setWechatAppId(SystemConstants.PayType.WECHAT_APP_ID); shopMerchant.setWechatAppId(SystemConstants.PayAppId.WECHAT_APP_ID);
shopMerchant.setRelatedId(shopMerchantParam.getShopId()); shopMerchant.setRelatedId(shopMerchantParam.getShopId());
} }
shopMerchant.setShopId(shopMerchantParam.getShopId()); shopMerchant.setShopId(shopMerchantParam.getShopId());
if (isUp) { if (isUp) {
shopMerchant.setChannel(CzgStrUtils.getStrOrNull(shopMerchantParam.getChannel())); if (StrUtil.isNotBlank(shopMerchantParam.getChannel())) {
shopMerchant.setChannel(shopMerchantParam.getChannel());
}
shopMerchant.setRelatedId(shopMerchantParam.getRelatedId()); shopMerchant.setRelatedId(shopMerchantParam.getRelatedId());
if (shopMerchantParam.getRelatedId() == null || !shopMerchantParam.getRelatedId().equals(shopMerchant.getRelatedId())) { if (shopMerchant.getRelatedId() != null && !shopMerchantParam.getRelatedId().equals(shopMerchant.getRelatedId())) {
ShopDirectMerchant shopDirectMerchant = shopDirectMerchantService.getById(shopMerchantParam.getRelatedId()); ShopDirectMerchant shopDirectMerchant = shopDirectMerchantService.getById(shopMerchant.getRelatedId());
if (shopDirectMerchant != null) { if (shopDirectMerchant != null) {
NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO(); NativeMerchantDTO nativeMerchantDTO = new NativeMerchantDTO();
nativeMerchantDTO.setWechatMerchantId(shopDirectMerchant.getWechatMerchantId()); nativeMerchantDTO.setWechatMerchantId(shopDirectMerchant.getWechatMerchantId());

View File

@@ -2,6 +2,7 @@ package com.czg.service.order.service.impl;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.SecureUtil;
import com.czg.PayCst;
import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO; import com.czg.account.dto.shopuser.ShopUserMoneyEditDTO;
import com.czg.account.entity.*; import com.czg.account.entity.*;
import com.czg.account.service.*; import com.czg.account.service.*;
@@ -158,6 +159,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
.setRecordId(shopUser.getId()) .setRecordId(shopUser.getId())
.setPrice(memberOrder.getAmount()) .setPrice(memberOrder.getAmount())
.setIp(clientIp); .setIp(clientIp);
payParam1.setRelatedId(memberOrder.getId());
return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值"); return payService.ltPayOther(payParam1, PayTypeConstants.SourceType.MEMBER_PAY, "会员充值");
} }
@@ -189,6 +191,7 @@ public class ShopUserServiceImpl implements ShopUserPayService {
.setRecordId(shopUser.getId()) .setRecordId(shopUser.getId())
.setPrice(payParam.getAmount()) .setPrice(payParam.getAmount())
.setIp(clintIp); .setIp(clintIp);
payParam1.setRelatedId(isFree ? payParam.getOrderId() : payParam.getRechargeDetailId());
return payService.ltPayOther(payParam1, payType, "会员充值"); return payService.ltPayOther(payParam1, payType, "会员充值");
} }
@@ -209,12 +212,13 @@ public class ShopUserServiceImpl implements ShopUserPayService {
String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN; String payType = isFree ? PayTypeConstants.SourceType.FREE : PayTypeConstants.SourceType.MEMBER_IN;
LtPayOtherDTO payParam = new LtPayOtherDTO() 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()) .setPayType(rechargeDTO.getPayType())
.setShopId(rechargeDTO.getShopId()) .setShopId(rechargeDTO.getShopId())
.setRecordId(shopUser.getId()) .setRecordId(shopUser.getId())
.setPrice(amount) .setPrice(amount)
.setIp(clientIp); .setIp(clientIp);
payParam.setRelatedId(isFree ? rechargeDTO.getOrderId() : rechargeDTO.getRechargeDetailId());
return payService.ltPayOther(payParam, payType, "会员充值"); return payService.ltPayOther(payParam, payType, "会员充值");
} }

View File

@@ -2,9 +2,9 @@ package com.czg.impl;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.czg.PayAdapter; import com.czg.PayAdapter;
import com.czg.PayCst;
import com.czg.PolyPayUtils; import com.czg.PolyPayUtils;
import com.czg.constant.PayChannelCst; import com.czg.constant.PayChannelCst;
import com.czg.constants.SystemConstants;
import com.czg.entity.resp.CzgBaseResp; import com.czg.entity.resp.CzgBaseResp;
import com.czg.entity.resp.CzgRefundResp; import com.czg.entity.resp.CzgRefundResp;
import com.czg.enums.CzgPayEnum; 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) { private CzgResult<Map<String, Object>> jsPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq bizData) {
AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序"); AssertUtil.isBlank(bizData.getSubAppid(), "暂不可用,请联系商家配置" + (PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? "支付宝" : "微信") + "小程序");
bizData.setPayType(SystemConstants.PayType.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT"); bizData.setPayType(PayCst.Type.ALIPAY.equals(bizData.getPayType()) ? "ALIPAY" : "WECHAT");
bizData.polyBase(shopMerchant.getStoreId(), notifyUrl); bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
return PolyPayUtils.jsPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); return PolyPayUtils.jsPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
} }
private CzgResult<Map<String, Object>> ltPay(PolyMerchantDTO shopMerchant, String domain, String notifyUrl, CzgPayBaseReq 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); bizData.polyBase(shopMerchant.getStoreId(), notifyUrl);
return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData); return PolyPayUtils.ltPay(domain, shopMerchant.getAppId(), shopMerchant.getAppSecret(), bizData);
} }

View File

@@ -53,18 +53,6 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
@Resource @Resource
private WxAccountUtil wxAccountUtil; 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ConsInOutStockHeadParam inStock(ConsInOutStockHeadParam param) { public ConsInOutStockHeadParam inStock(ConsInOutStockHeadParam param) {
@@ -72,7 +60,6 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
Long createUserId = StpKit.USER.getLoginIdAsLong(); Long createUserId = StpKit.USER.getLoginIdAsLong();
String createUserName = StpKit.USER.getAccount(); String createUserName = StpKit.USER.getAccount();
ConsStockFlow head = BeanUtil.copyProperties(param, ConsStockFlow.class); ConsStockFlow head = BeanUtil.copyProperties(param, ConsStockFlow.class);
List<ConsStockFlow> entityList = BeanUtil.copyToList(param.getBodyList(), ConsStockFlow.class);
List<ConsStockFlow> insertList = new ArrayList<>(); List<ConsStockFlow> insertList = new ArrayList<>();
List<ConsInfo> updateStockList = new ArrayList<>(); List<ConsInfo> updateStockList = new ArrayList<>();
for (ConsInOutStockBodyParam entity : param.getBodyList()) { for (ConsInOutStockBodyParam entity : param.getBodyList()) {
@@ -251,15 +238,7 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
Long shopId = entity.getShopId(); Long shopId = entity.getShopId();
BigDecimal afterNumber = entity.getAfterNumber(); BigDecimal afterNumber = entity.getAfterNumber();
ConsInfo consInfo = consInfoMapper.selectOneById(entity.getConId()); ConsInfo consInfo = consInfoMapper.selectOneById(entity.getConId());
String shopName = ""; String shopName = productMapper.getShopName(shopId);
try {
shopName = StpKit.USER.getShopName();
} catch (Exception e) {
log.error("获取店铺名称失败");
}
if (StrUtil.isEmpty(shopName)) {
shopName = productMapper.getShopName(shopId);
}
BigDecimal conWarning = consInfo.getConWarning(); BigDecimal conWarning = consInfo.getConWarning();
// 库存小于警告值,发送消息提醒 // 库存小于警告值,发送消息提醒
if (NumberUtil.isLess(afterNumber, conWarning)) { if (NumberUtil.isLess(afterNumber, conWarning)) {
@@ -268,12 +247,8 @@ public class ConsStockFlowServiceImpl extends ServiceImpl<ConsStockFlowMapper, C
return; return;
} }
String conName = StrUtil.format("{}数量<预警值{}", consInfo.getConName(), conWarning); String conName = StrUtil.format("{}数量<预警值{}", consInfo.getConName(), conWarning);
String finalShopName = shopName; ThreadUtil.execAsync(() -> openIdList.parallelStream().forEach(openId ->
ThreadUtil.execAsync(() -> { wxAccountUtil.sendStockMsg("耗材库存预警", shopName, conName, afterNumber, openId)));
openIdList.parallelStream().forEach(openId -> {
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
});
});
} }
} }
} }

View File

@@ -5,11 +5,14 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.write.handler.SheetWriteHandler;
import com.alibaba.excel.write.merge.OnceAbsoluteMergeStrategy;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.JSONWriter;
import com.czg.constant.CacheConstant; import com.czg.constant.CacheConstant;
import com.czg.constants.SystemConstants; import com.czg.constants.SystemConstants;
import com.czg.excel.ExcelExportUtil;
import com.czg.exception.CzgException; import com.czg.exception.CzgException;
import com.czg.product.dto.*; import com.czg.product.dto.*;
import com.czg.product.entity.*; import com.czg.product.entity.*;
@@ -30,6 +33,7 @@ import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl; import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
@@ -65,7 +69,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
private final ProdSkuMapper prodSkuMapper; private final ProdSkuMapper prodSkuMapper;
private final ProdConsRelationMapper prodConsRelationMapper; private final ProdConsRelationMapper prodConsRelationMapper;
private final ConsInfoMapper consInfoMapper; private final ConsInfoMapper consInfoMapper;
private final ConsStockFlowMapper consStockFlowMapper;
private final ProductStockFlowMapper productStockFlowMapper; private final ProductStockFlowMapper productStockFlowMapper;
private final ProductStockFlowService productStockFlowService; private final ProductStockFlowService productStockFlowService;
private final ConsStockFlowService consStockFlowService; private final ConsStockFlowService consStockFlowService;
@@ -175,6 +178,57 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
return records; return records;
} }
@Override
public void exportProductList(ProductDTO param, HttpServletResponse response) {
QueryWrapper queryWrapper = buildFullQueryWrapper(param);
List<ProductDTO> records = super.listAs(queryWrapper, ProductDTO.class);
buildProductExtInfo(records);
List<SheetWriteHandler> handlers = new ArrayList<>();
List<ProductExportDTO> dataList = new ArrayList<>();
records.forEach(exportDTO -> {
int first = dataList.size() + 1;
if (exportDTO.getSkuList() != null && !exportDTO.getSkuList().isEmpty()) {
exportDTO.getSkuList().forEach(sku -> {
ProductExportDTO dto = new ProductExportDTO();
BeanUtil.copyProperties(exportDTO, dto);
dto.setSpecFullName(sku.getSpecInfo());
dto.setPrice(sku.getSalePrice());
dto.setMemberPrice(sku.getMemberPrice());
dto.setIsSale(sku.getIsGrounding());
dto.setBarCode(sku.getBarCode());
dataList.add(dto);
});
if (exportDTO.getSkuList().size() > 1) {
OnceAbsoluteMergeStrategy name = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 0, 0);
handlers.add(name);
OnceAbsoluteMergeStrategy category = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 1, 1);
handlers.add(category);
OnceAbsoluteMergeStrategy unit = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 6, 6);
handlers.add(unit);
OnceAbsoluteMergeStrategy type = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 7, 7);
handlers.add(type);
OnceAbsoluteMergeStrategy groupType = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 8, 8);
handlers.add(groupType);
OnceAbsoluteMergeStrategy startTime = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 9, 9);
handlers.add(startTime);
OnceAbsoluteMergeStrategy endTime = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 10, 10);
handlers.add(endTime);
OnceAbsoluteMergeStrategy stockNumber = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 11, 11);
handlers.add(stockNumber);
OnceAbsoluteMergeStrategy createTime = new OnceAbsoluteMergeStrategy(first, first + exportDTO.getSkuList().size() - 1, 12, 12);
handlers.add(createTime);
}
} else {
dataList.add(BeanUtil.copyProperties(exportDTO, ProductExportDTO.class));
}
});
ExcelExportUtil.exportProductWithMergeToResponse(dataList, ProductExportDTO.class, "商品列表", response, handlers);
}
@Override @Override
public List<ProductDTO> getProductCacheList(ProductDTO param) { public List<ProductDTO> getProductCacheList(ProductDTO param) {
Long shopId = param.getShopId(); Long shopId = param.getShopId();
@@ -555,7 +609,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
String type = param.getType(); String type = param.getType();
Long id = param.getId(); Long id = param.getId();
Integer isSale = param.getIsSale(); Integer isSale = param.getIsSale();
String sensitiveOperation = ""; String sensitiveOperation;
if (isSale == 1) { if (isSale == 1) {
sensitiveOperation = "上架"; sensitiveOperation = "上架";
} else { } else {
@@ -668,7 +722,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override @Override
public void stockWarning(Integer warnLine) { public void stockWarning(Integer warnLine) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
UpdateChain.of(Product.class) UpdateChain.of(Product.class)
.set(Product::getWarnLine, warnLine) .set(Product::getWarnLine, warnLine)
.eq(Product::getShopId, shopId) .eq(Product::getShopId, shopId)
@@ -678,7 +732,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void reportDamage(ProductReportDamageParam param) { public void reportDamage(ProductReportDamageParam param) {
Long shopId = StpKit.USER.getShopId(0L); Long shopId = StpKit.USER.getShopId();
Long createUserId = StpKit.USER.getLoginIdAsLong(); Long createUserId = StpKit.USER.getLoginIdAsLong();
String createUserName = StpKit.USER.getAccount(); String createUserName = StpKit.USER.getAccount();
Product product = mapper.selectOneById(param.getProductId()); Product product = mapper.selectOneById(param.getProductId());

View File

@@ -53,12 +53,8 @@ public class ProductStockFlowServiceImpl extends ServiceImpl<ProductStockFlowMap
} }
String productName = StrUtil.sub(product.getName(), 0, 10).concat("..."); String productName = StrUtil.sub(product.getName(), 0, 10).concat("...");
String conName = StrUtil.format("{}数量<预警值{}", productName, warnLine); String conName = StrUtil.format("{}数量<预警值{}", productName, warnLine);
String finalShopName = shopName; ThreadUtil.execAsync(() -> openIdList.parallelStream().forEach(openId ->
ThreadUtil.execAsync(() -> { wxAccountUtil.sendStockMsg("商品库存预警", shopName, conName, afterNumber, openId)));
openIdList.parallelStream().forEach(openId -> {
wxAccountUtil.sendStockMsg(finalShopName, conName, afterNumber, openId);
});
});
} }
} }
} }

View File

@@ -1,22 +1,18 @@
package com.czg.service.product.util; package com.czg.service.product.util;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.czg.service.RedisService; import com.czg.exception.CzgException;
import jakarta.annotation.Resource;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -32,6 +28,7 @@ import java.util.Map;
@Component @Component
public class WxAccountUtil { public class WxAccountUtil {
//银收客公众号推送
@Value("${wx.ysk.appId}") @Value("${wx.ysk.appId}")
private String appId = "wx212769170d2c6b2a"; private String appId = "wx212769170d2c6b2a";
@Value("${wx.ysk.secrete}") @Value("${wx.ysk.secrete}")
@@ -41,9 +38,6 @@ public class WxAccountUtil {
@Value("${wx.ysk.warnMsgTmpId}") @Value("${wx.ysk.warnMsgTmpId}")
private String warnMsgTmpId; private String warnMsgTmpId;
@Resource
@Lazy
private RedisService redisService;
static LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>(); static LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
@@ -59,84 +53,100 @@ public class WxAccountUtil {
linkedHashMap.put("47003", "参数错误"); 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) { public void sendOperationMsg(List<String> openIdList, String userName, String operationDesc) {
openIdList.forEach(openId -> { openIdList.forEach(openId -> {
Map<String, Object> data = new HashMap<String, Object>() {{ Map<String, Object> data = Map.of(
put("thing19", new HashMap<String, Object>() {{ "thing19", Map.of("value", userName),
put("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"))
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);
try { try {
sendTemplateMsg(operationMsgTmpId, openId, data); sendTemplateMsg("敏感操作", operationMsgTmpId, openId, data);
} catch (Exception e) { } catch (Exception e) {
log.error("发送失败, openId: {}, 响应: {}", openId, e.getMessage()); 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(); String stockNumStr = stockNum.toPlainString();
Map<String, Object> data = new HashMap<String, Object>() {{ Map<String, Object> data = Map.of(
put("thing22", new HashMap<String, Object>() {{ //品名
put("value", shopName); "thing34", Map.of("value", typeName),
}}); //商品名称
put("thing4", new HashMap<String, Object>() {{ "thing4", Map.of("value", productName),
put("value", productName); //商品数量
}}); "number5", Map.of("value", stockNumStr),
put("number5", new HashMap<String, Object>() {{ //商家名称
put("value", stockNumStr); "thing22", Map.of("value", shopName)
}}); );
}};
log.info("开始发送库存预警消息, 接收用户openId: {}, 消息数据: {}", openId, data);
try { try {
sendTemplateMsg(warnMsgTmpId, openId, data); sendTemplateMsg("库存预警", warnMsgTmpId, openId, data);
} catch (Exception e) { } catch (Exception e) {
log.error("发送失败, openId:{}, msg: {}", openId, e.getMessage()); 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);
// }
} }

View File

@@ -149,7 +149,7 @@
and t1.shop_id = #{shopId} and t1.shop_id = #{shopId}
</where> </where>
<if test="idList != null"> <if test="idList != null">
and t1.id in and (t1.id in
<foreach item="item" collection="idList" separator="," open="(" close=")"> <foreach item="item" collection="idList" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
@@ -157,6 +157,7 @@
<foreach item="item" collection="idList" separator="," open="(" close=")"> <foreach item="item" collection="idList" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
)
</if> </if>
order by t1.sort desc,t1.id desc order by t1.sort desc,t1.id desc
</select> </select>

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