ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/ConfigEnum.java
@@ -37,7 +37,8 @@ NURSE_PROBLEM("NURSE_PROBLEM", 4,"调理问题"), HOME_STYLE("HOME_STYLE", 2,"首页风格"), HOME_SLOGAN("HOME_SLOGAN", 1,"首页广告语"), HOME_LOGO("HOME_LOGO", 1,"首页logo"); HOME_LOGO("HOME_LOGO", 1,"首页logo"), SHOP_COMMON_PROPORTION("SHOP_COMMON_PROPORTION", 1,"商户统一分成"); ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/constant/SecurityConstant.java
@@ -52,6 +52,11 @@ String AUTO_CANCEL_ORDER_TIME = "AUTO_CANCEL_ORDER_TIME"; /** * 商户统一分成 */ String SHOP_COMMON_PROPORTION = "SHOP_COMMON_PROPORTION"; /** * 自动取消订单时间 */ String PAY_MONEY_INTEGRAL = "PAY_MONEY_INTEGRAL"; ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/shop/Shop.java
@@ -280,6 +280,12 @@ */ @TableField("auth_flag") private Integer authFlag; /** * 分账标记 */ @TableField("account_flag") private Integer accountFlag; /** * 店铺二维码 */ ruoyi-common/ruoyi-common-seata/pom.xml
@@ -23,5 +23,6 @@ <artifactId>spring-cloud-starter-alibaba-seata</artifactId> </dependency> </dependencies> </project> ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/config/AsyncConfig.java
@@ -1,6 +1,6 @@ package com.ruoyi.common.security.config; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.AsyncConfigurer; @@ -20,7 +20,7 @@ */ @Configuration @EnableAsync @Slf4j @Log4j2 public class AsyncConfig implements AsyncConfigurer { /** ruoyi-modules/ruoyi-goods/pom.xml
@@ -78,6 +78,13 @@ <artifactId>ruoyi-common-swagger</artifactId> </dependency> <!-- RuoYi Common Seata--> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-seata</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> ruoyi-modules/ruoyi-goods/src/main/java/com/ruoyi/goods/scheduler/ActivityScheduler.java
@@ -2,14 +2,14 @@ import com.ruoyi.goods.service.activity.ActivityService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component @Slf4j @Log4j2 public class ActivityScheduler { ruoyi-modules/ruoyi-member/pom.xml
@@ -78,6 +78,11 @@ <artifactId>ruoyi-common-swagger</artifactId> </dependency> <!-- RuoYi Common Seata--> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-seata</artifactId> </dependency> <dependency> ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/controller/business/MerBirthdayController.java
@@ -9,6 +9,7 @@ import com.ruoyi.system.api.domain.dto.MerBaseDto; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -26,6 +27,7 @@ @Api(value = "商户端生日卡相关接口", tags = "商户端生日卡相关接口", description = "商户端生日卡相关接口") @RestController @RequestMapping("/mer/birthday") @Log4j2 public class MerBirthdayController { ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/scheduler/MemberScheduler.java
@@ -5,7 +5,7 @@ import com.ruoyi.member.service.member.MemberCouponService; import com.ruoyi.member.service.member.MemberService; import com.ruoyi.member.service.member.MemberTotalService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -14,7 +14,7 @@ @Component @Slf4j @Log4j2 public class MemberScheduler { ruoyi-modules/ruoyi-order/pom.xml
@@ -78,6 +78,13 @@ <artifactId>ruoyi-common-swagger</artifactId> </dependency> <!-- RuoYi Common Seata--> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-seata</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> @@ -143,6 +150,7 @@ <version>4.13.1</version> <scope>test</scope> </dependency> </dependencies> <build> ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/scheduler/OrderScheduler.java
@@ -2,7 +2,7 @@ import com.ruoyi.order.service.order.OrderService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -11,7 +11,7 @@ @Component @Slf4j @Log4j2 public class OrderScheduler { ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/ConsumerGoodsServiceImpl.java
@@ -30,6 +30,7 @@ import com.ruoyi.system.api.service.RemoteGoodsService; import com.ruoyi.system.api.service.RemoteMemberService; import com.ruoyi.system.api.service.RemoteShopService; import io.seata.spring.annotation.GlobalTransactional; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -100,7 +101,7 @@ * @param merSureConsumerGoodsDto */ @Override @Transactional @Transactional public void sureMerConsumerGoods(MerSureConsumerGoodsDto merSureConsumerGoodsDto){ ConsumerGoods oldConsumerGoods = this.getById(merSureConsumerGoodsDto.getConsumerGoodsId()); if(oldConsumerGoods.getSureNum()==null||oldConsumerGoods.getSureNum()<1){ @@ -217,6 +218,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public void useMerConsumerGoods(MerSureConsumerGoodsDto merSureConsumerGoodsDto){ List<MerSureConsumerGoodsListDto> goodsList = merSureConsumerGoodsDto.getMerSureConsumerGoodsListDtoList(); if (goodsList != null && !goodsList.isEmpty()) { ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -58,7 +58,8 @@ import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.service.*; import lombok.extern.slf4j.Slf4j; import io.seata.spring.annotation.GlobalTransactional; import lombok.extern.log4j.Log4j2; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.stereotype.Service; @@ -84,7 +85,7 @@ * @since 2023-04-25 */ @Service @Slf4j @Log4j2 public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements OrderService { @Resource @@ -513,6 +514,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public AppPlaceOrderVo placeOrder(AppPlaceOrderDto appPlaceOrderDto) { // 获取用户ID Long userId = appPlaceOrderDto.getUserId(); @@ -912,6 +914,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public AppPlaceOrderVo placeActivityOrder(AppPlaceActivityDto appPlaceActivityDto) { Long userId = appPlaceActivityDto.getUserId(); // 创建订单对象 @@ -1448,6 +1451,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public MerVerifyOrderVo sureVerifyOrder(MerVerifyOrderDto merVerifyOrderDto) { String orderId = merVerifyOrderDto.getOrderId(); BigDecimal relReceiveMoney = merVerifyOrderDto.getRelReceiveMoney(); @@ -1696,6 +1700,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public MerVerifyCouponVo sureVerifyCoupon(MerVerifyCouponDto merVerifyCouponDto) { MerVerifyCouponGetVo verifyCouponGetVo = remoteCouponService.getVerifyCoupon(merVerifyCouponDto.getMemberCouponId()).getData(); MemberCoupon memberCoupon = verifyCouponGetVo.getMemberCoupon(); @@ -1823,6 +1828,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public MerVerifyAwardVo sureVerifyPrize(MerVerifyPrizeDto merVerifyPrizeDto) { MerVerifyAwardVo merVerifyAwardVo = new MerVerifyAwardVo(); MemberGiftRecord memberGiftRecord = remoteMemberService.getVerifyPrize(merVerifyPrizeDto.getPrizeId()).getData(); @@ -2287,6 +2293,7 @@ } //更新会员消费记录 MemberTotalChangeDto memberTotalChangeDto = new MemberTotalChangeDto(); memberTotalChangeDto.setUserId(order.getUserId()); memberTotalChangeDto.setConsumeTime(nowTime); remoteMemberService.changeMemberTotal(memberTotalChangeDto); //更新商户统计 @@ -4424,6 +4431,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public void autoCancelOrder(String orderId) { //更新订单信息 Order order = this.getById(orderId); @@ -4490,6 +4498,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public void payBack(PartnerTransactionsResult transaction) { log.info("订单支付回调---"+transaction.toString()); // Order order = this.getById(orderId); @@ -4656,6 +4665,7 @@ */ @Override @Transactional @GlobalTransactional(rollbackFor = Exception.class) public void refundOrder(String orderId) { // 更新订单信息 Order order = this.getById(orderId); ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -1318,8 +1318,8 @@ SELECT COUNT(DISTINCT toc.user_id) orderPerson, COUNT(DISTINCT CASE WHEN tog.goods_type = 1 THEN toc.user_id ELSE NULL END) cyclePerson, COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) experiencePerson, COUNT(DISTINCT CASE WHEN tog.goods_type = 3 THEN toc.user_id ELSE NULL END) servicePerson COUNT(DISTINCT CASE WHEN tog.goods_type = 3 THEN toc.user_id ELSE NULL END) experiencePerson, COUNT(DISTINCT CASE WHEN tog.goods_type = 2 THEN toc.user_id ELSE NULL END) servicePerson FROM t_order toc INNER JOIN t_order_goods tog ON tog.order_id = toc.order_id WHERE toc.del_flag = 0 AND toc.order_from = 2 AND toc.order_status = 3 AND toc.new_member_flag = 1 @@ -1775,7 +1775,7 @@ <select id="countUserActivityByActivity" resultType="java.lang.Integer"> SELECT COUNT(order_id) FROM t_order WHERE del_flag = 0 AND order_from =2 AND user_id = #{userId} AND activity_id = #{activityId} AND order_status > 0 WHERE del_flag = 0 AND order_from =2 AND user_id = #{userId} AND activity_id = #{activityId} AND order_status > 1 </select> <select id="getStaffActivityOrderTotal" resultType="com.ruoyi.order.domain.vo.StaffActivityOrderTotalVo"> ruoyi-modules/ruoyi-shop/pom.xml
@@ -78,6 +78,12 @@ <artifactId>ruoyi-common-swagger</artifactId> </dependency> <!-- RuoYi Common Seata--> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-seata</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/management/MgtShopController.java
@@ -274,7 +274,7 @@ @RequestMapping(value = "/mgtShopAuth", method = RequestMethod.POST) @Log(title = "商户进件管理", businessType = BusinessType.UPDATE,operContent = "商户进件") @ApiOperation(value = "平台商户进件") public R mgtShopAuth(@Validated @RequestBody MgtShopAuthDto mgtShopAuthDto) throws Exception { public R mgtShopAuth(@Validated @RequestBody MgtShopAuthDto mgtShopAuthDto) { Long userId = SecurityUtils.getUserId(); mgtShopAuthDto.setUserId(userId); shopService.mgtShopAuth(mgtShopAuthDto); @@ -295,5 +295,13 @@ return R.ok(mgtShopAuthCodeVo); } @RequestMapping(value = "/mgtShopAuth", method = RequestMethod.POST) @Log(title = "商户进件管理", businessType = BusinessType.UPDATE,operContent = "商户进件") @ApiOperation(value = "平台商户进件") public R mgtShopAuth(@RequestBody MgtShopAuthGetDto mgtShopAuthGetDto){ Long userId = SecurityUtils.getUserId(); mgtShopAuthGetDto.setUserId(userId); shopService.addProfitSharingReceiver(mgtShopAuthGetDto); return R.ok(); } } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MgtShopAuthPageVo.java
@@ -44,6 +44,7 @@ @ApiModelProperty(value = "签约链接") private String signUrl; @ApiModelProperty(value = "分账方标记1是0否 0的时候需要添加为分账方") private Integer accountFlag; } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/scheduler/ShopScheduler.java
@@ -3,7 +3,7 @@ import com.ruoyi.shop.service.shop.ShopService; import com.ruoyi.shop.service.task.ShopTaskService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -12,7 +12,7 @@ @Component @Slf4j @Log4j2 public class ShopScheduler { ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/impl/shop/ShopServiceImpl.java
@@ -39,7 +39,7 @@ import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.api.domain.vo.*; import com.ruoyi.system.api.service.*; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -59,7 +59,7 @@ * @since 2023-04-25 */ @Service @Slf4j @Log4j2 public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements ShopService { @Resource @@ -245,6 +245,7 @@ shop.setFrozenFlag(0); shop.setCooperativeFlag(1); shop.setAuthFlag(0); shop.setAccountFlag(0); newShop = true; } BeanUtils.copyProperties(mgtEditShopDto,shop); @@ -1030,7 +1031,7 @@ * @return void */ @Override public void mgtShopAuth(MgtShopAuthDto mgtShopAuthDto) throws WxPayException { public void mgtShopAuth(MgtShopAuthDto mgtShopAuthDto) { ShopAuthentication shopAuthentication = shopAuthenticationService.getById(mgtShopAuthDto.getAuthId()); Shop shop = this.getByShopId(shopAuthentication.getShopId()); @@ -1600,10 +1601,21 @@ * @return void */ @Override public ProfitSharingReceiverResult addProfitSharingReceiver(ProfitSharingReceiverRequest request){ public void addProfitSharingReceiver(MgtShopAuthGetDto mgtShopAuthGetDto){ try { ProfitSharingReceiverResult result = wechatPayUtils.addProfitSharingReceiver(request); return result; ShopAuthentication shopAuthentication = shopAuthenticationService.getById(mgtShopAuthGetDto.getAuthId()); Shop shop = this.getByShopId(shopAuthentication.getShopId()); if(shopAuthentication!=null&&shopAuthentication.getAuditStatus()==6){ ProfitSharingReceiverRequest request = new ProfitSharingReceiverRequest(); request.setAccount(shopAuthentication.getSubMchid()); request.setName(shopAuthentication.getBlShopName()); ProfitSharingReceiverResult result = wechatPayUtils.addProfitSharingReceiver(request); if(StringUtils.isNotBlank(result.getAccount())){ shop.setAccountFlag(1); this.saveOrUpdate(shop); } } } catch (WxPayException e) { throw new RuntimeException(e); } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/service/shop/ShopService.java
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverRequest; import com.github.binarywang.wxpay.bean.ecommerce.ProfitSharingReceiverResult; import com.github.binarywang.wxpay.exception.WxPayException; import com.ruoyi.shop.domain.dto.*; import com.ruoyi.shop.domain.vo.*; import com.ruoyi.system.api.domain.dto.MerBaseDto; @@ -207,7 +206,7 @@ * @param mgtShopAuthDto * @return void */ void mgtShopAuth(MgtShopAuthDto mgtShopAuthDto) throws WxPayException; void mgtShopAuth(MgtShopAuthDto mgtShopAuthDto); /** * @description 获取平台商户统计 @@ -367,15 +366,7 @@ * @return StaffShopDetailVo */ StaffShopDetailVo getShopDetail(Long shopId); /** * @description * @author jqs * @date 2023/8/23 9:44 * @param * @return void */ ProfitSharingReceiverResult addProfitSharingReceiver(ProfitSharingReceiverRequest request); /** * @description @@ -385,4 +376,13 @@ * @return List<MgtUserTaskMsgVo> */ List<MgtUserTaskMsgVo> getTaskMsgList(); /** * @description 添加分账方 * @author jqs * @date 2023/9/4 18:14 * @param mgtShopAuthGetDto * @return void */ void addProfitSharingReceiver(MgtShopAuthGetDto mgtShopAuthGetDto); } ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
@@ -417,7 +417,7 @@ AND ts.frozen_flag = 1 </if> <if test="param.shopStatus!=null and param.shopStatus==2"> AND ts.cooperative_flag = 0 AND ts.cooperation_end_time IS NOT NULL AND (CURRENT_DATE < Date(ts.cooperation_start_time) OR CURRENT_DATE > Date(ts.cooperation_end_time)) </if> <if test="param.keyword!=null and param.keyword!=''"> AND (ts.shop_name LIKE CONCAT('%',#{param.keyword},'%') OR ts.shopowner_name LIKE CONCAT('%',#{param.keyword},'%') @@ -547,10 +547,10 @@ WHEN 7 THEN '已拒绝' WHEN 8 THEN '已拒绝' END auditStatusDesc, ts.account_flag accountFlag, CASE tsa.audit_status WHEN 4 THEN 1 WHEN 5 THEN 1 END auditStatusSort FROM t_shop ts INNER JOIN t_shop_authentication tsa ON ts.shop_id = tsa.shop_id AND tsa.del_flag = 0 @@ -931,7 +931,7 @@ <select id="getTaskMsgList" resultType="com.ruoyi.system.api.domain.vo.MgtUserTaskMsgVo"> SELECT ts.belong_user_id userId, CONCAT('[', GROUP_CONCAT(tst.task_title SEPARATOR '],['), ']') taskTitles CONCAT('[', GROUP_CONCAT(tst.task_title SEPARATOR '],['), ']') taskTitle FROM t_shop_task tst INNER JOIN t_shop ts ON tst.shop_id = ts.shop_id WHERE tst.del_flag = 0 AND tst.task_status = 1 AND tst.task_date = CURRENT_DATE ruoyi-modules/ruoyi-system/pom.xml
@@ -78,6 +78,12 @@ <artifactId>ruoyi-common-swagger</artifactId> </dependency> <!-- RuoYi Common Seata--> <dependency> <groupId>com.ruoyi</groupId> <artifactId>ruoyi-common-seata</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpConfiguration.java
@@ -27,9 +27,8 @@ private WxCpProperties properties; @Bean @ConditionalOnMissingBean @ConditionalOnMissingBean(name = "wxService") public WxCpService wxService() { WxCpDefaultConfigImpl wxCpConfigStorage = new WxCpDefaultConfigImpl(); wxCpConfigStorage.setCorpId(properties.getCorpId()); wxCpConfigStorage.setAgentId(properties.getAgentId()); @@ -41,6 +40,20 @@ return wxService; } @Bean @ConditionalOnMissingBean(name = "adWxService") public WxCpService adWxService() { WxCpDefaultConfigImpl wxAdCpConfigStorage = new WxCpDefaultConfigImpl(); wxAdCpConfigStorage.setCorpId(properties.getCorpId()); wxAdCpConfigStorage.setAgentId(properties.getAgentId()); wxAdCpConfigStorage.setCorpSecret(properties.getAddressSecret()); wxAdCpConfigStorage.setAesKey(properties.getEncodingAESKey()); wxAdCpConfigStorage.setToken(properties.getToken()); WxCpService adWxService = new WxCpServiceImpl(); adWxService.setWxCpConfigStorage(wxAdCpConfigStorage); return adWxService; } @Bean @ConditionalOnMissingBean ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/config/WxCpProperties.java
@@ -29,6 +29,9 @@ */ private String agentSecret; private String addressSecret; /** * */ ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtConfigController.java
@@ -133,6 +133,16 @@ return R.ok(); } @RequestMapping(value = "/editShopProportion", method = RequestMethod.POST) @Log(title = "商户分成管理", businessType = BusinessType.UPDATE,operContent = "修改商户分成") @ApiOperation(value = "修改商户分成") public R editShopProportion(@RequestBody MgtShopCommonProportionEditDto mgtShopCommonProportionEditDto) { Long userId = SecurityUtils.getUserId(); mgtShopCommonProportionEditDto.setUserId(userId); customConfigService.editShopProportion(mgtShopCommonProportionEditDto); return R.ok(); } @RequestMapping(value = "/editAgreement", method = RequestMethod.POST) @Log(title = "协议管理", businessType = BusinessType.UPDATE,operContent = "修改协议") @ApiOperation(value = "修改协议") ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtShopCommonProportionEditDto.java
New file @@ -0,0 +1,21 @@ package com.ruoyi.system.domain.dto; import com.ruoyi.system.api.domain.dto.MgtBaseDto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @ClassName MgtShopCommonProportionEditDto * @Description TODO * @Author jqs * @Date 2023/9/4 18:03 * @Version 1.0 */ @Data public class MgtShopCommonProportionEditDto extends MgtBaseDto { @ApiModelProperty(value = "商户统一分成比例") private String shopCommonProportion; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtWxCPStaffDto.java
New file @@ -0,0 +1,36 @@ package com.ruoyi.system.domain.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * @ClassName MgtWxCPStaffDto * @Description TODO * @Author jqs * @Date 2023/9/4 16:49 * @Version 1.0 */ @Data public class MgtWxCPStaffDto { @ApiModelProperty(value = "微信部门id") private Long wxDeptId; @ApiModelProperty(value = "微信用户id") private String wxUserId; @ApiModelProperty(value = "员工姓名") private String staffName; @ApiModelProperty(value = "员工电话") private String staffMobile; @ApiModelProperty(value = "员工职位") private String staffPost; @ApiModelProperty(value = "员工邮箱") private String staffEmail; @ApiModelProperty(value = "负责人标记") private String headFlag; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/listener/RedisListener.java
@@ -8,7 +8,7 @@ import com.ruoyi.system.api.service.RemoteConfigService; import com.ruoyi.system.api.service.RemoteCouponService; import com.ruoyi.system.api.service.RemoteOrderService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; @@ -26,7 +26,7 @@ * @date 2023年06月06日 * @version: 1.0 */ @Slf4j @Log4j2 @Component public class RedisListener extends KeyExpirationEventMessageListener { ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java
@@ -2,14 +2,14 @@ import com.ruoyi.system.service.staff.SysWxCpService; import lombok.extern.slf4j.Slf4j; import lombok.extern.log4j.Log4j2; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @Component @Slf4j @Log4j2 public class SystemScheduler { ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/config/CustomConfigService.java
@@ -49,6 +49,15 @@ void editServiceCode(MgtServiceCodeEditDto mgtServiceCodeEditDto); /** * @description 修改统一分成 * @author jqs * @date 2023/9/4 18:05 * @param mgtShopCommonProportionEditDto * @return void */ void editShopProportion(MgtShopCommonProportionEditDto mgtShopCommonProportionEditDto); /** * @description 平台获取自定义配置 * @author jqs * @date 2023/6/7 15:02 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/config/CustomConfigServiceImpl.java
@@ -137,6 +137,34 @@ } /** * @description 修改统一分成 * @author jqs * @date 2023/9/4 18:05 * @param mgtShopCommonProportionEditDto * @return void */ @Override public void editShopProportion(MgtShopCommonProportionEditDto mgtShopCommonProportionEditDto){ // 获取平台统一分成的配置 CustomConfig customConfig = getByKey(ConfigEnum.SHOP_COMMON_PROPORTION.getKey()); // 如果配置不存在,则创建一个新的配置 if (customConfig == null) { customConfig = new CustomConfig(); customConfig.setCreateTime(new Date()); customConfig.setDelFlag(0); } // 设置配置的类型、键、名称、值和更新时间 customConfig.setConfigType(ConfigEnum.SHOP_COMMON_PROPORTION.getKeyType()); customConfig.setConfigKey(ConfigEnum.SHOP_COMMON_PROPORTION.getKey()); customConfig.setConfigName(ConfigEnum.SHOP_COMMON_PROPORTION.getKeyName()); customConfig.setConfigValue(mgtShopCommonProportionEditDto.getShopCommonProportion()); customConfig.setUpdateTime(new Date()); // 保存或更新配置 this.saveOrUpdate(customConfig); redisService.setCacheObject(SecurityConstant.SHOP_COMMON_PROPORTION,mgtShopCommonProportionEditDto.getShopCommonProportion()); } /** * @param * @return MgtCustomConfigVo * @description 平台获取自定义配置 ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java
@@ -4,6 +4,7 @@ import com.ruoyi.system.api.domain.poji.sys.SysDept; import com.ruoyi.system.api.domain.vo.MgtUserTaskMsgVo; import com.ruoyi.system.api.service.RemoteShopService; import com.ruoyi.system.domain.dto.MgtWxCPStaffDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.ruoyi.system.service.staff.SysStaffService; import com.ruoyi.system.service.staff.SysWxCpService; @@ -13,8 +14,11 @@ import me.chanjar.weixin.cp.api.WxCpDepartmentService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpDepart; import me.chanjar.weixin.cp.bean.WxCpUser; import me.chanjar.weixin.cp.bean.message.WxCpMessage; import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -31,8 +35,13 @@ @Log4j2 public class SysWxCpServiceImpl implements SysWxCpService { @Resource @Autowired @Qualifier("wxService") private WxCpService wxCpService; @Autowired @Qualifier("adWxService") private WxCpService adWxCpService; @Resource private RemoteShopService remoteShopService; @@ -42,6 +51,7 @@ @Resource private SysStaffService sysStaffService; /** * @description * @author jqs @@ -142,28 +152,193 @@ } } /** * @description 更新企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param wxDeptId * @param deptName * @return void */ @Override public void updateDept(){ public void updateWxCpDept(Long wxDeptId,String deptName){ WxCpDepart group = new WxCpDepart(); group.setId(240L); group.setName("软件开发测试部门"); group.setId(wxDeptId); group.setName(deptName); try { wxCpService.getDepartmentService().update(group); adWxCpService.getDepartmentService().update(group); } catch (WxErrorException e) { throw new RuntimeException(e); } } /** * @description 创建企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param parentId * @param deptName * @return void */ @Override public void sendMessage(){ WxCpMessage message; message = new WxCpMessage(); message.setAgentId(1000024); message.setToUser("jiangqiushi"); message.setMsgType("text"); message.setContent("今日需要任务跟进,请注意!"); public Long addWxCpDept(Long parentId,String deptName){ WxCpDepart depart = new WxCpDepart(); depart.setParentId(parentId); depart.setName(deptName); Long departId = null; try { WxCpMessageSendResult result = wxCpService.getMessageService().send(message); departId = adWxCpService.getDepartmentService().create(depart); } catch (WxErrorException e) { throw new RuntimeException(e); } return departId; } /** * @description 删除企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param wxDeptId * @return void */ @Override public void deleteWxCpDept(Long wxDeptId){ try { adWxCpService.getDepartmentService().delete(wxDeptId); } catch (WxErrorException e) { throw new RuntimeException(e); } } /** * @description 通过手机号获取wxUserId * @author jqs * @date 2023/9/4 15:44 * @param mobile * @return String */ private String getWxUserIdByMobile(String mobile){ String wxUserId = null; try { wxUserId = adWxCpService.getUserService().getUserId(mobile); } catch (WxErrorException e) { throw new RuntimeException(e); } return wxUserId; } /** * @description 通过wxUserId获取用户 * @author jqs * @date 2023/9/4 16:35 * @param wxUserId * @return WxCpUser */ private WxCpUser getWxCpUser(String wxUserId){ WxCpUser wxCpUser = null; try { wxCpUser = adWxCpService.getUserService().getById(wxUserId); } catch (WxErrorException e) { throw new RuntimeException(e); } return wxCpUser; } /** * @description 创建企业微信员工 * @author jqs * @date 2023/9/4 15:19 * @param mgtWxCPStaffDto * @return void */ @Override public String addWxCpStaff(MgtWxCPStaffDto mgtWxCPStaffDto){ String wxUserId = mgtWxCPStaffDto.getWxUserId(); String mobile = mgtWxCPStaffDto.getStaffMobile(); String oldUserId = this.getWxUserIdByMobile(mobile); WxCpUser oldWxCpUser = null; Boolean sameUserId = false; //判断手机号是否有对应企业微信用户 有则更新 无则新建 if(StringUtils.isNotBlank(oldUserId)){ oldWxCpUser = this.getWxCpUser(oldUserId); }else{ //当手机号无对应用户时判断wxUserId是否被占用 oldWxCpUser = this.getWxCpUser(wxUserId); if(oldWxCpUser!=null){ sameUserId = true; oldWxCpUser = null; } } //获取企业微信用户是否存在 if(oldWxCpUser!=null){ oldWxCpUser.setUserId(mgtWxCPStaffDto.getWxUserId()); oldWxCpUser.setName(mgtWxCPStaffDto.getStaffName()); oldWxCpUser.setMobile(mgtWxCPStaffDto.getStaffMobile()); if(StringUtils.isNotBlank(mgtWxCPStaffDto.getStaffEmail())){ oldWxCpUser.setEmail(mgtWxCPStaffDto.getStaffEmail()); } if(StringUtils.isNotBlank(mgtWxCPStaffDto.getStaffPost())){ oldWxCpUser.setPosition(mgtWxCPStaffDto.getStaffPost()); } oldWxCpUser.setPosition(mgtWxCPStaffDto.getStaffPost()); Long[] departIds = new Long[1]; departIds[0] = mgtWxCPStaffDto.getWxDeptId(); oldWxCpUser.setDepartIds(departIds); if(mgtWxCPStaffDto.getHeadFlag()!=null){ Integer[] isLeaderInDept = new Integer[1]; isLeaderInDept[0] = Integer.valueOf(mgtWxCPStaffDto.getHeadFlag()); oldWxCpUser.setIsLeaderInDept(isLeaderInDept); } try { adWxCpService.getUserService().update(oldWxCpUser); } catch (WxErrorException e) { throw new RuntimeException(e); } }else{ WxCpUser wxCpUser = new WxCpUser(); //wxUserId被占用重新生成 if(sameUserId){ wxUserId = wxUserId + "1"; } wxCpUser.setUserId(wxUserId); wxCpUser.setName(mgtWxCPStaffDto.getStaffName()); wxCpUser.setMobile(mgtWxCPStaffDto.getStaffMobile()); if(StringUtils.isNotBlank(mgtWxCPStaffDto.getStaffEmail())){ wxCpUser.setEmail(mgtWxCPStaffDto.getStaffEmail()); } if(StringUtils.isNotBlank(mgtWxCPStaffDto.getStaffPost())){ wxCpUser.setPosition(mgtWxCPStaffDto.getStaffPost()); } wxCpUser.setPosition(mgtWxCPStaffDto.getStaffPost()); Long[] departIds = new Long[1]; departIds[0] = mgtWxCPStaffDto.getWxDeptId(); wxCpUser.setDepartIds(departIds); if(mgtWxCPStaffDto.getHeadFlag()!=null){ Integer[] isLeaderInDept = new Integer[1]; isLeaderInDept[0] = Integer.valueOf(mgtWxCPStaffDto.getHeadFlag()); wxCpUser.setIsLeaderInDept(isLeaderInDept); } try { adWxCpService.getUserService().create(wxCpUser); } catch (WxErrorException e) { throw new RuntimeException(e); } } return wxUserId; } /** * @description 删除企业微信员工 * @author jqs * @date 2023/9/4 15:19 * @param wxUserId * @return void */ @Override public void deleteWxCpStaff(String wxUserId){ try { adWxCpService.getUserService().delete(wxUserId); } catch (WxErrorException e) { throw new RuntimeException(e); } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/sys/SysDeptServiceImpl.java
@@ -15,10 +15,12 @@ import com.ruoyi.system.mapper.sys.SysDeptMapper; import com.ruoyi.system.mapper.sys.SysDeptMenuMapper; import com.ruoyi.system.mapper.sys.SysRoleMapper; import com.ruoyi.system.service.staff.SysWxCpService; import com.ruoyi.system.service.sys.ISysDeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -40,6 +42,9 @@ @Autowired private SysDeptMenuMapper deptMenuMapper; @Resource private SysWxCpService sysWxCpService; /** * 查询部门管理数据 @@ -338,6 +343,10 @@ @Override public int deleteDeptById(Long deptId) { SysDept sysDept = this.selectDeptById(deptId); if(sysDept.getWxDeptId()!=null){ sysWxCpService.deleteWxCpDept(sysDept.getWxDeptId()); } return deptMapper.deleteDeptById(deptId); } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysWxCpService.java
@@ -1,5 +1,7 @@ package com.ruoyi.system.service.staff; import com.ruoyi.system.domain.dto.MgtWxCPStaffDto; /** * @ClassName WxCpService * @Description TODO @@ -35,8 +37,51 @@ */ void sendTaskMessage(); /** * @description 更新企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param wxDeptId * @param deptName * @return void */ void updateWxCpDept(Long wxDeptId,String deptName); void updateDept(); /** * @description 创建企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param parentId * @param deptName * @return void */ Long addWxCpDept(Long parentId,String deptName); void sendMessage(); /** * @description 删除企业微信部门 * @author jqs * @date 2023/9/4 15:19 * @param wxDeptId * @return void */ void deleteWxCpDept(Long wxDeptId); /** * @description 创建企业微信员工 * @author jqs * @date 2023/9/4 15:19 * @param mgtWxCPStaffDto * @return void */ String addWxCpStaff(MgtWxCPStaffDto mgtWxCPStaffDto); /** * @description 删除企业微信员工 * @author jqs * @date 2023/9/4 15:19 * @param wxUserId * @return void */ void deleteWxCpStaff(String wxUserId); } ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
@@ -48,7 +48,7 @@ agentId: 1000024 agentSecret: -wuQ2EBxNT9BJa40LdpFqyxI_8RqrZTCUNiabzBasi8 authorizeState: HONGRUITANG suiteSecret: HoHhls3QUFESA2wDypkaWvldYYHBciwZJ2zEpPVrjNx addressSecret: D5rirpvzRnygC0RncaUdooxAwvXTA7In9dqvPHvnV4w token: HaiHeng2023 encodingAESKey: jWmYm7qr5nMoAUwZRjGtBxmz3KA1tkAj3ykkR6q2B2C ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java
@@ -2,7 +2,8 @@ import com.ruoyi.system.service.staff.SysWxCpService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.common.error.WxErrorException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -23,11 +24,9 @@ @Resource private SysWxCpService sysWxCpService; @Resource private WxCpService wxCpService; /*@Test @Test public void main() throws WxErrorException { }*/ sysWxCpService.sendMessage(); sysWxCpService.updateDept(); } }