ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/dto/AppMemberBindingDto.java
@@ -19,6 +19,9 @@ @ApiModelProperty(value = "商户id") private Long shopId; @ApiModelProperty(value = "绑定类型1商城订单2活动订单3线下订单4核销优惠券5核销奖品6商户创建会员7平台变动") private Integer bindingType; @ApiModelProperty(value = "商户名称") private String shopName; } ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/system/api/domain/poji/member/Member.java
@@ -166,6 +166,11 @@ @TableField("frozen_flag") private Integer frozenFlag; /** * 绑定类型1商城订单2活动订单3线下订单4核销优惠券5核销奖品6商户创建7平台变动 */ @TableField("binding_type") private Integer bindingType; @Override protected Serializable pkVal() { ruoyi-modules/ruoyi-file/src/main/resources/bootstrap.yml
@@ -21,10 +21,18 @@ # 服务注册地址 server-addr: 47.109.78.184:5000 #server-addr: 127.0.0.1:8848 #pro #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639 #dev namespace: d39a744d-116f-4280-8445-0502dd1a3116 config: # 配置中心地址 server-addr: 47.109.78.184:5000 #server-addr: 127.0.0.1:8848 #pro #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639 #dev namespace: d39a744d-116f-4280-8445-0502dd1a3116 # 配置文件格式 file-extension: yml # 共享配置 ruoyi-modules/ruoyi-member/src/main/java/com/ruoyi/member/service/impl/member/MemberServiceImpl.java
@@ -527,6 +527,7 @@ member.setBindingFlag(appMemberBindingDto.getBindingFlag()); member.setRelationShopId(appMemberBindingDto.getShopId()); member.setRelationShopName(appMemberBindingDto.getShopName()); member.setBindingType(appMemberBindingDto.getBindingType()); this.saveOrUpdate(member); } @@ -659,6 +660,7 @@ member.setMiniOpenid(null); member.setBindingFlag(1); member.setBindingTime(new Date()); member.setBindingType(6); // Get shop information and set it to the member Shop shop = remoteShopService.getShop(merMemberAddDto.getShopId()).getData(); member.setRelationShopName(shop.getShopName()); @@ -971,6 +973,7 @@ member.setRelationShopId(shop.getShopId()); member.setRelationShopName(shop.getShopName()); member.setBindingFlag(1); member.setBindingType(7); member.setBindingTime(new Date()); member.setUpdateTime(new Date()); member.setUpdateUserId(mgtMemberRelEditDto.getUserId()); ruoyi-modules/ruoyi-order/pom.xml
@@ -102,20 +102,17 @@ <version>2.3.3</version> </dependency> <!-- 微信支付分提供的工具包,用于生成公用的http-client客户端 --> <dependency> <groupId>com.github.wechatpay-apiv3</groupId> <artifactId>wechatpay-apache-httpclient</artifactId> <version>0.4.9</version> </dependency> <dependency> <groupId>com.github.wechatpay-apiv3</groupId> <artifactId>wechatpay-java</artifactId> <version>0.2.10</version> </dependency> <dependency> <groupId>com.github.binarywang</groupId> <artifactId>weixin-java-miniapp</artifactId> @@ -126,12 +123,26 @@ <artifactId>weixin-java-pay</artifactId> <version>4.5.0</version> </dependency> <!-- 阿里云 --> <dependency> <groupId>com.aliyun</groupId> <artifactId>alibabacloud-dysmsapi20170525</artifactId> <version>2.0.24</version> </dependency> <!-- 测试类 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>2.7.7</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.1</version> <scope>test</scope> </dependency> </dependencies> <build> ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/config/WxPayConfiguration.java
@@ -42,6 +42,7 @@ payConfig.setApiV3Key(StringUtils.trimToNull(this.properties.getApiV3Key())); payConfig.setPrivateKeyPath(StringUtils.trimToNull(this.properties.getPrivateKeyPath())); payConfig.setPrivateCertPath(StringUtils.trimToNull(this.properties.getPrivateCertPath())); payConfig.setNotifyUrl("https://wxapp.hhhrt.cn/order/app/notify/payNotify"); // 平台特约商户号 PLATFORM_TY_MAC_ID = this.properties.getPlatformTyMacId(); ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/controller/miniapp/AppOrderController.java
@@ -107,6 +107,7 @@ appMemberBindingDto.setShopId(appPlaceOrderDto.getShopId()); appMemberBindingDto.setUserId(userId); appMemberBindingDto.setBindingFlag(1); appMemberBindingDto.setBindingType(1); memberService.updateMemberBinding(appMemberBindingDto); } } @@ -131,6 +132,7 @@ appMemberBindingDto.setShopId(appPlaceActivityDto.getShopId()); appMemberBindingDto.setUserId(userId); appMemberBindingDto.setBindingFlag(1); appMemberBindingDto.setBindingType(2); memberService.updateMemberBinding(appMemberBindingDto); } } ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -5,9 +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.ecommerce.PartnerTransactionsRequest; import com.github.binarywang.wxpay.bean.ecommerce.PartnerTransactionsResult; import com.github.binarywang.wxpay.bean.ecommerce.RefundNotifyResult; import com.github.binarywang.wxpay.bean.ecommerce.TransactionsResult; import com.github.binarywang.wxpay.bean.ecommerce.enums.TradeTypeEnum; import com.github.binarywang.wxpay.bean.profitsharingV3.ProfitSharingNotifyResult; import com.github.binarywang.wxpay.config.WxPayConfig; 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.exception.ServiceException; import com.ruoyi.common.core.utils.DateUtils; import com.ruoyi.common.core.utils.StringUtils; @@ -52,7 +60,6 @@ import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -119,11 +126,11 @@ @Resource private PayRecordService payRecordService; @Autowired @Resource private RedissonClient redissonClient; /*@Autowired private WxPayService wxService;*/ @Resource private WxPayService wxService; @Resource private PaymentMessageService paymentMessageService; @@ -740,8 +747,8 @@ appPlaceOrderVo.setOrderNo(orderNo); String goodsName = ""; if (null != goods) { goodsName = goods.getGoodsName(); if (null != goodsNameList) { goodsName = String.join(",", goodsNameList); } // 小程序微信下单支付 @@ -784,14 +791,14 @@ * @param payerClientIp * @param goodsNameList */ /*private void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId, public void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId, String goodsName, String orderNo, String orderId, BigDecimal payMoney, String openid, String payerClientIp, List<String> goodsNameList){ try { // 创建支付订单 R<String> resultMch = remoteShopService.getShopSubMchId(shopId); String subMchId = resultMch.getData(); //R<String> resultMch = remoteShopService.getShopSubMchId(shopId); String subMchId = "1650744551"; if (StringUtils.isEmpty(subMchId)) { throw new ServiceException("获取微信商户号失败"); } @@ -859,7 +866,7 @@ } catch (WxPayException e) { throw new ServiceException(e.getMessage()); } }*/ } /** @@ -1712,6 +1719,7 @@ if (member.getBindingFlag() != 1) { AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto(); appMemberBindingDto.setBindingFlag(1); appMemberBindingDto.setBindingType(4); appMemberBindingDto.setShopId(shop.getShopId()); appMemberBindingDto.setShopName(shop.getShopName()); appMemberBindingDto.setUserId(memberCoupon.getUserId()); @@ -1828,6 +1836,7 @@ if (member.getBindingFlag() != 1) { AppMemberBindingDto appMemberBindingDto = new AppMemberBindingDto(); appMemberBindingDto.setBindingFlag(1); appMemberBindingDto.setBindingType(5); appMemberBindingDto.setShopId(shop.getShopId()); appMemberBindingDto.setShopName(shop.getShopName()); appMemberBindingDto.setUserId(memberGiftRecord.getUserId()); @@ -1920,7 +1929,6 @@ sysUser.setAvatar("https://hongruitang.oss-cn-beijing.aliyuncs.com/default.png"); String password = "hongruitang"; sysUser.setPassword(SecurityUtils.encryptPassword(password)); log.debug("sysUser" + sysUser.toString()); sysUser = remoteUserService.registerUser(sysUser).getData(); member = new Member(); member.setMemberId(memberId); @@ -1929,6 +1937,7 @@ member.setRealName(name); member.setNickName(name); member.setBindingFlag(1); member.setBindingType(3); member.setRelationShopId(shopId); member.setRelationShopName(shop.getShopName()); remoteMemberService.createNewMember(member); @@ -2188,6 +2197,7 @@ appMemberBindingDto.setShopName(shop.getShopName()); appMemberBindingDto.setUserId(userId); appMemberBindingDto.setBindingFlag(1); appMemberBindingDto.setBindingType(3); remoteMemberService.updateMemberBinding(appMemberBindingDto); } //更新商户统计 @@ -2217,10 +2227,12 @@ @Override public List<MerOrderPageVo> pageMerOrder(Page page, MerOrderPageDto merOrderPageDto) { if (StringUtils.isNotBlank(merOrderPageDto.getKeyword())) { // 获取关键字对应的用户ID MgtUserIdByKeywordDto userIdByKeywordDto = new MgtUserIdByKeywordDto(); userIdByKeywordDto.setKeyword(merOrderPageDto.getKeyword()); MgtUserIdByKeywordVo userIdByKeywordVo = remoteMemberService.getUserIdByKeyword(userIdByKeywordDto).getData(); if (StringUtils.isNotBlank(userIdByKeywordVo.getUserIds())) { // 将用户ID转换成List<Long>类型 List<Long> userIdList = Arrays.stream(userIdByKeywordVo.getUserIds().split(",")) .map(Long::parseLong) .collect(Collectors.toList()); @@ -2228,6 +2240,8 @@ merOrderPageDto.setMemberUserId(null); } } // 获取订单列表 List<MerOrderPageVo> merOrderPageVoList = orderMapper.pageMerOrder(page, merOrderPageDto); if (merOrderPageVoList != null && !merOrderPageVoList.isEmpty()) { Long userId; @@ -2236,15 +2250,17 @@ String orderFromDesc; BigDecimal zeroBig = new BigDecimal("0.00"); StringJoiner userIdSj = new StringJoiner(","); // 遍历订单列表 for (MerOrderPageVo merOrderPageVo : merOrderPageVoList) { userId = merOrderPageVo.getUserId(); userIdSj.add(userId.toString()); orderFrom = merOrderPageVo.getOrderFrom(); // 根据订单来源设置订单来源描述 if (orderFrom != null) { if (orderFrom == 1) { orderFromDesc = "商城订单"; } else if(orderFrom == 2){ orderFromDesc = "店铺砍价活动("+merOrderPageVo.getActivityName()+")"; } else if (orderFrom == 2) { orderFromDesc = "店铺砍价活动(" + merOrderPageVo.getActivityName() + ")"; } else { orderFromDesc = "线下创建"; } @@ -2252,18 +2268,22 @@ orderFromDesc = "商城订单"; } merOrderPageVo.setOrderFromDesc(orderFromDesc); // 设置未支付金额为0.00,如果未支付金额小于0,则设置为0.00 if (merOrderPageVo.getUnPaidMoney() == null) { merOrderPageVo.setUnPaidMoney(zeroBig); } if(merOrderPageVo.getUnPaidMoney().compareTo(zeroBig)<0){ if (merOrderPageVo.getUnPaidMoney().compareTo(zeroBig) < 0) { merOrderPageVo.setUnPaidMoney(zeroBig); } } // 根据用户ID列表获取用户信息 MgtBaseBathDto mgtBaseBathDto = new MgtBaseBathDto(); mgtBaseBathDto.setIds(userIdSj.toString()); List<MgtSimpleMemberVo> simpleMemberVoList = remoteMemberService.listSimpleVoByIds(mgtBaseBathDto).getData(); Map<Long, MgtSimpleMemberVo> userMap = simpleMemberVoList.stream() .collect(Collectors.toMap(MgtSimpleMemberVo::getUserId, Function.identity())); // 遍历订单列表,设置用户信息 for (MerOrderPageVo merOrderPageVo : merOrderPageVoList) { if (merOrderPageVo.getUserId() != null && userMap.get(merOrderPageVo.getUserId()) != null) { merOrderPageVo.setUserName(userMap.get(merOrderPageVo.getUserId()).getRealName()); ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/order/OrderService.java
@@ -521,4 +521,10 @@ * @return */ List<MerOrderPageVo> pageMerMemberPayOrder(Page page,MerMemberNoClearOrderDto merOrderPageDto); void createWxPayInfo(AppPlaceOrderVo appPlaceOrderVo, Long userId, Long shopId, String goodsName, String orderNo, String orderId, BigDecimal payMoney, String openid, String payerClientIp, List<String> goodsNameList); } ruoyi-modules/ruoyi-order/src/main/resources/bootstrap.yml
@@ -16,10 +16,18 @@ # 服务注册地址 server-addr: 47.109.78.184:5000 #server-addr: 127.0.0.1:8848 #pro #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639 #dev namespace: d39a744d-116f-4280-8445-0502dd1a3116 config: # 配置中心地址 server-addr: 47.109.78.184:5000 #server-addr: 127.0.0.1:8848 #pro #namespace: 9591ef9f-a49a-4900-be35-d77258bdd639 #dev namespace: d39a744d-116f-4280-8445-0502dd1a3116 # 配置文件格式 file-extension: yml # 共享配置 ruoyi-modules/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -1719,7 +1719,7 @@ <if test="param.goodsType !=null and param.goodsType != ''"> AND tog.goods_type = #{param.goodsType} </if> GROUP BY toc.create_time GROUP BY mapKey </select> <select id="getStaffActivityMemberTotal" resultType="com.ruoyi.system.api.domain.vo.MgtMapIntTotalVo"> @@ -1735,7 +1735,7 @@ <if test="param.goodsType !=null and param.goodsType != ''"> AND tog.goods_type = #{param.goodsType} </if> GROUP BY toc.create_time GROUP BY mapKey </select> <select id="countUserBuyGoodsNum" resultType="java.lang.Integer"> ruoyi-modules/ruoyi-order/src/test/java/com/ruoyi/order/orderTest.java
New file @@ -0,0 +1,38 @@ package com.ruoyi.order; import com.ruoyi.order.service.order.OrderService; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import javax.annotation.Resource; /** * @ClassName orderTest * @Description TODO * @Author jqs * @Date 2023/8/18 11:12 * @Version 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = RuoYiOrderApplication.class) public class orderTest { @Resource private OrderService orderService; /*@Test public void main() { AppPlaceOrderVo appPlaceOrderVo = new AppPlaceOrderVo(); orderService.createWxPayInfo( appPlaceOrderVo, 280L, 50L, "测试支付商品", "SC202308160046", "0fa36ad3edcc40bebc2795cc505b5272", new BigDecimal("0.1"), "oL-gp5GG6-KRVSIAE_qYLMULPFjw", "127.0.0.1", Arrays.asList("测试支付商品")); System.out.println(appPlaceOrderVo.toString()); }*/ } ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/domain/vo/MerAgencyPageVo.java
@@ -22,6 +22,9 @@ @ApiModelProperty(value="商户状态0冻结1正常2终止合作") private Integer shopStatus; @ApiModelProperty(value = "商户图片") private String shopPicture; @ApiModelProperty(value = "商户名称") private String shopName; ruoyi-modules/ruoyi-shop/src/main/resources/mapper/shop/ShopMapper.xml
@@ -405,8 +405,10 @@ ts.shopowner_name shopownerName, ts.shopowner_phone shopownerPhone, ts.cooperation_end_time cooperationEndTime, ts.cooperative_flag cooperativeFlag ts.cooperative_flag cooperativeFlag, tsf.file_uel shopPicture FROM t_shop ts LEFT JOIN t_shop_file tsf ON tsf.shop_id = ts.shop_id AND tsf.del_flag = 0 AND tsf.file_type = 1 WHERE ts.del_flag = 0 AND ts.belong_shop_id = #{param.shopId} <if test="param.shopStatus!=null and param.shopStatus==1"> AND ts.shop_status = 1 ruoyi-modules/ruoyi-system/pom.xml
@@ -102,6 +102,7 @@ <version>2.3.3</version> </dependency> <!-- 测试类 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/conslole/QYWXCallBackController.java
@@ -1,12 +1,13 @@ package com.ruoyi.system.controller.conslole; import com.ruoyi.common.core.utils.StringUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.log4j.Log4j2; import me.chanjar.weixin.common.util.crypto.WxCryptUtil; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -31,9 +32,8 @@ private WxCryptUtil wxCryptUtil; @ApiOperation(value = "消息与事件接收配置") @RequestMapping(value = "/qywxNotify", method = RequestMethod.POST,consumes = "text/xml",produces = "text/xml;charset=utf-8") public String wechatPlatformEvent(@PathVariable String APPID, @RequestMapping(value = "/qywxNotify", method = {RequestMethod.GET,RequestMethod.POST}) public String wechatPlatformEvent(@RequestBody(required = false) String body, HttpServletRequest request, HttpServletResponse response ) throws Exception { @@ -49,8 +49,10 @@ log.info("企业微信回调参数msgSignature"+msgSignature); log.info("企业微信回调参数encType"+encType); log.info("企业微信回调参数xml"+xml); String reponseStr = wxCryptUtil.decryptXml(msgSignature,timestamp,nonce,xml); log.info("企业微信回调参数xml解析"+reponseStr); if(StringUtils.isNotBlank(msgSignature)&&StringUtils.isNotBlank(timestamp)&&StringUtils.isNotBlank(nonce)&&StringUtils.isNotBlank(xml)){ String reponseStr = wxCryptUtil.decryptXml(msgSignature,timestamp,nonce,xml); log.info("企业微信回调参数xml解析"+reponseStr); } return "SUCCESS"; } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/management/MgtStaffController.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.security.utils.SecurityUtils; @@ -17,14 +18,14 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.util.List; import static com.ruoyi.common.core.web.domain.AjaxResult.success; /** * @author jqs34 @@ -150,4 +151,14 @@ sysStaffService.mgtDeleteStaff(mgtBaseGetDto); return R.ok(); } @ApiOperation(value = "导入员工数据") @PostMapping("/importSysStaff") public AjaxResult importSysStaff(@RequestPart("file") MultipartFile file) throws Exception { ExcelUtil<MgtSysStaffImportDto> util = new ExcelUtil<MgtSysStaffImportDto>(MgtSysStaffImportDto.class); List<MgtSysStaffImportDto> sysStaffImportDtoList = util.importExcel(file.getInputStream()); String message = sysStaffService.importSysStaff(sysStaffImportDtoList); return success(message); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/staff/StaffSysController.java
@@ -2,10 +2,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.common.core.domain.R; import com.ruoyi.common.core.utils.poi.ExcelUtil; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.system.api.domain.dto.MerPageDto; import com.ruoyi.system.api.domain.dto.StaffPageDto; import com.ruoyi.system.api.domain.poji.sys.SysUser; import com.ruoyi.system.domain.dto.MgtSysStaffImportDto; import com.ruoyi.system.domain.dto.StaffUseSuggestDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.ruoyi.system.domain.vo.StaffSuggestPageVo; @@ -15,13 +17,13 @@ import com.ruoyi.system.service.sys.ISysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.util.List; import static com.ruoyi.common.core.web.domain.AjaxResult.success; /** * @author jqs34 @@ -80,4 +82,6 @@ List<StaffSuggestPageVo> staffSuggestPageVoList = staffSuggestService.pageStaffShopSuggest(page,staffPageDto); return R.ok(page.setRecords(staffSuggestPageVoList)); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/MgtSysStaffImportDto.java
New file @@ -0,0 +1,42 @@ package com.ruoyi.system.domain.dto; import com.ruoyi.common.core.annotation.Excel; import lombok.Data; /** * @ClassName MgtSysStaffImportDto * @Description TODO * @Author jqs * @Date 2023/8/18 15:56 * @Version 1.0 */ @Data public class MgtSysStaffImportDto { @Excel(name = "姓名") private String staffName; @Excel(name = "账号") private String userName; @Excel(name = "昵称") private String nickName; @Excel(name = "职务") private String post; @Excel(name = "部门") private String department; @Excel(name = "性别") private String gender; @Excel(name = "手机") private String mobile; @Excel(name = "座机") private String phone; @Excel(name = "邮箱") private String email; } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/pojo/staff/SysStaff.java
@@ -72,6 +72,9 @@ @TableField("head_flag") private String headFlag; /** * 企业微信userId */ @TableField("wx_user_id") private String wxUserId; ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/scheduler/SystemScheduler.java
@@ -24,7 +24,7 @@ /** * 定时同步企业微信部门 */ @Scheduled(cron="0 2 * * * ?") @Scheduled(cron="0 0 2 * * ?") private void timingCheckMemberCoupon(){ if(schedulerUtils.getSchedulerRun()) { log.info("定时同步企业微信部门任务开始执行"); ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysStaffServiceImpl.java
@@ -18,6 +18,7 @@ import com.ruoyi.system.api.service.RemoteShopService; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.dto.MgtStaffPageDto; import com.ruoyi.system.domain.dto.MgtSysStaffImportDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.ruoyi.system.domain.vo.MgtDeptStaffListVo; import com.ruoyi.system.domain.vo.MgtStaffPageVo; @@ -28,6 +29,7 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; import java.util.List; import java.util.concurrent.TimeUnit; @@ -218,19 +220,7 @@ } /** * @description 同步组织架构 * @author jqs * @date 2023/7/18 19:06 * @param * @return void */ @Override public void synchronizeOrganizationalStructure(){ String accessToken = getQYToken(); } /** @@ -291,4 +281,63 @@ } this.saveOrUpdate(sysStaff); } /** * @description 导入员工 * @author jqs * @date 2023/8/18 16:04 * @param * @return void */ @Override public String importSysStaff(List<MgtSysStaffImportDto> staffImportDtoList){ if (StringUtils.isNull(staffImportDtoList) || staffImportDtoList.size() == 0) { throw new ServiceException("导入数据不能为空!"); } int successNum = 0; int failureNum = 0; StringBuilder successMsg = new StringBuilder(); StringBuilder failureMsg = new StringBuilder(); SysStaff sysStaff; Date nowTime = new Date(); for (MgtSysStaffImportDto entity : staffImportDtoList) { try { /*tagName = entity.getTagName(); sysTagSame = null; // 验证是否存在这个用户 queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(SysTag::getDelFlag, 0) // 查询条件:delFlag=0 .eq(SysTag::getTagType, tagType) // 查询条件:tagType=mgtTagEditDto的tagType属性 .eq(SysTag::getTagName, tagName); // 查询条件:tagName=mgtTagEditDto的tagName属性 // 执行查询,获取与查询条件匹配的SysTag对象 sysTagSame = this.getOne(queryWrapper); if (sysTagSame == null) { sysTagNew = new SysTag(); sysTagNew.setDelFlag(0); sysTagNew.setTagType(tagType); sysTagNew.setTagName(tagName); sysTagNew.setCreateTime(nowTime); sysTagNew.setSynFlag(0); this.save(sysTagNew); successNum++; successMsg.append("<br/>" + successNum + "、标签 " + sysTagNew.getTagName() + " 导入成功"); } else { failureNum++; failureMsg.append("<br/>" + failureNum + "、标签 " + sysTagSame.getTagName() + " 已存在"); }*/ } catch (Exception e) { failureNum++; String msg = "<br/>" + failureNum + "、标签 " + entity.getStaffName() + " 导入失败:"; failureMsg.append(msg + e.getMessage()); log.error(msg, e); } } if (failureNum > 0) { failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); throw new ServiceException(failureMsg.toString()); } else { successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); } return successMsg.toString(); } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/staff/SysWxCpServiceImpl.java
@@ -62,28 +62,31 @@ List<WxCpDepart> wxCpDepartList = wxCpDepartmentService.list(null); if(wxCpDepartList!=null&&wxCpDepartList.size()>0){ for(WxCpDepart wxCpDepart : wxCpDepartList){ //获取系统内对应部门 SysDept sysDept = sysDeptService.getByWxDeptId(wxCpDepart.getId()); //判断是否有该部门,没有则新建 if(sysDept!=null){ //判断是否有变化 if(!sysDept.getDeptName().equals(wxCpDepart.getName())||sysDept.getOrderNum()!=wxCpDepart.getOrder().intValue()){ sysDept.setDeptName(wxCpDepart.getName()); if(wxCpDepart.getParentId().compareTo(24L)<0){ //获取系统内对应部门 SysDept sysDept = sysDeptService.getByWxDeptId(wxCpDepart.getId()); //判断是否有该部门,没有则新建 if(sysDept!=null){ //判断是否有变化 if(!sysDept.getDeptName().equals(wxCpDepart.getName())||sysDept.getOrderNum()!=wxCpDepart.getOrder().intValue()){ sysDept.setDeptName(wxCpDepart.getName()); sysDept.setOrderNum(wxCpDepart.getOrder().intValue()); sysDept.setUpdateBy("企业微信同步"); sysDeptService.updateDept(sysDept); log.info("企业微信同步更新部门:"+wxCpDepart.getName()); } }else{ sysDept = new SysDept(); sysDept.setDelFlag("0"); sysDept.setStatus("0"); sysDept.setParentId(100L); sysDept.setOrderNum(wxCpDepart.getOrder().intValue()); sysDept.setUpdateBy("企业微信同步"); sysDeptService.updateDept(sysDept); log.info("企业微信同步更新部门:"+wxCpDepart.getName()); sysDept.setCreateBy("企业微信同步"); sysDept.setDeptName(wxCpDepart.getName()); sysDept.setWxDeptId(wxCpDepart.getId()); sysDeptService.insertDept(sysDept); log.info("企业微信同步新增部门:"+wxCpDepart.getName()); } }else{ sysDept = new SysDept(); sysDept.setDelFlag("0"); sysDept.setStatus("0"); sysDept.setParentId(100L); sysDept.setOrderNum(wxCpDepart.getOrder().intValue()); sysDept.setCreateBy("企业微信同步"); sysDept.setDeptName(wxCpDepart.getName()); sysDeptService.insertDept(sysDept); log.info("企业微信同步新增部门:"+wxCpDepart.getName()); } } } ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/staff/SysStaffService.java
@@ -5,6 +5,7 @@ import com.ruoyi.system.api.domain.dto.MgtBaseGetDto; import com.ruoyi.system.domain.dto.MgtStaffEditDto; import com.ruoyi.system.domain.dto.MgtStaffPageDto; import com.ruoyi.system.domain.dto.MgtSysStaffImportDto; import com.ruoyi.system.domain.pojo.staff.SysStaff; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.vo.MgtDeptStaffListVo; @@ -86,14 +87,7 @@ */ SysStaff getByMobile(String mobile); /** * @description 同步组织架构 * @author jqs * @date 2023/7/18 19:06 * @param * @return void */ void synchronizeOrganizationalStructure(); /** * @description 编辑商户员工 @@ -103,4 +97,13 @@ * @return void */ void editSysStaffInfo(MerEditUserDto merEditUserDto); /** * @description 导入员工 * @author jqs * @date 2023/8/18 16:04 * @param * @return void */ String importSysStaff(List<MgtSysStaffImportDto> staffImportDtoList); } ruoyi-modules/ruoyi-system/src/main/resources/mapper/sys/SysDeptMapper.xml
@@ -105,6 +105,7 @@ <if test="status != null">status,</if> <if test="createBy != null and createBy != ''">create_by,</if> <if test="dataScope != null and dataScope != ''">data_scope,</if> <if test="wxDeptId != null and wxDeptId != ''">wx_dept_id,</if> create_time )values( <if test="deptId != null and deptId != 0">#{deptId},</if> @@ -118,6 +119,7 @@ <if test="status != null">#{status},</if> <if test="createBy != null and createBy != ''">#{createBy},</if> <if test="dataScope != null and dataScope != ''">#{dataScope},</if> <if test="wxDeptId != null and wxDeptId != ''">#{wxDeptId},</if> sysdate() ) </insert> ruoyi-modules/ruoyi-system/src/test/java/com/ruoyi/system/systemTest.java
@@ -2,6 +2,7 @@ import com.ruoyi.system.service.staff.SysWxCpService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @@ -22,4 +23,8 @@ @Resource private SysWxCpService sysWxCpService; @Test public void main() { sysWxCpService.syncDepartment(); } }