From 7a8716132ea660525d4790349e05d59b3c369bb6 Mon Sep 17 00:00:00 2001 From: jyy <jyy> Date: Sat, 22 May 2021 17:31:27 +0800 Subject: [PATCH] Merge branch 'score_shop' into api_score_meger --- zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml | 7 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java | 13 + zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java | 6 zq-erp/pom.xml | 2 zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java | 5 zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java | 1 zq-xcx/project.config.json | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java | 13 + zq-erp/src/main/resources/config/application.properties | 13 + zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java | 2 zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java | 7 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java | 9 zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java | 24 ++ zq-erp/src/test/java/com/matrix/JyyTests2.java | 241 ++++++++++++++++++++++++++++++ zq-erp/src/test/java/com/matrix/JyyTests.java | 41 ++++ zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java | 32 +++ zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java | 2 zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java | 2 zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java | 21 + zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java | 22 ++ zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html | 4 zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml | 2 22 files changed, 425 insertions(+), 48 deletions(-) diff --git a/zq-erp/pom.xml b/zq-erp/pom.xml index ed1dc1f..3bdc5c1 100644 --- a/zq-erp/pom.xml +++ b/zq-erp/pom.xml @@ -401,7 +401,7 @@ <exclude>config/xcx/*</exclude> <exclude>config/xcshop/*</exclude> - <!----> + <!-- --> <exclude>config/config.json</exclude> <exclude>config/application.properties</exclude> <exclude>config/system.properties</exclude> diff --git a/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java b/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java index 5884118..c61852d 100644 --- a/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java +++ b/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java @@ -64,6 +64,7 @@ .excludePathPatterns("/plugin/**") .excludePathPatterns("/swagger**/**") .excludePathPatterns("/webjars/**"); + // 用户认证拦截 registry.addInterceptor(userLoginInterceptor) .addPathPatterns("/**") diff --git a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java index 894cdf2..08f9c22 100644 --- a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java +++ b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java @@ -521,7 +521,7 @@ /** * 免免邮金额 */ - public static final String FREE_PACKAGE_PRICE = "FREE_PACKAGE_PRICE"; + public static final String FREE_PACKAGE_PRICE = "FREE_PACKAGE_PRICE"; /** diff --git a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java index 1295c04..747dc87 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java @@ -212,4 +212,6 @@ public SysVipInfo findByOpenId(String openId); int unbundlingSaleMan(Long userId); + + int bindingRecommend(@Param("recommendId") Long recommendId,@Param("userId") Long userId); } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java index b5a3280..78e2713 100644 --- a/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java @@ -119,7 +119,10 @@ throw new GlobleException(sysVipInfo.getPhone()+"手机已被注册!"); } } - + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + if(user!=null){ + sysVipInfo.setCompanyId(user.getCompanyId()); + } sysVipInfo.setCreateTime(new Date()); sysVipInfo.setPointAll(0); sysVipInfo.setIsDeal(SysVipInfo.UNDEAL_VIP); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java index dded875..48276f1 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java @@ -17,6 +17,7 @@ import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.shopXcx.api.service.WXShopOrderService; import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; @@ -81,6 +82,8 @@ @Autowired private RabiitMqTemplate rabiitMqTemplate; + @Autowired + BusParameterSettingsDao parameterSettingsDao; /** * 列表显示 @@ -525,8 +528,12 @@ modifyMap.put("refundCharge", shopRefundRecord.getRefundMoney()); shopOrderDao.updateByMap(modifyMap); + + + rabiitMqTemplate.sendMsg(MQTaskRouting.SHOP_ORDER_REFUND+evn,shopRefundRecord.getOrderId()+""); + }catch (Exception e){ LogUtil.debug("退款成功,修改退款表和订单表状态出错。。。", id); e.printStackTrace(); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java index daf749a..1d471ab 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java @@ -1,6 +1,5 @@ package com.matrix.system.shopXcx.api.action; -import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.component.tools.WxUtils; import com.matrix.core.pojo.AjaxResult; @@ -9,6 +8,7 @@ import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.CustomerDataDictionaryDao; +import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; import com.matrix.system.shopXcx.api.tools.SMSTools; import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; @@ -103,6 +103,7 @@ return Double.valueOf(moneyStr); } + /** * 接收保存退款退货数据 */ @@ -135,13 +136,13 @@ if (i == 0) { return new AjaxResult(AjaxResult.STATUS_FAIL, "保存失败"); } - + ShopOrder order = shopOrderDao.selectById(refundRecord.getOrderId()); //未发货的订单取消订单不走后台审核直接退款 List<ShopRefundRecord> refundRecordsList = refundRecordDao.selectByModel(record); if(CollectionUtils.isNotEmpty(refundRecordsList)){ ShopRefundRecord shopRecord = refundRecordsList.get(0); Integer orderId = shopRecord.getOrderId(); - ShopOrder order = shopOrderDao.selectById(orderId); + if (order == null) { return new AjaxResult(AjaxResult.STATUS_FAIL, "未发货直接退款未找到订单信息"); } @@ -160,6 +161,10 @@ if(flag){ ShopRefundRecord fundRecord = refundRecordDao.selectById(shopRecord.getId()); refundRecordService.updateGroupBuyStatus(orderId.longValue()); + + + + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "退款成功"); } return new AjaxResult(AjaxResult.STATUS_FAIL, "退款失败"); @@ -172,6 +177,8 @@ modifyMap.put("id", orderId); modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_APPLY_MONEYBACK); shopOrderDao.updateByMap(modifyMap); + + return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java index 611820b..faf6fc3 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java @@ -1,10 +1,15 @@ package com.matrix.system.shopXcx.api.action; +import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.interceptor.HostInterceptor; +import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; +import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; +import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.shopXcx.api.dto.SaleProductDto; import com.matrix.system.shopXcx.bean.ShopProduct; +import com.matrix.system.shopXcx.bean.ShopSku; import com.matrix.system.shopXcx.dao.ShopProductAttributeDao; import com.matrix.system.shopXcx.dao.ShopProductDao; import com.matrix.system.shopXcx.dao.ShopSkuDao; @@ -19,7 +24,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.List; +import java.util.Objects; /** * @author jyy @@ -35,9 +42,12 @@ @Autowired private ShopProductAttributeDao shopProductAttributeDao; - + @Autowired + private ShopSalesmanGradeDao shopSalesmanGradeDao; @Autowired private ShopSkuDao shopSkuDao; + @Autowired + private RedisUserLoginUtils redisUserLoginUtils; @ApiOperation(value = "查询推广商品", notes = "") @PostMapping(value = "/getSalesProductList") @@ -54,7 +64,25 @@ shopProduct.setAbleSales(ShopProduct.ABLE_SALES); shopProduct.setCompanyId(HostInterceptor.getCompanyId()); List<ShopProduct> shopProducts = shopProductDao.selectByModelWx(shopProduct); - shopProducts.forEach(item->item.setSkus(shopSkuDao.selectByPid(item.getId()))); + SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); + ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(sysVipInfo.getSalesmanGrade()); + shopProducts.forEach(item->{ + List<ShopSku> shopSkus = shopSkuDao.selectByPid(item.getId()); + //计算产品佣金 + shopSkus.forEach(shopSku -> { + if(Objects.isNull(shopSku.getInvitationPrice())){ + shopSku.setInvitationPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getInvitationCommission())).divide(BigDecimal.valueOf(100))); + } + if(Objects.isNull(shopSku.getSealesPrice())){ + shopSku.setSealesPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSealesCommission())).divide(BigDecimal.valueOf(100))); + } + if(Objects.isNull(shopSku.getSelfPrice())){ + shopSku.setSelfPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSelfCommission())).divide(BigDecimal.valueOf(100))); + } + }); + item.setSkus(shopSkus); + + }); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, shopProducts); return result; } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java index 7e39d58..ee96c85 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java @@ -168,11 +168,7 @@ return AjaxResult.buildSuccessInstance("已经被绑定"); } else { if (loginUser.getRecommendId()==null) { - Map<String, Object> updateParam = new HashMap<>(); - updateParam.put("id", loginUser.getId()); - loginUser.setRecommendId(invitationUser.getId()); - loginUser.setBindingParentTime(new Date()); - sysVipInfoDao.update(loginUser); + sysVipInfoDao.bindingRecommend(invitationUser.getId(),loginUser.getId()); return AjaxResult.buildSuccessInstance("绑定成功"); } else { return AjaxResult.buildSuccessInstance("已经存在上级"); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java index 977b543..5eb9595 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java @@ -107,7 +107,7 @@ shopSku.setSealesPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSealesCommission())).divide(BigDecimal.valueOf(100))); } if(Objects.isNull(shopSku.getSelfPrice())){ - shopSku.setSealesPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSelfCommission())).divide(BigDecimal.valueOf(100))); + shopSku.setSelfPrice(shopSku.getPrice().multiply(BigDecimal.valueOf(shopSalesmanGrade.getSelfCommission())).divide(BigDecimal.valueOf(100))); } }); } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java index 6466163..97af9ae 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java @@ -15,7 +15,9 @@ import com.matrix.system.constance.Dictionary; import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; import com.matrix.system.fenxiao.dao.ShopSalesmanApplyDao; +import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; import com.matrix.system.fenxiao.entity.ShopSalesmanApply; +import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; import com.matrix.system.fenxiao.service.ShopSalesmanApplyService; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.MoneyCardUseDao; @@ -145,6 +147,8 @@ } + @Autowired + ShopSalesmanGradeDao shopSalesmanGradeDao; /** * 查询用户信息 @@ -160,6 +164,15 @@ res.putInMap("couponCount", shopCouponRecordDao.countUnuseCouponRecord(loginUser.getId())); res.putInMap("prizeCount",activitySignReceiveRecordDao.getSignAwardReceiveCount(loginUser.getId(),loginUser.getCompanyId())); res.putInMap("userInfo", sysVipInfo); + //查询会员等级 + if(sysVipInfo.getSalesmanGrade()!=null){ + ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(sysVipInfo.getSalesmanGrade()); + res.putInMap("vipLevel", shopSalesmanGrade.getName()); + }else if(sysVipInfo.getVipLevel()!=null){ + res.putInMap("vipLevel", sysVipInfo.getVipLevel().getLevelName()); + }else{ + res.putInMap("vipLevel", "初级会员"); + } res.setStatus(AjaxResult.STATUS_SUCCESS); return res; } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java index 9a44280..38a88a4 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java @@ -16,6 +16,7 @@ import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.CustomerDataDictionaryDao; import com.matrix.system.common.interceptor.HostInterceptor; +import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.ShoppingGoodsDao; import com.matrix.system.hive.dao.SysVipInfoDao; @@ -346,9 +347,11 @@ //计算运费 - discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(), HostInterceptor.getCompanyId())); - - + if(ShopOrder.SHIPPING_METHOD_WL==shopOrderDto.getDeliverySelect()){ + discountExplain.setPostage(calculationPostage(billPrice, HostInterceptor.getCompanyId())); + }else{ + discountExplain.setPostage(BigDecimal.ZERO); + } //账单总金额 discountExplain.setBillPrice(billPrice.add(discountExplain.getPostage())); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java index 28e33f6..0b3bfc7 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java @@ -1,12 +1,14 @@ package com.matrix.system.shopXcx.api.service.impl; import com.matrix.component.rabbitmq.RabiitMqTemplate; -import com.matrix.component.tools.WxTempLateMsgUtil; import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; import com.matrix.core.exception.GlobleException; -import com.matrix.core.tools.DateUtil; +import com.matrix.core.tools.DingDingRobotUtil; import com.matrix.core.tools.LogUtil; +import com.matrix.core.tools.StringUtils; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.shopXcx.api.service.WXShopOrderService; import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; import com.matrix.system.shopXcx.bean.*; @@ -16,10 +18,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -48,6 +48,10 @@ @Autowired private ShopActivitiesGroupJoinDao shopActivitiesGroupJoinDao; + + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; + @Value("${wx_pay_debug_onoff}") private boolean isDebug; @@ -146,6 +150,16 @@ rabiitMqTemplate.sendMsg(MQTaskRouting.SHOP_ORDER_REFUND+evn,shopRefundRecord.getOrderId()+""); + //发送退款通知 + BusParameterSettings wxOrderNoticeDingdingToken = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WX_ORDER_NOTICE_DINGDING_TOKEN, shopOrder.getCompanyId()); + if (wxOrderNoticeDingdingToken != null && StringUtils.isNotBlank(wxOrderNoticeDingdingToken.getParamValue())) { + DingDingRobotUtil.sendText(wxOrderNoticeDingdingToken.getParamValue(), + "订单退款,微商城订单编号 "+shopOrder.getOrderNo() + +"; 订单金额:¥"+shopOrder.getOrderMoney() + +";收货电话:"+ shopOrder.getUserTel()+",收货人:"+ shopOrder.getUserName() + ,""); + } + }catch (Exception e){ LogUtil.debug("退款成功,修改退款表和订单表状态出错。。。", id); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java index 41bc09c..2ea6cb0 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java @@ -7,10 +7,11 @@ import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.SysVipInfoDao; +import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; import com.matrix.system.shopXcx.bean.ShopOrder; import com.matrix.system.shopXcx.bean.ShopOrderDetails; +import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; import com.matrix.system.shopXcx.dao.ShopOrderDao; import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao; import com.rabbitmq.client.DeliverCallback; @@ -41,11 +42,15 @@ @Autowired SysVipInfoDao sysVipInfoDao; + @Autowired + ShopDeliveryInfoDao shopDeliveryInfoDao; + @Override public void handle(String consumerTag, Delivery message) throws IOException { - String orderId = new String(message.getBody(), "UTF-8"); + String orderIdStr = new String(message.getBody(), "UTF-8"); + Integer orderId=Integer.valueOf(orderIdStr); //获取订单信息 - ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); + ShopOrder order = shopOrderDao.selectById(orderId); LogUtil.debug("收到创建订单通知任务orderId={}", orderId); BusParameterSettings wxOrderNoticeDingdingToken = parameterSettingsDao.selectCompanyParamByCode(AppConstance.WX_ORDER_NOTICE_DINGDING_TOKEN, order.getCompanyId()); if (wxOrderNoticeDingdingToken != null && StringUtils.isNotBlank(wxOrderNoticeDingdingToken.getParamValue())) { @@ -54,8 +59,19 @@ StringBuilder content = new StringBuilder(); orderDetails.stream().forEach(i -> content.append(i.getsTitle()).append("*").append( i.getCount()).append(";")); + ShopDeliveryInfo addInfo = shopDeliveryInfoDao.selectByOrderId(orderId); - DingDingRobotUtil.sendText(wxOrderNoticeDingdingToken.getParamValue(),"微商城订单 ("+order.getUserName()+") | 订单金额:¥"+order.getOrderMoney()+",订单内容:"+ content.toString(),""); + String shippingMethod="物流配送"; + if(AppConstance.SHIPPING_METHOD_SELF .equals(order.getShippingMethod())){ + shippingMethod="门店自提"; + } + DingDingRobotUtil.sendText(wxOrderNoticeDingdingToken.getParamValue(), + "新订单,微商城订单编号 "+order.getOrderNo() + +"; 订单金额:¥"+order.getOrderMoney() + +";订单内容:"+ content.toString() + +";收货电话:"+ order.getUserTel()+",收货人:"+ order.getUserName()+",收货地址:"+ addInfo.getReceiveAddress() + +"配送方式:"+shippingMethod + ,""); }else{ LogUtil.debug("未配置订单钉钉提醒"); } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java index d7eab53..8b52165 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java @@ -16,6 +16,7 @@ import org.springframework.stereotype.Component; import java.io.IOException; +import java.util.List; /** * 分销订单退款 @@ -44,13 +45,19 @@ LogUtil.debug("收到分销订单退款任务orderId={}", orderId); QueryWrapper queryWrapper=new QueryWrapper(); queryWrapper.eq("order_id",orderId); - ShopSalesmanOrder shopSalesmanOrder = shopSalesmanOrderDao.selectOne(queryWrapper); - if(shopSalesmanOrder!=null){ - shopSalesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_YTK); - shopSalesmanOrderDao.updateById(shopSalesmanOrder); - }else{ - LogUtil.debug("改订单为生成分销订单={}", orderId); - } + List<ShopSalesmanOrder> list = shopSalesmanOrderDao.selectList(queryWrapper); + + list.forEach(shopSalesmanOrder->{ + + if(shopSalesmanOrder!=null){ + shopSalesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_YTK); + shopSalesmanOrderDao.updateById(shopSalesmanOrder); + }else{ + LogUtil.debug("改订单为生成分销订单={}", orderId); + } + + + }); ShopOrder order=shopOrderDao.selectById(Integer.parseInt(orderId)); //如果是积分支付则需要返还积分 diff --git a/zq-erp/src/main/resources/config/application.properties b/zq-erp/src/main/resources/config/application.properties index 14fb986..fa1e322 100644 --- a/zq-erp/src/main/resources/config/application.properties +++ b/zq-erp/src/main/resources/config/application.properties @@ -3,19 +3,24 @@ #线上测试环境 - +# #spring.datasource.username=ct_test #spring.datasource.password=123456 #spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 + +spring.datasource.username=ct_test +spring.datasource.password=123456 +spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 #spring.datasource.username=xc_shop #spring.datasource.password=xc_shop123!@# #spring.datasource.url=jdbc:mysql://124.70.222.34/xc_shop?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 -spring.datasource.username=hive -spring.datasource.password=hive123!@# -spring.datasource.url=jdbc:mysql://124.70.222.34/hive_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 +#spring.datasource.username=hive +#spring.datasource.password=hive123!@# +#spring.datasource.url=jdbc:mysql://124.70.222.34/hive_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 + spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.initialSize=3 diff --git a/zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml b/zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml index ee69a10..df93edb 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml @@ -323,7 +323,7 @@ <set> update_time=now(), <if test="updateBy!=null"> - update_by = #{btnKey}, + update_by = #{updateBy}, </if> <if test="(suName!=null and suName!='') or (suName!='' and suName==0)"> diff --git a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml index 9724622..68afb0d 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml @@ -499,9 +499,7 @@ <if test="isDeal != null "> is_deal = #{isDeal}, </if> - <if test="recommendId != null "> - recommend_id = #{recommendId}, - </if> + <if test="province != null and province !='' "> province = #{province}, </if> @@ -552,6 +550,9 @@ <update id="unbundlingSaleMan"> UPDATE sys_vip_info set recommend_id = NULL where id=#{userId}; </update> + <update id="bindingRecommend"> + UPDATE sys_vip_info set recommend_id = #{recommendId} where id=#{userId}; + </update> <!-- 批量删除 --> <delete id="deleteByIds" parameterType="java.util.List"> diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html index 0030e60..ff23851 100644 --- a/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html +++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html @@ -94,8 +94,8 @@ <label class="col-sm-2 control-label">配送方式 </label> <div class="col-sm-4"> - <input autocomplete="off" type="text" class="form-control" readonly="readonly" - th:value="${orderInfo.shippingMethod}" nullmsg="订单备注不能为空"> + <input autocomplete="off" type="text" class="form-control" readonly="readonly" th:if="${orderInfo.shippingMethod==1}" th:value="物流配送" > + <input autocomplete="off" type="text" class="form-control" readonly="readonly" th:if="${orderInfo.shippingMethod==2}" th:value="门店自提" > </div> </div> <div class="form-group"> diff --git a/zq-erp/src/test/java/com/matrix/JyyTests.java b/zq-erp/src/test/java/com/matrix/JyyTests.java index 9297740..b955d11 100644 --- a/zq-erp/src/test/java/com/matrix/JyyTests.java +++ b/zq-erp/src/test/java/com/matrix/JyyTests.java @@ -1,27 +1,53 @@ package com.matrix; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.matrix.component.redis.RedisClient; +import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.tools.LogUtil; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysFunction; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; +import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; +import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; +import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; +import com.matrix.system.fenxiao.entity.ShopSalesmanOrder; +import com.matrix.system.hive.bean.SysVipInfo; +import com.matrix.system.hive.dao.SysOrderDao; +import com.matrix.system.hive.dao.SysOrderItemDao; +import com.matrix.system.hive.dao.SysVipInfoDao; +import com.matrix.system.hive.service.CodeService; +import com.matrix.system.hive.service.ShoppingGoodsService; +import com.matrix.system.hive.service.SysOrderService; +import com.matrix.system.hive.service.SysVipInfoService; import com.matrix.system.hive.service.imp.SysVipInfoServiceImpl; import com.matrix.system.score.dao.ScoreVipDetailDao; import com.matrix.system.score.service.ScoreVipDetailService; +import com.matrix.system.shopXcx.bean.ShopOrder; +import com.matrix.system.shopXcx.bean.ShopOrderDetails; +import com.matrix.system.shopXcx.bean.ShopProduct; +import com.matrix.system.shopXcx.dao.ShopOrderDao; +import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao; import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; +import com.matrix.system.shopXcx.dao.ShopSkuDao; import com.matrix.system.shopXcx.mqTask.OrderDingDingNoticeTask; import com.rabbitmq.client.Delivery; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 测试类示例 @@ -56,8 +82,13 @@ OrderDingDingNoticeTask orderDingDingNoticeTask; @Test + @Rollback public void testNoticeTask() throws IOException { - orderDingDingNoticeTask.handle("",new Delivery(null,null,"1295".getBytes())); + // orderDingDingNoticeTask.handle("",new Delivery(null,null,"1295".getBytes())); + + + + } diff --git a/zq-erp/src/test/java/com/matrix/JyyTests2.java b/zq-erp/src/test/java/com/matrix/JyyTests2.java new file mode 100644 index 0000000..0304fff --- /dev/null +++ b/zq-erp/src/test/java/com/matrix/JyyTests2.java @@ -0,0 +1,241 @@ +package com.matrix; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.matrix.component.redis.RedisClient; +import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.tools.LogUtil; +import com.matrix.system.common.bean.BusParameterSettings; +import com.matrix.system.common.bean.SysFunction; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.fenxiao.constant.FenxiaoSettingConstant; +import com.matrix.system.fenxiao.dao.ShopSalesmanGradeDao; +import com.matrix.system.fenxiao.dao.ShopSalesmanOrderDao; +import com.matrix.system.fenxiao.entity.ShopSalesmanGrade; +import com.matrix.system.fenxiao.entity.ShopSalesmanOrder; +import com.matrix.system.hive.bean.SysVipInfo; +import com.matrix.system.hive.dao.SysOrderDao; +import com.matrix.system.hive.dao.SysOrderItemDao; +import com.matrix.system.hive.dao.SysVipInfoDao; +import com.matrix.system.hive.service.CodeService; +import com.matrix.system.hive.service.ShoppingGoodsService; +import com.matrix.system.hive.service.SysOrderService; +import com.matrix.system.hive.service.SysVipInfoService; +import com.matrix.system.hive.service.imp.SysVipInfoServiceImpl; +import com.matrix.system.score.dao.ScoreVipDetailDao; +import com.matrix.system.score.service.ScoreVipDetailService; +import com.matrix.system.shopXcx.bean.ShopOrder; +import com.matrix.system.shopXcx.bean.ShopOrderDetails; +import com.matrix.system.shopXcx.bean.ShopProduct; +import com.matrix.system.shopXcx.dao.ShopOrderDao; +import com.matrix.system.shopXcx.dao.ShopOrderDetailsDao; +import com.matrix.system.shopXcx.dao.ShopOrderV2Dao; +import com.matrix.system.shopXcx.dao.ShopSkuDao; +import com.matrix.system.shopXcx.mqTask.OrderDingDingNoticeTask; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.junit4.SpringRunner; + +import java.io.IOException; +import java.util.*; + +/** + * 测试类示例 + * + * @author jiangyouyao + * @email 512061637@qq.com + * @date 2019年2月25日 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {ZqErpApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class JyyTests2 { + + @Autowired + ShopOrderDao shopOrderDao; + @Autowired + ShopOrderDetailsDao shopOrderDetailsDao; + + @Autowired + SysVipInfoService sysVipInfoService; + + + @Autowired + private SysVipInfoDao vipDap; + + @Autowired + SysVipInfoDao vipDao; + + @Autowired + CodeService codeService; + + @Autowired + SysOrderDao sysOrderDao; + + @Autowired + ShoppingGoodsService shoppingGoodsService; + + @Autowired + SysOrderItemDao orderItemDao; + + @Autowired + SysOrderService orderService; + + @Autowired + ShopSkuDao shopSkuDao; + + @Autowired + BusParameterSettingsDao parameterSettingsDao; + + + @Autowired + private ShopSalesmanOrderDao shopSalesmanOrderDao; + + @Autowired + private ShopSalesmanGradeDao shopSalesmanGradeDao; + + + @Test + @Rollback + public void testNoticeTask() throws IOException { + // orderDingDingNoticeTask.handle("",new Delivery(null,null,"1295".getBytes())); + + ShopOrder order=shopOrderDao.selectById(1353); + //判读客户是否存在上级,存在则产生上级的收益 + SysVipInfo sysVipInfo = sysVipInfoService.findById(order.getUserId()); + LogUtil.debug("处理分销订单userOpid={}",sysVipInfo.getOpenId()); + //判断是否重复生成 + QueryWrapper queryWrapper=new QueryWrapper(); + queryWrapper.eq("order_id",order.getId()); + Integer orderCount = shopSalesmanOrderDao.selectCount(queryWrapper); + ShopSalesmanOrder salesmanOrder=new ShopSalesmanOrder(); + salesmanOrder.setCompanyId(order.getCompanyId()); + salesmanOrder.setCreateBy(MatrixConstance.SYSTEM_USER); + salesmanOrder.setUpdateBy(MatrixConstance.SYSTEM_USER); + salesmanOrder.setCreateTime(new Date()); + salesmanOrder.setUpdateTime(new Date()); + salesmanOrder.setOrderId(Long.parseLong(order.getId()+"")); + salesmanOrder.setUserId(order.getUserId()); + salesmanOrder.setRevenueType(ShopSalesmanOrder.REVENUE_TYPE_SALES); + salesmanOrder.setOrderStatus(ShopSalesmanOrder.STATUS_DJS); + Double selfAmount=0D; + Double zk=1D; + //分销订单总额 + Double orderTotal=0D; + for (ShopOrderDetails item:order.getDetails() ){ + if(item.getShopProduct().getAbleSales()==ShopProduct.ABLE_SALES){ + orderTotal+=item.getTotalPrice().doubleValue(); + } + } + //自购返佣 + Integer isSales = sysVipInfo.getIsSales(); + if(SysVipInfo.IS_SALES == isSales){ + for (ShopOrderDetails item:order.getDetails() ){ + if(item.getShopProduct().getAbleSales()==ShopProduct.ABLE_SALES){ + //分销规则是否开启自购返佣 + BusParameterSettings zgfy = parameterSettingsDao.selectCompanyParamByCode(FenxiaoSettingConstant.FX_ZGFY, sysVipInfo.getCompanyId()); + //按分销等级计算 + ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(sysVipInfo.getSalesmanGrade()); + if(ObjectUtil.isNotEmpty(zgfy)) { + //获取商品的自购返佣价格,如果没有设置,在去获取当前推广人的等级的自购返佣比例 + if(StrUtil.isNotEmpty(zgfy.getParamValue()) && + FenxiaoSettingConstant.FX_ZGFY_YES.equals(zgfy.getParamValue())) { + if(item.getShopSku().getSelfPrice() == null + ||item.getShopSku().getSealesPrice().doubleValue() == 0){ + selfAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSelfCommission()/100); + }else { + //按产品设置的自购返佣金额计算 + selfAmount+=item.getShopSku().getSelfPrice().doubleValue()*item.getCount(); + } + } + } + } + } + //自购返佣记录 + if(selfAmount > 0) { + //整体的优惠金额折算成折扣,* 佣金 + zk=(order.getOrderMoney().doubleValue()-order.getPostage().doubleValue())/orderTotal; + selfAmount=selfAmount*zk; + salesmanOrder.setAmount(selfAmount); + salesmanOrder.setSalesUserId(order.getUserId()); + shopSalesmanOrderDao.insert(salesmanOrder); + } + } + + //存在上级 + if(sysVipInfo.getRecommendId()!=null) { + SysVipInfo salesMan=sysVipInfoService.findById(sysVipInfo.getRecommendId()); + Double salesAmount=0D; + Double invitationAmount=0D; + SysVipInfo invitationMan=null; + ShopSalesmanOrder invitationOrder=null; + boolean hasInvitationMan=salesMan.getRecommendId()!=null; + //判断推广员是否还存在上级,存在则计算邀请收益 + if(hasInvitationMan){ + invitationMan=sysVipInfoService.findById(salesMan.getRecommendId()); + invitationOrder=new ShopSalesmanOrder(); + BeanUtils.copyProperties(salesmanOrder,invitationOrder); + invitationOrder.setSalesUserId(invitationMan.getId()); + invitationOrder.setRevenueType(ShopSalesmanOrder.REVENUE_TYPE_INVITATION); + } + //收益计算 + for (ShopOrderDetails item:order.getDetails() ){ + if(item.getShopProduct().getAbleSales()== ShopProduct.ABLE_SALES){ + //按分销等级计算 + ShopSalesmanGrade shopSalesmanGrade = shopSalesmanGradeDao.selectById(salesMan.getSalesmanGrade()); + //推广提成,按分销等级计算或者按产品设置的推广金额计算 + if(item.getShopSku().getSealesPrice()==null + ||item.getShopSku().getSealesPrice().doubleValue()==0){ + salesAmount+=item.getTotalPrice().doubleValue()*(shopSalesmanGrade.getSealesCommission()/100); + }else{ + salesAmount+=item.getShopSku().getSealesPrice().doubleValue()*item.getCount(); + } + //邀请提成,获取商品的邀请提成价格和是否有上级推广人,如果没有设置,在去获取当前推广人的等级的自购返佣比例 + if(hasInvitationMan) { + if(item.getShopSku().getInvitationPrice() == null + ||item.getShopSku().getInvitationPrice().doubleValue() == 0){ + //获取上级的推广等级设置 + ShopSalesmanGrade invitationManGrade = shopSalesmanGradeDao.selectById(invitationMan.getSalesmanGrade()); + invitationAmount+=item.getTotalPrice().doubleValue()*(invitationManGrade.getInvitationCommission()/100); + }else { + //按产品设置的邀请提成价格计算 + invitationAmount+=item.getShopSku().getInvitationPrice().doubleValue()*item.getCount(); + } + } + } + } + //推广提成记录 + if(salesAmount>0){ + //整体的优惠金额折算成折扣,* 佣金 + zk=(order.getOrderMoney().doubleValue()-order.getPostage().doubleValue())/orderTotal; + salesAmount=salesAmount*zk; + salesmanOrder.setAmount(salesAmount); + salesmanOrder.setSalesUserId(sysVipInfo.getRecommendId()); + shopSalesmanOrderDao.insert(salesmanOrder); + } + //邀请提成记录 + if(invitationAmount > 0) { + //整体的优惠金额折算成折扣,* 佣金 + invitationAmount=invitationAmount*zk; + invitationOrder.setAmount(invitationAmount); + shopSalesmanOrderDao.insert(invitationOrder); + } + }else{ + LogUtil.debug("不存在父级userOpid={}",sysVipInfo.getOpenId()); + } + + + + + } + + + +} diff --git a/zq-xcx/project.config.json b/zq-xcx/project.config.json index 8b486aa..77acbda 100644 --- a/zq-xcx/project.config.json +++ b/zq-xcx/project.config.json @@ -23,18 +23,20 @@ "compileHotReLoad": false, "useMultiFrameRuntime": true, "useApiHook": true, + "useApiHostProcess": false, "babelSetting": { "ignore": [], "disablePlugins": [], "outputPath": "" }, + "enableEngineNative": false, + "bundle": false, "useIsolateContext": true, "useCompilerModule": true, "userConfirmedUseCompilerModuleSwitch": false, "userConfirmedBundleSwitch": false, "packNpmManually": false, "packNpmRelationList": [], - "enableEngineNative": false, "minifyWXSS": true }, "compileType": "miniprogram", -- Gitblit v1.9.1