ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppBaseDto.java
@@ -16,4 +16,9 @@ @ApiModelProperty(value = "userId",hidden = true) private Long userId; @ApiModelProperty(value = "openid", hidden = true) private String openid; @ApiModelProperty(value = "终端IP", hidden = true) private String spbillCreateIp; } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/shop/ShopProportionVo.java
New file @@ -0,0 +1,4 @@ package com.ruoyi.system.api.domain.poji.shop; public class ShopProportionVo { } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/factory/RemoteShopFallbackFactory.java
@@ -2,6 +2,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.system.api.domain.dto.*; import com.ruoyi.system.api.domain.poji.shop.ShopProportionVo; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.model.QwH5LoginVo; import com.ruoyi.system.api.model.QwUserDetailDto; @@ -33,6 +34,11 @@ @Override public R<Shop> getShop(Long shopId) { return R.fail("获取商户失败:" + throwable.getMessage()); } @Override public R<String> getShopSubMchId(Long shopId) { return R.fail("获取微信商户号失败:" + throwable.getMessage()); } @Override @@ -109,6 +115,11 @@ public R editMgtShopStaff(MgtShopStaffEditDto mgtShopStaffEditDto) { return R.fail("修改员工失败:" + throwable.getMessage()); } @Override public R<ShopProportionVo> getShopProportion(Long shopId) { return R.fail("获取商户分成信息失败:" + throwable.getMessage()); } }; } } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/service/RemoteShopService.java
@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.system.api.domain.dto.*; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.poji.shop.ShopProportionVo; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.factory.RemoteShopFallbackFactory; import com.ruoyi.system.api.model.QwH5LoginVo; @@ -19,6 +20,10 @@ @PostMapping("/shop/getShop") public R<Shop> getShop(@RequestBody Long shopId); @PostMapping("/shop/getShopSubMchId") public R<String> getShopSubMchId(@RequestBody Long shopId); @PostMapping("/shop/getShopByUserId") public R<ShopRelUserVo> getShopByUserId(@RequestBody Long userId); @@ -149,4 +154,12 @@ */ @PostMapping("/shop/editMgtShopStaff") public R editMgtShopStaff(@RequestBody MgtShopStaffEditDto mgtShopStaffEditDto); /** * 获取商户分成 * @param shopId * @return */ @PostMapping("/shop/getShopProportion") R<ShopProportionVo> getShopProportion(@RequestBody Long shopId); } ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/SecurityUtils.java
@@ -1,6 +1,8 @@ package com.ruoyi.common.security.utils; import javax.servlet.http.HttpServletRequest; import com.ruoyi.system.api.domain.poji.sys.SysUser; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import com.ruoyi.common.core.constant.SecurityConstants; import com.ruoyi.common.core.constant.TokenConstants; @@ -48,6 +50,11 @@ return SecurityContextHolder.get(SecurityConstants.LOGIN_USER, LoginUser.class); } public static SysUser getSysUser() { return getLoginUser().getSysUser(); } /** * 获取请求token */ ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/MyWxPayConfig.java
@@ -33,6 +33,13 @@ private static final String API_V3_KEY = ""; // 分账特约商户 private static final String PLATFORM_TY_MAC_ID = ""; public static String getPlatformTyMacId() { return PLATFORM_TY_MAC_ID; } @Bean @ConditionalOnMissingBean public WxPayService wxService() { ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java
@@ -15,6 +15,7 @@ import com.ruoyi.system.api.domain.dto.AppBaseGetDto; import com.ruoyi.system.api.domain.dto.AppMemberBindingDto; import com.ruoyi.system.api.domain.poji.member.Member; import com.ruoyi.system.api.model.LoginUser; import com.ruoyi.system.api.service.RemoteConfigService; import com.ruoyi.system.api.service.RemoteMemberService; import io.swagger.annotations.Api; @@ -87,13 +88,18 @@ @RequestMapping(value = "/placeOrder", method = RequestMethod.POST) @ApiOperation(value = "创建订单") public R<AppPlaceOrderVo> placeOrder(@RequestBody AppPlaceOrderDto appPlaceOrderDto) { Long userId = SecurityUtils.getUserId(); LoginUser loginUser = SecurityUtils.getLoginUser(); Long userId = loginUser.getUserid(); appPlaceOrderDto.setUserId(userId); appPlaceOrderDto.setSpbillCreateIp(loginUser.getIpaddr()); if(userId!=null){ Member member = memberService.getMember(userId).getData(); appPlaceOrderDto.setUserId(userId); if(member!=null&&member.getRelationShopId()!=null){ if (member != null) { appPlaceOrderDto.setOpenid(member.getMiniOpenid()); appPlaceOrderDto.setShopId(member.getRelationShopId()); } if(member.getBindingFlag()!=1){ //绑定商户 AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto(); @@ -103,6 +109,7 @@ memberService.updateMemberBinding(appMemberBindingDto); } } } AppPlaceOrderVo appPlaceOrderVo = orderService.placeOrder(appPlaceOrderDto); return R.ok(appPlaceOrderVo); } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/domain/vo/AppPlaceOrderVo.java
@@ -54,7 +54,7 @@ private String packageStr; @ApiModelProperty(value = "签名方式") private String tradeType; private String signType; @ApiModelProperty(value = "签名") private String paySign; ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/account/OrderPaymentService.java
@@ -3,6 +3,9 @@ import com.ruoyi.order.domain.pojo.account.OrderPayment; import com.baomidou.mybatisplus.extension.service.IService; import java.math.BigDecimal; import java.util.Date; /** * <p> * 订单支付 服务类 @@ -13,4 +16,24 @@ */ public interface OrderPaymentService extends IService<OrderPayment> { /** * 保存支付记录 * @param userId * @param shopId * @param orderId * @param payMoney * @param endTime * @param profitSharing * @param openid * @param goodsNames * @param prepayId */ void saveOrderPayment(Long userId, Long shopId, String orderId, BigDecimal payMoney, Date endTime, String profitSharing, String openid, String goodsNames, String prepayId); /** * * @param orderId * @return */ OrderPayment getByOrderId(String orderId); } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/account/PaymentMessageService.java
@@ -13,4 +13,12 @@ */ public interface PaymentMessageService extends IService<PaymentMessage> { /** * 保存请求信息 * @param sendType * @param sendId * @param sendMessage * @param resultMessage */ void savePaymentMessage(String sendType, Long sendId, String sendMessage, String resultMessage); } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/account/OrderPaymentServiceImpl.java
@@ -1,10 +1,16 @@ package com.ruoyi.order.service.impl.account; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.core.utils.uuid.IdUtils; import com.ruoyi.order.domain.pojo.account.OrderPayment; import com.ruoyi.order.mapper.account.OrderPaymentMapper; import com.ruoyi.order.service.account.OrderPaymentService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.util.Date; /** * <p> @@ -17,4 +23,33 @@ @Service public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, OrderPayment> implements OrderPaymentService { @Override public void saveOrderPayment(Long userId, Long shopId, String orderId, BigDecimal payMoney, Date endTime, String profitSharing, String openid, String goodsNames, String prepayId) { OrderPayment payment = new OrderPayment(); payment.setPaymentId(IdUtils.simpleUUID()); payment.setUserId(userId); payment.setShopId(shopId); payment.setOrderId(orderId); payment.setPayMoney(payMoney); payment.setTimeExpire(endTime); // 0 否 1、是 payment.setProfitSharing("Y".equals(profitSharing) ? 1 : 0); payment.setUserOpenId(openid); payment.setGoodsNames(goodsNames); payment.setPrepayId(prepayId); payment.setCreateTime(new Date()); payment.setDelFlag(0); this.saveOrUpdate(payment); } @Override public OrderPayment getByOrderId(String orderId) { LambdaQueryWrapper<OrderPayment> queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(OrderPayment::getOrderId, orderId) .eq(OrderPayment::getDelFlag, 0) .eq(OrderPayment::getPayStatus, 2) .last(" limit 1 "); return this.getOne(queryWrapper); } } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/account/PaymentMessageServiceImpl.java
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.util.Date; /** * <p> * 支付报文 服务实现类 @@ -17,4 +19,15 @@ @Service public class PaymentMessageServiceImpl extends ServiceImpl<PaymentMessageMapper, PaymentMessage> implements PaymentMessageService { @Override public void savePaymentMessage(String sendType, Long sendId, String sendMessage, String resultMessage) { PaymentMessage paymentMessage = new PaymentMessage(); paymentMessage.setDelFlag("0"); paymentMessage.setSendType(sendType); paymentMessage.setSendId(sendId); paymentMessage.setSendMessage(sendMessage); paymentMessage.setResultMessage(resultMessage); paymentMessage.setCreateTime(new Date()); this.saveOrUpdate(paymentMessage); } } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -5,6 +5,17 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult; import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingReceiver; import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingRequest; import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest; import com.github.binarywang.wxpay.config.WxPayConfig; import com.github.binarywang.wxpay.constant.WxPayConstants; import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.service.WxPayService; import com.google.common.base.Joiner; import com.google.gson.Gson; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.StringUtils; @@ -12,6 +23,7 @@ import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.CodeFactoryUtil; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.order.config.MyWxPayConfig; import com.ruoyi.order.domain.dto.*; import com.ruoyi.order.domain.pojo.account.OrderPayment; import com.ruoyi.order.domain.pojo.account.OrderRefund; @@ -21,6 +33,8 @@ import com.ruoyi.order.domain.pojo.order.PayRecord; import com.ruoyi.order.domain.vo.*; import com.ruoyi.order.mapper.order.OrderMapper; import com.ruoyi.order.service.account.OrderPaymentService; import com.ruoyi.order.service.account.PaymentMessageService; import com.ruoyi.order.service.order.*; import com.ruoyi.system.api.constant.AppErrorConstant; import com.ruoyi.system.api.constant.DelayTaskEnum; @@ -35,6 +49,7 @@ import com.ruoyi.system.api.domain.poji.member.MemberCoupon; import com.ruoyi.system.api.domain.poji.member.MemberGiftRecord; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.poji.shop.ShopProportionVo; import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.service.*; @@ -110,22 +125,14 @@ @Autowired private RedissonClient redissonClient; /** 商户号 */ public static String merchantId = ""; /** 商户API私钥路径 */ public static String privateKeyPath = ""; /** 商户证书序列号 */ public static String merchantSerialNumber = ""; /** 微信支付平台证书路径 */ public static String wechatPayCertificatePath = ""; /** 微信支付 APIv3 密钥 */ public static String apiV3Key = ""; /** 微信支付APPID */ public static String appId=""; /** 微信支付商户ID */ public static String mchId=""; /** 通知地址 */ public static String notifyUrl=""; @Autowired private WxPayService wxService; @Resource private PaymentMessageService paymentMessageService; @Resource private OrderPaymentService orderPaymentService; /** * @description: buyGoods @@ -510,7 +517,7 @@ Integer serviceNum; Integer goodsNum = 0; String memberCouponId; Goods goods; Goods goods = null; GoodsFile goodsFile; BigDecimal goodsPrice; BigDecimal goodsTotalPrice; @@ -542,6 +549,7 @@ HashSet<String> goodsTypeSet = new HashSet<>(); //使用优惠券 StringJoiner memberCouponSJ = new StringJoiner(","); List<String> goodsNameList = new ArrayList<>(); // 遍历购买的商品列表 for (AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList) { appSureOrderGoodsVo = new AppSureOrderGoodsVo(); @@ -551,6 +559,7 @@ memberCouponId = appBuyGoodsDto.getMemberCouponId(); // 获取商品信息 goods = goodsMap.get(goodsId); goodsNameList.add(goods.getGoodsName()); // 设置商品信息 appSureOrderGoodsVo.setGoodsId(goodsId); appSureOrderGoodsVo.setGoodsName(goods.getGoodsName()); @@ -713,37 +722,61 @@ } appPlaceOrderVo.setOrderId(orderId); appPlaceOrderVo.setOrderNo(orderNo); // 调用支付 /* CombineTransactionsJsRequest request=new CombineTransactionsJsRequest(); request.setCombineAppid(); request.setCombineMchid(); profitsSharingService.combineTransactions(request);*/ //构建预下单支付对象 /*PrepayRequest request = new PrepayRequest(); Amount amount = new Amount(); amount.setTotal(Integer.parseInt(order.getPayMoney().multiply(new BigDecimal(100)).toString())); request.setAmount(amount); request.setAppid(this.appId); request.setMchid(this.mchId); request.setDescription(order.getGoodsInfo()); request.setNotifyUrl(this.notifyUrl); request.setOutTradeNo(order.getOrderId()); Payer payer = new Payer(); payer.setOpenid("oLTPCuN5a-nBD4rAL_fa********"); request.setPayer(payer);*/ //返回前端唤醒支付结果信息 /*PrepayWithRequestPaymentResponse res = this.getJsApIResponse(request); appPlaceOrderVo.setAppId(this.appId); appPlaceOrderVo.setTimeStamp(res.getTimeStamp()); appPlaceOrderVo.setNonceStr(res.getNonceStr()); appPlaceOrderVo.setPackageStr(res.getPackageVal()); appPlaceOrderVo.setTradeType(res.getSignType()); appPlaceOrderVo.setPaySign(res.getPaySign());*/ try { // 创建支付订单 Long shopId = appPlaceOrderDto.getShopId(); R<String> resultMch = remoteShopService.getShopSubMchId(shopId); String subMchId = resultMch.getData(); if(StringUtils.isEmpty(subMchId)){ throw new ServiceException("获取微信商户号失败"); } WxPayConfig config = wxService.getConfig(); config.setSubMchId(subMchId); WxPayUnifiedOrderRequest request = new WxPayUnifiedOrderRequest(); request.setTradeType(WxPayConstants.TradeType.JSAPI); request.setSubMchId(subMchId); // 商户订单号 request.setOutTradeNo(orderNo); // 订单总金额 Integer totalFee = order.getPayMoney().multiply(new BigDecimal(100)).intValue(); request.setTotalFee(totalFee); request.setProductId(orderNo); request.setNotifyUrl(config.getNotifyUrl()); request.setProfitSharing("Y"); request.setOpenid(appPlaceOrderDto.getOpenid()); request.setSpbillCreateIp(appPlaceOrderDto.getSpbillCreateIp()); // 商品描述 body String body = "商品购买"; if(null != goods){ body = goods.getGoodsName() + "-" + body; } request.setBody(body); request.checkAndSign(config); // 请求参数 Gson gson = new Gson(); String payRequestJson = gson.toJson(request); WxPayMpOrderResult result = wxService.createOrder(request); String payResponseJson = gson.toJson(request); // 支付相关信息返回 appPlaceOrderVo.setAppId(result.getAppId()); appPlaceOrderVo.setMchId(config.getMchId()); appPlaceOrderVo.setTimeStamp(result.getTimeStamp()); appPlaceOrderVo.setNonceStr(result.getNonceStr()); appPlaceOrderVo.setPackageStr(result.getPackageValue()); appPlaceOrderVo.setSignType(result.getSignType()); appPlaceOrderVo.setPaySign(result.getPaySign()); appPlaceOrderVo.setPrepayId(result.getPackageValue()); //减去优惠券 if(memberCouponSJ!=null&&StringUtils.isNotBlank(memberCouponSJ.toString())){ if(StringUtils.isNotBlank(memberCouponSJ.toString())){ remoteCouponService.useMemberCoupon(memberCouponSJ.toString()); } //生成自动取消订单延时任务 @@ -759,7 +792,20 @@ delayTask.setRedisKey(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + orderId); remoteConfigService.addDelayTask(delayTask); appPlaceOrderVo.setEndTime(DateUtils.addMinutes(order.getCreateTime(),delayTime)); // 保存支付订单统一下单日志 paymentMessageService.savePaymentMessage("1", 0L, payRequestJson, payResponseJson); // 保存支付订单统一下单支付记录 orderPaymentService.saveOrderPayment(userId, shopId, orderId, order.getPayMoney(), appPlaceOrderVo.getEndTime(), "Y", appPlaceOrderDto.getOpenid(), Joiner.on(";").join(goodsNameList),result.getPackageValue()); return appPlaceOrderVo; } catch (WxPayException e){ throw new ServiceException(e.getMessage()); } } @@ -1359,7 +1405,6 @@ merVerifyOrderVo.setCloseFlag(order.getCloseFlag()); // if(order.getOrderFrom()==2){ //profitsSharingService.applyProfitSharing(); } @@ -1371,8 +1416,39 @@ payRecord.setPayTime(new Date()); payRecord.setPayType(2); payRecordService.save(payRecord); return merVerifyOrderVo; // TODO 核销完成 开始分账(平台收取服务费) OrderPayment payment = orderPaymentService.getByOrderId(orderId); String transactionId = payment.getTransactionId(); String platformTyMacId = MyWxPayConfig.getPlatformTyMacId(); R<String> resultMch = remoteShopService.getShopSubMchId(order.getShopId()); String subMchId = resultMch.getData(); if(StringUtils.isEmpty(subMchId)){ throw new ServiceException("获取微信商户号失败"); } R<ShopProportionVo> resultShopProportion = remoteShopService.getShopProportion(order.getShopId()); ShopProportionVo shopProportion = resultShopProportion.getData(); if(null == shopProportion){ throw new ServiceException("获取商户分成失败"); } ProfitSharingRequest request = new ProfitSharingRequest(); request.setSubMchId(subMchId); request.setTransactionId(transactionId); request.setOutOrderNo(order.getOrderNo()); List<ProfitSharingReceiver> receiverList = new ArrayList<>(); ProfitSharingReceiver receiver = new ProfitSharingReceiver(); // TODO 分账 // receiver.set // request.setReceivers(); // platformTyMacId // wxService.getProfitSharingV3Service().profitSharing() return merVerifyOrderVo; } /** ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/console/ShopController.java
@@ -2,6 +2,9 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; import com.ruoyi.shop.domain.pojo.shop.ShopProportion; import com.ruoyi.shop.domain.pojo.shop.ShopRelUser; import com.ruoyi.shop.domain.pojo.shop.ShopStaff; import com.ruoyi.shop.service.shop.*; @@ -10,6 +13,7 @@ import com.ruoyi.system.api.constant.AppErrorConstant; import com.ruoyi.system.api.domain.dto.*; import com.ruoyi.system.api.domain.poji.shop.Shop; import com.ruoyi.system.api.domain.poji.shop.ShopProportionVo; import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.model.QwH5LoginVo; @@ -59,6 +63,12 @@ @Resource private MemberTaskService memberTaskService; @Resource private ShopAuthenticationService shopAuthenticationService; @Resource private ShopProportionService shopProportionService; /** * 企业微信H5登录 * @param qwUserDetail @@ -90,6 +100,30 @@ return R.ok(shop); } @PostMapping("/getShopSubMchId") public R<String> getShopSubMchId(@RequestBody Long shopId){ String subMchid = ""; ShopAuthentication authentication = shopAuthenticationService.getByShopId(shopId); if(null != authentication){ subMchid = authentication.getSubMchid(); } return R.ok(subMchid, ""); } /** * 获取商户分成 * @param shopId * @return */ @PostMapping("/getShopProportion") public R<ShopProportionVo> getShopProportion(@RequestBody Long shopId){ ShopProportion shopProportion = shopProportionService.getByShopId(shopId); ShopProportionVo shopProportionVo = new ShopProportionVo(); BeanUtils.copyBeanProp(shopProportionVo, shopProportion); return R.ok(shopProportionVo); } @PostMapping("/getShopByUserId") public R<ShopRelUserVo> getShopByUserId(@RequestBody Long userId) ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/enums/WxApplyMentSignStateEnum.java
New file @@ -0,0 +1,20 @@ package com.ruoyi.shop.enums; import com.ruoyi.shop.enums.dict.IDict; public enum WxApplyMentSignStateEnum implements IDict<Integer> { /** * 签约状态 1、UNSIGNED:未签约。该状态下,电商平台可查询获取签约链接,引导二级商户的超级管理员完成签约; 2、SIGNED :已签约。指二级商户的超级管理员已完成签约。注意:若申请单被驳回,商户修改了商户主体名称、法人名称、超级管理员信息、主体类型等信息,则需重新签约。 3、NOT_SIGNABLE:不可签约。该状态下,暂不支持超级管理员签约。一般为申请单处于已驳回、已冻结、机器校验中状态,无法签约。 */ UNSIGNED(1, "UNSIGNED"), SIGNED(2, "SIGNED"), NOT_SIGNABLE(3, "NOT_SIGNABLE"); WxApplyMentSignStateEnum(Integer code, String text){ init(code, text); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/enums/WxApplyMentStateEnum.java
New file @@ -0,0 +1,30 @@ package com.ruoyi.shop.enums; import com.ruoyi.shop.enums.dict.IDict; public enum WxApplyMentStateEnum implements IDict<Integer> { /** * 审核状态 1:CHECKING:资料校验中 2:ACCOUNT_NEED_VERIFY:待账户验证 3:AUDITING:审核中 4:REJECTED:已驳回 5:NEED_SIGN:待签约 6:FINISH:完成 7:FROZEN:已冻结 8:CANCELED:已作废 */ CHECKING(1, "CHECKING"), ACCOUNT_NEED_VERIFY(2, "ACCOUNT_NEED_VERIFY"), AUDITING(3, "AUDITING"), REJECTED(4, "REJECTED"), NEED_SIGN(5, "NEED_SIGN"), FINISH(6, "FINISH"), FROZEN(7, "FROZEN"), CANCELED(8, "CANCELED"); WxApplyMentStateEnum(Integer code, String text){ init(code, text); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/enums/dict/DictBean.java
New file @@ -0,0 +1,15 @@ package com.ruoyi.shop.enums.dict; import lombok.Data; /** * 字典bean * 只有code和text,可用于展示下拉框 * * @author luozhan */ @Data public class DictBean<T> implements IDict<T> { private final T code; private final String text; } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/enums/dict/IDict.java
New file @@ -0,0 +1,170 @@ package com.ruoyi.shop.enums.dict; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; /** * 字典接口 * <p> * 自定义的字典枚举类实现本接口后可省略属性code和text,以及对应的get方法 * 在构造方法中只需调用init方法即可初始化 * * @author luozhan * @date 2021-12 */ public interface IDict<T> { /** * 通过code获取value * * @param clazz 枚举class * @param code code * @return text */ static <T> String getTextByCode(Class<? extends IDict<T>> clazz, T code) { return Stream.of(clazz.getEnumConstants()) .filter((IDict<T> e) -> e.getCode().equals(code)) .map(IDict::getText) .findAny().orElse(""); } /** * 通过text获取code * * @param clazz 枚举class * @param text text * @return code */ static <T> T getCodeByText(Class<? extends IDict<T>> clazz, String text) { return Stream.of(clazz.getEnumConstants()) .filter((IDict<T> e) -> e.getText().equals(text)) .map(IDict::getCode) .findAny().orElse(null); } /** * 通过code获取字典枚举实例 * * @param clazz 枚举class * @param code code * @param <T> 字典code类型 * @param <R> 枚举类型 * @return 字典枚举实例 */ @SuppressWarnings("unchecked") static <T, R extends IDict<T>> R getByCode(Class<? extends IDict<T>> clazz, T code) { return Stream.of(clazz.getEnumConstants()) .filter((IDict<T> e) -> (e.getCode().equals(code))) .map(v -> (R) v) .findAny() .orElse(null); } /** * 获取给定的字典枚举项(常用下拉框数据请求) * * @param enums 可指定需要哪些项 * @return List */ @SafeVarargs static <T, E extends IDict<T>> List<IDict<T>> getItems(E... enums) { return Stream.of(enums) .map(DictPool::getDict) .collect(Collectors.toList()); } /** * 获取所有字典枚举项,除开指定的枚举 * * @param exclude 指定排除的枚举 * @return List */ @SafeVarargs @SuppressWarnings("unchecked") static <T, E extends IDict<T>> List<IDict<T>> getItemsExclude(E... exclude) { Class<IDict<T>> clazz = (Class<IDict<T>>) exclude.getClass().getComponentType(); IDict<T>[] allEnum = clazz.getEnumConstants(); List<IDict<T>> excludeList = Arrays.asList(exclude); return Stream.of(allEnum) .filter(e -> !excludeList.contains(e)) .map(DictPool::getDict) .collect(Collectors.toList()); } /** * 获取所有字典枚举项(常用下拉框数据请求) * 枚举值上标记@Deprecated的不会返回 * * @param clazz 字典枚举类 * @return List */ static <T> List<IDict<T>> getAll(Class<? extends IDict<T>> clazz) { Map<String, Field> fieldCache = Arrays.stream(clazz.getDeclaredFields()). filter(Field::isEnumConstant). collect(Collectors.toMap(Field::getName, Function.identity())); IDict<T>[] allEnum = clazz.getEnumConstants(); return Stream.of(allEnum) .filter(e -> !fieldCache.get(((Enum<?>) e).name()).isAnnotationPresent(Deprecated.class)) .map(DictPool::getDict) .collect(Collectors.toList()); } /** * 初始化 * * @param code 字典编码 * @param text 字典文本 */ default void init(T code, String text) { DictPool.putDict(this, code, text); } /** * 获取编码 * * @return 编码 */ default T getCode() { return DictPool.getDict(this).getCode(); } /** * 获取文本 * * @return 文本 */ default String getText() { return DictPool.getDict(this).getText(); } @SuppressWarnings("all") class DictPool { private static final Map<IDict, DictBean> DICT_MAP = new ConcurrentHashMap<>(); private static final Map<String, Class<? extends IDict>> DICT_NAME_CLASS_MAP = new ConcurrentHashMap<>(); static <T> void putDict(IDict<T> dict, T code, String text) { DICT_NAME_CLASS_MAP.put(dict.getClass().getName(), dict.getClass()); DICT_MAP.put(dict, new DictBean<>(code, text)); } public static List<IDict<Object>> getDict(String dictName) { Class<? extends IDict> aClass = DICT_NAME_CLASS_MAP.get(dictName); return IDict.getAll((Class<? extends IDict<Object>>) aClass); } static <K extends IDict<T>, T> DictBean<T> getDict(K dict) { return DICT_MAP.get(dict); } } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/scheduler/ShopScheduler.java
@@ -1,7 +1,12 @@ package com.ruoyi.shop.scheduler; import com.ruoyi.common.core.utils.bean.BeanUtils; import com.ruoyi.common.core.utils.uuid.IdUtils; import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; import com.ruoyi.shop.service.shop.ShopService; import com.ruoyi.shop.service.task.ShopTaskService; import com.ruoyi.system.api.domain.poji.shop.Shop; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -21,6 +26,9 @@ @Resource private ShopTaskService shopTaskService; @Resource private ShopService shopService; /** * 定时检查跟进任务状态 @@ -33,4 +41,16 @@ } } /** * 0 0/1 * * * ? * 定时检查 每分钟检查一次 微信二级商户进件状态 */ @Scheduled(cron="0 0/1 * * * ?") private void queryEcommerceApplyMentsStatus(){ if(schedulerUtils.getSchedulerRun()) { log.info("--------------------定时检查微信二级商户进件状态任务开始执行--------------------"); shopService.queryEcommerceApplyMentsStatus(); log.info("--------------------定时检查微信二级商户进件状态任务结束执行--------------------"); } } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopAuthenticationServiceImpl.java
@@ -1,10 +1,23 @@ package com.ruoyi.shop.service.impl.shop; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult; import com.google.common.base.Joiner; import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; import com.ruoyi.shop.enums.WxApplyMentSignStateEnum; import com.ruoyi.shop.enums.WxApplyMentStateEnum; import com.ruoyi.shop.enums.dict.IDict; import com.ruoyi.shop.mapper.shop.ShopAuthenticationMapper; import com.ruoyi.shop.service.shop.ShopAuthenticationService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; /** * <p> @@ -17,4 +30,72 @@ @Service public class ShopAuthenticationServiceImpl extends ServiceImpl<ShopAuthenticationMapper, ShopAuthentication> implements ShopAuthenticationService { @Override public List<ShopAuthentication> getShopAuthNeedUpdateStatus() { List<Integer> auditStatusList = Arrays.asList(1, 2, 3, 5); LambdaQueryWrapper<ShopAuthentication> queryWrapper = Wrappers.lambdaQuery(); queryWrapper.in(ShopAuthentication::getAuditStatus, auditStatusList); queryWrapper.isNotNull(ShopAuthentication::getApplymentId); return this.list(queryWrapper); } @Override public void updateAuditStatusByApplymentId(String applymentId, ApplymentsStatusResult result) { // WxApplyMentStateEnum String applymentState = result.getApplymentState(); Integer auditStatus = IDict.getCodeByText(WxApplyMentStateEnum.class, applymentState); Integer signState = IDict.getCodeByText(WxApplyMentSignStateEnum.class, result.getSignState()); LambdaUpdateWrapper<ShopAuthentication> updateWrapper = Wrappers.lambdaUpdate(); updateWrapper.eq(ShopAuthentication::getApplymentId, applymentId) .set(ShopAuthentication::getAuditStatus, auditStatus) .set(ShopAuthentication::getSignState, signState); if(WxApplyMentStateEnum.ACCOUNT_NEED_VERIFY.getCode().equals(auditStatus)){ // ACCOUNT_NEED_VERIFY 待账户验证 updateWrapper.set(ShopAuthentication::getLegalValidationUrl, result.getLegalValidationUrl()); ApplymentsStatusResult.AccountValidation accountValidation = result.getAccountValidation(); if(null != accountValidation) { updateWrapper.set(ShopAuthentication::getAvAccountName, accountValidation.getAccountName()) .set(ShopAuthentication::getAvAccountNo, accountValidation.getAccountNo()) .set(ShopAuthentication::getAvPayAmount, accountValidation.getPayAmount()) .set(ShopAuthentication::getDaNumber, accountValidation.getDestinationAccountNumber()) .set(ShopAuthentication::getDaName, accountValidation.getDestinationAccountName()) .set(ShopAuthentication::getDaBank, accountValidation.getDestinationAccountBank()) .set(ShopAuthentication::getDaCity, accountValidation.getCity()) .set(ShopAuthentication::getDaRemark, accountValidation.getRemark()) .set(ShopAuthentication::getDaDeadline, accountValidation.getDeadline()); } } else if(WxApplyMentStateEnum.NEED_SIGN.getCode().equals(auditStatus)){ // NEED_SIGN 待签约 updateWrapper.set(ShopAuthentication::getSignUrl, result.getSignUrl()); updateWrapper.set(ShopAuthentication::getSubMchid, result.getSubMchid()); } else if(WxApplyMentStateEnum.FINISH.getCode().equals(auditStatus)){ // FINISH 完成 updateWrapper.set(ShopAuthentication::getSubMchid, result.getSubMchid()); } else if(WxApplyMentStateEnum.REJECTED.getCode().equals(auditStatus) || WxApplyMentStateEnum.FROZEN.getCode().equals(auditStatus)){ List<ApplymentsStatusResult.AuditDetail> auditDetail = result.getAuditDetail(); if(null != auditDetail && !auditDetail.isEmpty()){ List<String> paramNameList = auditDetail.stream().map(ApplymentsStatusResult.AuditDetail::getParamName).collect(Collectors.toList()); List<String> rejectReason = auditDetail.stream().map(ApplymentsStatusResult.AuditDetail::getRejectReason).collect(Collectors.toList()); updateWrapper.set(ShopAuthentication::getAdParamName, Joiner.on(";").join(paramNameList)) .set(ShopAuthentication::getAdRejectReason, Joiner.on(";").join(rejectReason)); } } this.update(updateWrapper); } @Override public ShopAuthentication getByShopId(Long shopId) { LambdaQueryWrapper<ShopAuthentication> queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(ShopAuthentication::getShopId, shopId) .last(" limit 1 "); return this.getOne(queryWrapper); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopProportionServiceImpl.java
@@ -1,7 +1,10 @@ package com.ruoyi.shop.service.impl.shop; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ruoyi.shop.domain.dto.MgtShopProportionEditDto; import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; import com.ruoyi.shop.domain.pojo.shop.ShopProportion; import com.ruoyi.shop.mapper.shop.ShopProportionMapper; import com.ruoyi.shop.service.shop.ShopProportionService; @@ -48,4 +51,13 @@ shopProportionNew.setUpdateUserId(mgtShopProportionEditDto.getUserId()); this.saveOrUpdate(shopProportionNew); } @Override public ShopProportion getByShopId(Long shopId) { LambdaQueryWrapper<ShopProportion> queryWrapper = Wrappers.lambdaQuery(); queryWrapper.eq(ShopProportion::getShopId, shopId) .eq(ShopProportion::getDelFlag, 0) .last(" limit 1 "); return this.getOne(queryWrapper); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -2,9 +2,12 @@ import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsResult; import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.ruoyi.common.core.constant.CacheConstants; import com.ruoyi.common.core.exception.ServiceException; @@ -18,6 +21,7 @@ import com.ruoyi.shop.domain.pojo.shop.*; import com.ruoyi.shop.domain.pojo.task.ShopFile; import com.ruoyi.shop.domain.vo.*; import com.ruoyi.shop.enums.WxApplyMentStateEnum; import com.ruoyi.shop.mapper.shop.ShopMapper; import com.ruoyi.shop.service.shop.*; import com.ruoyi.shop.service.task.MemberTaskService; @@ -124,6 +128,7 @@ /** * 获取商户详情 * * @param shopId * @return */ @@ -159,6 +164,7 @@ /** * 创建商户 * * @param mgtEditShopDto */ @Override @@ -321,12 +327,12 @@ } /** * @description 商户关联类初始化 * @author jqs * @date 2023/7/7 11:25 * @param shop * @param userId * @return void * @description 商户关联类初始化 * @author jqs * @date 2023/7/7 11:25 */ private void initNewShop(Shop shop,Long userId){ BigDecimal zeroBig = new BigDecimal("0.00"); @@ -394,11 +400,11 @@ } /** * @param mgtTerminateCooperationDto * @return void * @description 终止合作 * @author jqs * @date 2023/6/20 12:01 * @param mgtTerminateCooperationDto * @return void */ @Override public void terminateMgtCooperation(MgtTerminateCooperationDto mgtTerminateCooperationDto){ @@ -422,11 +428,11 @@ } /** * @param mgtFrozenShopDto * @return void * @description 冻结商户 * @author jqs * @date 2023/7/15 13:56 * @param mgtFrozenShopDto * @return void */ @Override public void frozenMgtShop(MgtFrozenShopDto mgtFrozenShopDto){ @@ -441,11 +447,11 @@ } /** * @param * @return Integer * @description 处理商户状态 * @author jqs * @date 2023/7/15 14:09 * @param * @return Integer */ private Integer handelShopStatus(Integer frozenFlag, Integer cooperativeFlag, Integer authFlag){ Integer shopStatus = 1; @@ -467,6 +473,7 @@ /** * 修改合作时间 * * @param mgtChangeCoopDto */ @Override @@ -500,6 +507,7 @@ /** * 分页获取商户 * * @param page * @param mgtShopPageDto * @return @@ -563,6 +571,7 @@ /** * 获取商户详情 * * @param shopId * @return */ @@ -628,6 +637,7 @@ /** * 修改商户标签 * * @param mgtEditShopTagDto */ @Override @@ -662,11 +672,11 @@ /** * @param mgtTransferShopDto * @return void * @description 转移客户 * @author jqs * @date 2023/6/28 16:36 * @param mgtTransferShopDto * @return void */ @Override public void transferMgtShop(MgtTransferShopDto mgtTransferShopDto){ @@ -699,6 +709,7 @@ /** * 获取附近门店 * * @param appNearbyShopDto * @return */ @@ -733,7 +744,6 @@ } /** * * @param shopId * @return */ @@ -747,6 +757,7 @@ /** * 获取获取员工端首页统计 * * @param userId * @return */ @@ -776,8 +787,10 @@ staffHomeShopTotalVo.setShopTask(shopTaskCount); return staffHomeShopTotalVo; } /** * 获取商户端 * * @param merBaseDto * @return */ @@ -812,6 +825,7 @@ /** * 获取商户绑定代理商 * * @param page * @param merAgencyPageDto * @return @@ -824,6 +838,7 @@ /** * 处理商户员工 * * @param shopId * @param sysUser */ @@ -847,12 +862,12 @@ } /** * @description 平台获取商户分成列表 * @author jqs * @date 2023/6/8 9:25 * @param page * @param mgtShopProportionPageDto * @return List<MgtShopProportionPageVo> * @description 平台获取商户分成列表 * @author jqs * @date 2023/6/8 9:25 */ @Override public List<MgtShopProportionPageVo> pageMgtShopProportion(Page page, MgtShopProportionPageDto mgtShopProportionPageDto){ @@ -860,11 +875,11 @@ } /** * @param shopTag * @return void * @description 删除商户标签 * @author jqs * @date 2023/6/8 15:53 * @param shopTag * @return void */ @Override public void deleteShopTag(String shopTag){ @@ -872,11 +887,11 @@ } /** * @param mgtShopIdByCodeDto * @return MgtShopIdByCodeVo * @description 通过code获取shopId * @author jqs * @date 2023/6/9 16:40 * @param mgtShopIdByCodeDto * @return MgtShopIdByCodeVo */ @Override public MgtShopIdByCodeVo getShopIdByCode(MgtShopIdByCodeDto mgtShopIdByCodeDto){ @@ -892,11 +907,11 @@ } /** * @param mgtShopListDto * @return List<MgtShopListSimpleVo> * @description 获取商户list * @author jqs * @date 2023/6/12 14:37 * @param mgtShopListDto * @return List<MgtShopListSimpleVo> */ @Override public List<MgtShopListSimpleVo> listMgtShopSimpleVo(MgtShopListDto mgtShopListDto){ @@ -904,11 +919,11 @@ } /** * @param shopIds * @return List<MgtShopListSimpleVo> * @description 通过id获取商户列表 * @author jqs * @date 2023/6/14 17:53 * @param shopIds * @return List<MgtShopListSimpleVo> */ @Override public List<MgtSimpleShopVo> listShopSimpleVoByIds(String shopIds){ @@ -916,10 +931,10 @@ } /** * @description pageMgtShopByCityCode * @param page * @param mgtShopByCodePageDto * @return List<MgtSimpleShopVo> * @description pageMgtShopByCityCode * @author jqs34 * @date 2023/6/14 20:56 */ @@ -929,10 +944,10 @@ } /** * @description pageMgtShopAuth * @param page * @param mgtShopAuthPageDto * @return List<MgtShopAuthPageVo> * @description pageMgtShopAuth * @author jqs34 * @date 2023/6/14 23:01 */ @@ -942,9 +957,9 @@ } /** * @description boardShopTotal * @param * @return MgtBulletinBoardVo * @description boardShopTotal * @author jqs34 * @date 2023/6/18 16:59 */ @@ -955,11 +970,11 @@ } /** * @param mgtShopAuthDto * @return void * @description 商户进件 * @author jqs * @date 2023/6/19 11:02 * @param mgtShopAuthDto * @return void */ @Override public void mgtShopAuth(MgtShopAuthDto mgtShopAuthDto) throws WxPayException { @@ -968,17 +983,21 @@ String applyNumber = IdUtils.simpleUUID(); BeanUtils.copyProperties(mgtShopAuthDto , shopAuthentication); shopAuthentication.setApplyNumber(applyNumber); shopAuthentication.setAuditStatus(3); // 提交申请 -> 资料校验中 shopAuthentication.setAuditStatus(1); ApplymentsResult result = wechatPayUtils.ecommerceApply(shopAuthentication, applyNumber, shop); // 微信支付申请单号 shopAuthentication.setApplymentId(result.getApplymentId()); shopAuthenticationService.saveOrUpdate(shopAuthentication); wechatPayUtils.ecommerceApply(shopAuthentication,applyNumber,shop); } /** * @param mgtBasePlatformDto * @return MgtPlTotalShopTotalVo * @description 获取平台商户统计 * @author jqs * @date 2023/6/21 16:25 * @param mgtBasePlatformDto * @return MgtPlTotalShopTotalVo */ @Override public MgtPlTotalShopTotalVo getPlTotalShopTotal(MgtBasePlatformDto mgtBasePlatformDto) { @@ -1049,11 +1068,11 @@ } /** * @param MgtMapIntTotalVos * @return List<MgtMapIntTotalVo> * @description 去除空字符串 * @author jqs * @date 2023/6/27 17:35 * @param MgtMapIntTotalVos * @return List<MgtMapIntTotalVo> */ private List<MgtMapIntTotalVo> listRemoveNull(List<MgtMapIntTotalVo> MgtMapIntTotalVos){ for (int i = 0; i < MgtMapIntTotalVos.size(); i++) { @@ -1065,9 +1084,9 @@ } /** * @description 获取平台统计shopId * @param mgtBasePlatformDto * @return List<Long> * @description 获取平台统计shopId * @author jqs34 * @date 2023/6/23 14:12 */ @@ -1079,11 +1098,11 @@ /** * @param authId * @return MgtShopAuthGetVo * @description 获取商户审核资料 * @author jqs * @date 2023/6/25 10:37 * @param authId * @return MgtShopAuthGetVo */ @Override public MgtShopAuthGetVo getMgtShopAuth(String authId){ @@ -1094,11 +1113,11 @@ } /** * @param authId * @return MgtShopAuthCodeVo * @description 获取商户验证信息 * @author jqs * @date 2023/6/26 10:38 * @param authId * @return MgtShopAuthCodeVo */ @Override public MgtShopAuthCodeVo getMgtShopAuthCode(String authId){ @@ -1111,11 +1130,11 @@ /** * @param shopId * @return List<Long> * @description 获取商户下属代理商 * @author jqs * @date 2023/7/3 17:27 * @param shopId * @return List<Long> */ @Override public List<Long> listShopIdByShopId(Long shopId){ @@ -1126,11 +1145,11 @@ } /** * @param shopId * @return List<MgtSimpleShopVo> * @description 获取商户下属代理商 * @author jqs * @date 2023/7/3 18:18 * @param shopId * @return List<MgtSimpleShopVo> */ @Override public List<MgtSimpleShopVo> listShopByShop(Long shopId){ @@ -1146,11 +1165,11 @@ } /** * @param userId * @return Shop * @description 获取用户管理商户 * @author jqs * @date 2023/7/14 10:00 * @param userId * @return Shop */ @Override public Shop getShopByBelongUserId(Long userId){ @@ -1161,12 +1180,12 @@ } /** * @description 员工端获取商户列表 * @author jqs * @date 2023/7/14 15:26 * @param page * @param staffShopPageDto * @return List<StaffShopPageVo> * @description 员工端获取商户列表 * @author jqs * @date 2023/7/14 15:26 */ @Override public List<StaffShopPageVo> pageStaffShop(Page page, StaffShopPageDto staffShopPageDto){ @@ -1175,11 +1194,11 @@ } /** * @param userId * @return StaffShopSimpleTotalVo * @description 获取员工端商户数量统计 * @author jqs * @date 2023/7/14 15:51 * @param userId * @return StaffShopSimpleTotalVo */ @Override public StaffShopSimpleTotalVo getStaffSimpleTotal(Long userId){ @@ -1194,11 +1213,11 @@ } /** * @param shopId * @return StaffShopInfoGetVo * @description 员工端获取商户详情 * @author jqs * @date 2023/7/14 18:32 * @param shopId * @return StaffShopInfoGetVo */ @Override public StaffShopInfoGetVo getStaffShopInfo(Long shopId) { @@ -1277,11 +1296,11 @@ } /** * @param staffShopEstimateEditDto * @return void * @description 修改商户评估 * @author jqs * @date 2023/7/15 10:18 * @param staffShopEstimateEditDto * @return void */ @Override public void editShopEstimate(StaffShopEstimateEditDto staffShopEstimateEditDto){ @@ -1301,11 +1320,11 @@ } /** * @param staffShopECEditDto * @return void * @description 修改店铺扩展联系人 * @author jqs * @date 2023/7/15 11:06 * @param staffShopECEditDto * @return void */ @Override public void editExtendContacts(StaffShopECEditDto staffShopECEditDto){ @@ -1323,11 +1342,11 @@ } /** * @param staffShopCCEditDto * @return void * @description 修改店铺状态 * @author jqs * @date 2023/7/15 11:51 * @param staffShopCCEditDto * @return void */ @Override public void editShopCustomStatus(StaffShopCCEditDto staffShopCCEditDto){ @@ -1338,4 +1357,44 @@ shop.setUpdateTime(new Date()); shopMapper.updateShop(shop); } @Override public void queryEcommerceApplyMentsStatus() { List<ShopAuthentication> list = shopAuthenticationService.getShopAuthNeedUpdateStatus(); list.forEach(item -> queryApplyStatusByApplymentId(item.getApplymentId(), item.getShopId())); } /** * 调用微信接口查询申请审核状态 * @param applymentId */ private void queryApplyStatusByApplymentId(String applymentId, Long shopId) { try { if (StringUtils.isNotBlank(applymentId)) { ApplymentsStatusResult result = wechatPayUtils.queryApplyStatusByApplymentId(applymentId); shopAuthenticationService.updateAuditStatusByApplymentId(applymentId, result); String applymentState = result.getApplymentState(); if(WxApplyMentStateEnum.FINISH.getText().equals(applymentState)){ applySuccessUpdateShopStatus(shopId); } } } catch (WxPayException e) { e.printStackTrace(); } } /** * 商户进件审核完成,更新商户状态 * @param shopId */ private void applySuccessUpdateShopStatus(Long shopId){ // 更新商户状态为正常 Shop shop = this.getById(shopId); Integer shopStatus = handelShopStatus(shop.getFrozenFlag(), shop.getCooperativeFlag(), 1); LambdaUpdateWrapper<Shop> updateWrapper = Wrappers.lambdaUpdate(); updateWrapper.eq(Shop::getShopId, shopId) .set(Shop::getShopStatus, shopStatus) .set(Shop::getAuthFlag, 1); this.update(updateWrapper); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/shop/ShopAuthenticationService.java
@@ -1,7 +1,10 @@ package com.ruoyi.shop.service.shop; import com.github.binarywang.wxpay.bean.ecommerce.ApplymentsStatusResult; import com.ruoyi.shop.domain.pojo.shop.ShopAuthentication; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** * <p> @@ -13,4 +16,23 @@ */ public interface ShopAuthenticationService extends IService<ShopAuthentication> { /** * 获取需要更新状态的 微信二级商户认证审核 * @return */ List<ShopAuthentication> getShopAuthNeedUpdateStatus(); /** * 修改微信审核状态 * @param applymentId * @param result */ void updateAuditStatusByApplymentId(String applymentId, ApplymentsStatusResult result); /** * 获取商户认证信息 * @param shopId * @return */ ShopAuthentication getByShopId(Long shopId); } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/shop/ShopProportionService.java
@@ -22,4 +22,11 @@ * @return void */ void editMgtShopProportion(MgtShopProportionEditDto mgtShopProportionEditDto); /** * 获取商户分成比例 * @param shopId * @return */ ShopProportion getByShopId(Long shopId); } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/shop/ShopService.java
@@ -327,4 +327,9 @@ * @return void */ void editShopCustomStatus(StaffShopCCEditDto staffShopCCEditDto); /** * 微信二级商户进件状态 定时任务检测 */ void queryEcommerceApplyMentsStatus(); } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/util/WechatPayUtils.java
@@ -20,12 +20,13 @@ @Component @AllArgsConstructor public class WechatPayUtils { private final WxPayService wxService; /** * 电商二级商户进件(提交申请单) */ public void ecommerceApply(ShopAuthentication shopAuthentication, String applyNumber, Shop shop) throws WxPayException { public ApplymentsResult ecommerceApply(ShopAuthentication shopAuthentication, String applyNumber, Shop shop) throws WxPayException { EcommerceService ecommerceService = wxService.getEcommerceService(); ApplymentsRequest request = new ApplymentsRequest(); //生成提交类 @@ -105,18 +106,18 @@ request.setBusinessAdditionPics(shopAuthentication.getBaPics()); request.setBusinessAdditionDesc(shopAuthentication.getBaDesc()); ApplymentsResult result = ecommerceService.createApply(request); return ecommerceService.createApply(request); } /** * 通过查询申请状态API查询二级商户入驻申请结果 * @param applyNumber 业务申请编号 * @param applymentId 微信支付申请单号 * @return 申请状态 * @throws WxPayException */ public ApplymentsStatusResult queryApplyStatusByOutRequestNo(String applyNumber) throws WxPayException { return wxService.getEcommerceService().queryApplyStatusByOutRequestNo(applyNumber); public ApplymentsStatusResult queryApplyStatusByApplymentId(String applymentId) throws WxPayException { return wxService.getEcommerceService().queryApplyStatusByApplymentId(applymentId); } }