935090232@qq.com
2021-06-08 112ceac7d0d3c1565464638306bb488c951e471e
Merge branch 'score_shop' into api_score_meger

# Conflicts:
# zq-erp/src/main/resources/config/application.properties
37 files modified
12 files added
2173 ■■■■■ changed files
zq-erp/pom.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java 15 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveNew.java 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveRule.java 33 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/MoneyCardUse.java 5 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/ShoppingGoods.java 26 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/bean/SysOrder.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java 8 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveRuleDao.java 11 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dao/SysVipInfoDao.java 2 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/dto/AchieveNewStatisticsDto.java 41 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/AchieveRuleService.java 33 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java 49 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java 45 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysVipInfoServiceImpl.java 5 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java 80 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/vo/AchieveNewStatisticsVo.java 42 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/action/AchieveRuleAction.java 129 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hiveErp/pojo/AchieveRuleItem.java 56 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopRefundRecordAction.java 7 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java 13 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesProductAction.java 32 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxSalesmanAction.java 6 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopProduct.java 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java 13 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopRefundRecordServiceImpl.java 22 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderDingDingNoticeTask.java 24 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/SalesOrderRefundTask.java 21 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/filecopy.java 80 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/application.properties 15 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/common/SysUsersDao.xml 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml 101 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveRuleDao.xml 7 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/OnlinebookingDao.xml 24 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml 38 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/hive/SysVipInfoDao.xml 7 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive-erp/products/achieverule-list.html 402 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive-erp/statistics/achieveNewStatiostics.html 366 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive-erp/statistics/daily-list-new.html 21 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive/products/goods-form.html 34 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive/products/shoppinggoods-md-list.html 11 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive/products/shoppinggoods-zb-list.html 11 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-list-new.html 21 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/shop/shopOrder-form.html 4 ●●●● patch | view | raw | blame | history
zq-erp/src/test/java/com/matrix/JyyTests.java 41 ●●●● patch | view | raw | blame | history
zq-erp/src/test/java/com/matrix/JyyTests2.java 241 ●●●●● patch | view | raw | blame | history
zq-xcx/project.config.json 4 ●●● patch | view | raw | blame | history
zq-erp/pom.xml
@@ -401,12 +401,12 @@
                    <exclude>config/xcx/*</exclude>
                    <exclude>config/xcshop/*</exclude>
                    <!---->
                    <!--
                    <exclude>config/config.json</exclude>
                    <exclude>config/application.properties</exclude>
                    <exclude>config/system.properties</exclude>
-->
                    <exclude>**/*.woff</exclude>
                    <exclude>**/*.woff2</exclude>
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java
@@ -64,14 +64,15 @@
                .excludePathPatterns("/plugin/**")
                .excludePathPatterns("/swagger**/**")
                .excludePathPatterns("/webjars/**");
        // 用户认证拦截
        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/common/**")
                .excludePathPatterns("/resource/**")
                .excludePathPatterns("/swagger**/**")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/api/**");
//        registry.addInterceptor(userLoginInterceptor)
//                .addPathPatterns("/**")
//                .excludePathPatterns("/common/**")
//                .excludePathPatterns("/resource/**")
//                .excludePathPatterns("/swagger**/**")
//                .excludePathPatterns("/webjars/**")
//                .excludePathPatterns("/api/**");
        // url权限拦截
        registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**");
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";
    /**
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveNew.java
@@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.matrix.core.anotations.Extend;
import com.matrix.core.tools.DateUtil;
import com.matrix.system.app.dto.BasePageDto;
import com.matrix.system.common.bean.EntityDTOExt;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
@@ -11,7 +13,7 @@
 *
 * @date 2019-03-24 23:55
 */
public class AchieveNew implements Serializable{
public class AchieveNew extends EntityDTOExt {
    @Extend
    private static final long serialVersionUID = 1L; 
@@ -26,7 +28,7 @@
            
    
    /**
     * 美疗师id
     * 美疗师id  把这个字段视为正式的业绩归属人
     */
    private Long  beaultId;
            
zq-erp/src/main/java/com/matrix/system/hive/bean/AchieveRule.java
New file
@@ -0,0 +1,33 @@
package com.matrix.system.hive.bean;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import com.matrix.system.score.entity.BaseEntity;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
 * 业绩规则
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Data
@TableName("achieve_rule")
public class AchieveRule extends BaseEntity {
    @NotEmpty(message = "规则名称不能为空")
    private String name;
    private String rules;
    private Long companyId;
    @TableField(exist=false)
    @NotEmpty(message = "规则不能为空")
    private List<AchieveRuleItem> ruleItemList;
}
zq-erp/src/main/java/com/matrix/system/hive/bean/MoneyCardUse.java
@@ -1,6 +1,8 @@
package com.matrix.system.hive.bean;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.matrix.core.anotations.Extend;
import com.matrix.core.tools.DateUtil;
@@ -14,9 +16,10 @@
 *
 * @date 2016-09-17 10:17
 */
public class MoneyCardUse  {
    @TableId(value = "id",type = IdType.AUTO)
    private Long  id;
zq-erp/src/main/java/com/matrix/system/hive/bean/ShoppingGoods.java
@@ -433,12 +433,38 @@
     * 任选套餐是否无限次 N-否 Y-是
     */
    private String isInfinite;
    /**
     *业绩规则id
     */
    private Long achieveRuleId;
    /**
     *业绩规则名称
     */
    @Extend
    private String achieveRuleName;
    /**
     * 支付方式 1-充值本金 2-赠送金额 3-积分
     */
    private String payMethods;
    public String getAchieveRuleName() {
        return achieveRuleName;
    }
    public void setAchieveRuleName(String achieveRuleName) {
        this.achieveRuleName = achieveRuleName;
    }
    public Long getAchieveRuleId() {
        return achieveRuleId;
    }
    public void setAchieveRuleId(Long achieveRuleId) {
        this.achieveRuleId = achieveRuleId;
    }
    public String getPayMethods() {
        return payMethods;
    }
zq-erp/src/main/java/com/matrix/system/hive/bean/SysOrder.java
@@ -42,7 +42,7 @@
    private Date orderTime;
    /**
     * 收款
     * calculationType: 1,
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date payTime;
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveNewDao.java
@@ -1,10 +1,15 @@
package com.matrix.system.hive.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.system.app.vo.OrderDetailAchieveItemVo;
import com.matrix.system.app.vo.RankingVo;
import com.matrix.system.app.vo.UserAchieveVo;
import com.matrix.system.hive.bean.AchieveNew;
import com.matrix.system.hive.dto.AchieveNewStatisticsDto;
import com.matrix.system.hive.vo.AchieveNewStatisticsVo;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@@ -18,7 +23,7 @@
 */
public interface AchieveNewDao{
public interface AchieveNewDao extends BaseMapper<AchieveNew> {
    public int insert(@Param("item") AchieveNew achieveNew);
       
@@ -82,4 +87,5 @@
    int updateAchieveNumOfPeople(@Param("list") List<AchieveNew> list, @Param("num") Double num);
    IPage<AchieveNewStatisticsVo> achieveNewStatistics(Page<AchieveNewStatisticsVo> page,  @Param("record")AchieveNewStatisticsDto queryDto);
}
zq-erp/src/main/java/com/matrix/system/hive/dao/AchieveRuleDao.java
New file
@@ -0,0 +1,11 @@
package com.matrix.system.hive.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.matrix.system.hive.bean.AchieveRule;
/**
 * 业绩规则dao
 */
public interface AchieveRuleDao extends BaseMapper<AchieveRule> {
}
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);
}
zq-erp/src/main/java/com/matrix/system/hive/dto/AchieveNewStatisticsDto.java
New file
@@ -0,0 +1,41 @@
package com.matrix.system.hive.dto;
import com.google.common.base.CaseFormat;
import com.matrix.core.pojo.BasePageQueryDto;
import com.matrix.core.tools.StringUtils;
import lombok.Data;
@Data
public class AchieveNewStatisticsDto extends BasePageQueryDto {
    //规则名称
    String achieveRuleId;
    //业绩归属人id
    String staffName;
    //门店名称
    Long shopId;
    //公司id
    Long companyId;
    //订单类型
    String orderType;
    @Override
    public void setSort(String sort) {
        if(StringUtils.isNotBlank(sort)){
            if ("ruleName".equals(sort)) {
                super.setSort("u.name");
            } else {
                super.setSort(CaseFormat.LOWER_CAMEL.to
                        (CaseFormat.LOWER_UNDERSCORE, sort));
            }
        }else{
            super.setSort(sort);
        }
    }
}
zq-erp/src/main/java/com/matrix/system/hive/service/AchieveRuleService.java
New file
@@ -0,0 +1,33 @@
package com.matrix.system.hive.service;
import cn.hutool.json.JSONUtil;
import com.matrix.system.hive.bean.AchieveRule;
import com.matrix.system.hive.dao.AchieveRuleDao;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
/**
 * 业绩规则服务
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Service
@AllArgsConstructor
public class AchieveRuleService {
    AchieveRuleDao achieveRuleDao;
    /**
     * 根据id查询 AchieveRule
     * @param id
     * @return
     */
    public AchieveRule selectById(Long id){
        AchieveRule achieveRule = achieveRuleDao.selectById(id);
        achieveRule.setRuleItemList(JSONUtil.toList(JSONUtil.parseArray(achieveRule.getRules()), AchieveRuleItem.class));
        return achieveRule;
    }
}
zq-erp/src/main/java/com/matrix/system/hive/service/imp/AchieveNewServiceImpl.java
@@ -1,6 +1,7 @@
package com.matrix.system.hive.service.imp;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONUtil;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.PaginationVO;
@@ -16,13 +17,11 @@
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.*;
import com.matrix.system.hive.dao.AchieveNewDao;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
import com.matrix.system.hive.dao.SysBeauticianStateDao;
import com.matrix.system.hive.dao.SysProjUseDao;
import com.matrix.system.hive.dao.*;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.hive.service.AchieveNewService;
import com.matrix.system.hive.service.SysProjServicesService;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -185,8 +184,14 @@
            // 是否为赠送业绩
            if (Dictionary.TAOCAN_SOURCE_ZS.equals(projUse.getSource())) {
                achieveNew.setFreeConsume(projUse.getPrice()*beauticianState.getCount());
                //计算提成
                achieveNew.setProjPercentage(
                        calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_ZS,achieveNew.getFreeConsume(),beauticianState.getProjId()));
            } else {
                achieveNew.setHisConsume(projUse.getPrice()*beauticianState.getCount());
                //计算提成
                achieveNew.setProjPercentage(
                        calculationProjPercentage(AchieveRuleItem.ACHIEVE_TYPE_BJ,achieveNew.getHisConsume(),beauticianState.getProjId()));
            }
            achieveNew.setT2(projUse.getSource());
            achieveNew.setDatatime(new Date());
@@ -239,6 +244,36 @@
    }
    @Autowired
    AchieveRuleDao achieveRuleDao;
    private Double calculationProjPercentage(int type, Double consume, Long goodsId) {
         ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(goodsId);
         if(shoppingGoods.getAchieveRuleId()!=null){
             AchieveRule achieveRule = achieveRuleDao.selectById(shoppingGoods.getAchieveRuleId());
             if(achieveRule!=null){
                 List<AchieveRuleItem> achieveRuleItems = JSONUtil.toList(JSONUtil.parseArray(achieveRule.getRules()), AchieveRuleItem.class);
                 double percentage=0D;
                 for(AchieveRuleItem item:achieveRuleItems){
                     if(item.getAchieveType()==type
                        && (item.getLower() == consume
                             || (item.getLower()< consume && consume < item.getUpper() ))){
                         if(AchieveRuleItem.ACHIEVE_TYPE_FIXED==item.getCalculationType()){
                             percentage=item.getAchieve();
                         }else{
                             percentage= consume * (item.getAchieve()/100);
                         }
                         break;
                     }
                 }
                 return percentage;
             }
         }
        return 0D;
    }
    /**
     * 顾问人头业绩
     * @param achieveNew
@@ -264,7 +299,6 @@
                    for (AchieveNew achieveNew : orderItem.getAchieveList()) {
                        if (achieveNew !=null   && achieveNew.getGoodsCash()!=null) {
                            buildAchieve(pageOrder,  orderItem, achieveNew);
                            // 新增美疗师业绩
                            achieveNewList.add(achieveNew);
                        }
                    }
@@ -290,7 +324,10 @@
        }
        achieveNew.setVipId(pageOrder.getVipId());
        achieveNew.setSaleId(pageOrder.getStaffId());
        if(achieveNew.getSaleId()==null){
            achieveNew.setSaleId(pageOrder.getStaffId());
        }
        if (pageOrder.getPayTime() != null) {
            achieveNew.setDatatime(pageOrder.getPayTime());
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -497,6 +497,12 @@
        if (!Dictionary.ORDER_STATU_DFK.equals(pageOrder.getStatu())) {
            throw new GlobleException("该订单已经收过款,请刷新页面再试!");
        }
        //交易业绩设置是否合理
        checkAchieveIsOk(pageOrder);
        // 更新收款时间
        pageOrder.setPayTime(new Date());
        pageOrder.setStatu(Dictionary.ORDER_STATU_YFK);
@@ -530,6 +536,28 @@
        //设置会员积分
        addVipScore(pageOrder);
    }
    /**
     * 交易业绩设置是否合理
     * @param pageOrder
     */
    private void checkAchieveIsOk(SysOrder pageOrder) {
        double huakouSum = pageOrder.getItems().stream()
                .mapToDouble(
                        item ->
                                item.getAchieveList().stream()
                                        .filter(achieveNew -> "划扣".equals(achieveNew.getPayMethod()))
                                        .mapToDouble(achieve -> achieve.getGoodsCash()).sum()
                ).sum();
        double czkPay= pageOrder.getFlows().stream()
                .filter(sysOrderFlow -> "储值卡".equals(sysOrderFlow.getPayMethod()))
                .mapToDouble(sysOrderFlow ->sysOrderFlow.getAmount().doubleValue()).sum();
        if(czkPay!=huakouSum){
            throw new GlobleException("划扣业绩不等于储值卡扣款金额,请修改业绩设置!");
        }
    }
    /**
@@ -1205,13 +1233,20 @@
        } else {
            puse.setPrice(goodsAssemble.getPrice() * zk);
        }
        puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount())));
        // 赠送和打折后金额为0的都视为赠送项目
        if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) {
            puse.setSource(Dictionary.TAOCAN_SOURCE_GM);
        } else {
            //赠送产品按原价计算消耗
            puse.setSource(Dictionary.TAOCAN_SOURCE_ZS);
            if (taocanId == null) {
                puse.setPrice(goodsAssemble.getShoppingGoods().getPrice() );
            } else {
                puse.setPrice(goodsAssemble.getPrice());
            }
        }
        puse.setBalance(MoneyUtil.mul(puse.getPrice(), Double.valueOf(puse.getSurplusCount())));
        puse.setFailTime(failTime);
        sysProjUseDao.insert(puse);
        return puse;
@@ -1291,18 +1326,22 @@
        puse.setVipId(order.getVipId());
        puse.setStatus(Dictionary.TAOCAN_STATUS_YX);
        puse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM);
        puse.setBalance(sysOrderItem.getZkPrice());
        puse.setPrice(sysOrderItem.getZkPrice());
        puse.setProjName(sysOrderItem.getShoppingGoods().getName());
        // 赠送和打折后金额为0的都视为赠送项目
        if (sysOrderItem.getIsFree().equals(Dictionary.FLAG_NO) && sysOrderItem.getZkPrice() > 0) {
            puse.setSource(Dictionary.TAOCAN_SOURCE_GM);
            puse.setPrice(sysOrderItem.getZkPrice());
        } else {
            puse.setSource(Dictionary.TAOCAN_SOURCE_ZS);
            //赠送产品按原价计算消耗
            puse.setPrice(sysOrderItem.getShoppingGoods().getSealPice());
        }
        // 设置失效时间
        Date invalidTime = shoppingGoodsService.calInvalidTime(sysOrderItem.getShoppingGoods(), 1, null);
        puse.setFailTime(invalidTime);
        puse.setBalance(sysOrderItem.getShoppingGoods().getSealPice()*puse.getSurplusCount());
        sysProjUseDao.insert(puse);
    }
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);
zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java
@@ -1,5 +1,7 @@
package com.matrix.system.hive.statistics;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
@@ -13,14 +15,17 @@
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.AchieveNew;
import com.matrix.system.hive.dao.AchieveNewDao;
import com.matrix.system.hive.dto.AchieveNewStatisticsDto;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.hive.service.AchieveNewService;
import com.matrix.system.hive.service.SysOrderItemService;
import com.matrix.system.hive.service.SysOrderService;
import com.matrix.system.hive.vo.AchieveNewStatisticsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -53,6 +58,25 @@
    @Autowired
    private AchieveNewDao achieveNewDao;
    /**
     * 员工业绩统计
     */
    @PostMapping(value = "/achieveNewStatistics")
    public @ResponseBody
    AjaxResult achieveNewStatistics(@RequestBody  AchieveNewStatisticsDto queryDto){
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
        queryDto.setCompanyId(sysUsers.getCompanyId());
        Page<AchieveNewStatisticsVo> page = new Page(queryDto.getPageNum(), queryDto.getPageSize());
        IPage<AchieveNewStatisticsVo> rows = achieveNewDao.achieveNewStatistics(page,queryDto);
        AjaxResult result = AjaxResult.buildSuccessInstance(rows.getRecords(),rows.getTotal());
        return result;
    }
    /**
     * 门店每日单据明细表
     */
@@ -74,11 +98,16 @@
     */
    @RequestMapping(value = "/findDailyInfoNew")
    public @ResponseBody
    AjaxResult findDailyInfoNew(AchieveNew achieveNew, PaginationVO pageVo) {
    AjaxResult findDailyInfoNew(@RequestBody  AchieveNew achieveNew) {
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
        achieveNew.setCompanyId(sysUsers.getCompanyId());
        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
            achieveNew.setShopId(sysUsers.getShopId());
        }
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(achieveNew.getOffset());
        pageVo.setLimit(achieveNew.getLimit());
        pageVo.setSort("datatime");
        pageVo.setOrder("desc");
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, achieveNewService.findDayFlow(achieveNew, pageVo),
@@ -86,6 +115,55 @@
        return result;
    }
    @RequestMapping(value = "/exportAchieveNewStatisticsExcel")
    public void exportAchieveNewStatisticsExcel(ModelMap model, HttpServletRequest request, HttpServletResponse response,   AchieveNewStatisticsDto queryDto) throws IOException {
        //这里是从数据库里查数据并组装成我们想要的数据结构的过程
        List<ExcelSheetPO> res = new ArrayList<>();
        ExcelSheetPO orderSheet = new ExcelSheetPO();
        String title = "员工业绩统计";
        orderSheet.setSheetName(title);
        orderSheet.setTitle(title);
        String[] header = {"规则名称", "门店名称", "业绩归属人", "业绩创建人", "订单金额", "现金", "划扣", "本金消耗", "赠送消耗"
                , "服务提成", "人头", "项目个数", "服务时间", "订单类型"};
        orderSheet.setHeaders(header);
        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
            queryDto.setShopId(sysUsers.getShopId());
        }
        queryDto.setCompanyId(sysUsers.getCompanyId());
        Page<AchieveNewStatisticsVo> page = new Page(1, Long.MAX_VALUE);
        IPage<AchieveNewStatisticsVo> rows = achieveNewDao.achieveNewStatistics(page,queryDto);
        List<AchieveNewStatisticsVo> dataList = rows.getRecords();
        List<List<Object>> list = new ArrayList<>();
        if (dataList.size() > 0) {
            for (AchieveNewStatisticsVo item : dataList) {
                List<Object> temp = new ArrayList<>();
                temp.add(item.getRuleName());
                temp.add(item.getShopName());
                temp.add(item.getGuwen());
                temp.add(item.getCreateBy());
                temp.add(item.getZkTotal());
                temp.add(item.getGoodsCash());
                temp.add(item.getCardCash());
                temp.add(item.getHisConsume());
                temp.add(item.getFreeConsume());
                temp.add(item.getProjPercentage());
                temp.add(item.getNumberOfPeople());
                temp.add(item.getProjNum());
                temp.add(item.getProjTime());
                temp.add(item.getOrderType());
                list.add(temp);
            }
        }
        orderSheet.setDataList(list);
        res.add(orderSheet);
        response = ResponseHeadUtil.setExcelHead(response);
        response.setHeader("Content-Disposition",
                "attachment;filename=" + java.net.URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8"));
        OutputStream os = response.getOutputStream();
        com.matrix.core.tools.excl.ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
    }
    @RequestMapping(value = "/exportDailyInfoNew")
    public void exportDailyInfoNew(ModelMap model, HttpServletRequest request, HttpServletResponse response, AchieveNew achieveNew) throws IOException {
        //这里是从数据库里查数据并组装成我们想要的数据结构的过程
zq-erp/src/main/java/com/matrix/system/hive/vo/AchieveNewStatisticsVo.java
New file
@@ -0,0 +1,42 @@
package com.matrix.system.hive.vo;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class AchieveNewStatisticsVo {
    //规则名称
    String ruleName;
    //业绩归属人
    String guwen;
    //业绩归属人id
    Long gwid;
    //订单创建人
    String createBy;
    //创建人id
    Long createId;
    //订单金额
    BigDecimal zkTotal;
    //消耗金额
    BigDecimal hisConsume;
    //赠送消耗
    BigDecimal freeConsume;
    //项目提成
    BigDecimal projPercentage;
    // 人头数
    Double numberOfPeople;
    //项目数
    Double projNum;
    //项目时长
    Integer projTime;
    //现金支付
    BigDecimal goodsCash;
    //卡项支付
    BigDecimal cardCash;
    //门店名称
    String shopName;
    //订单类型
    String orderType;
}
zq-erp/src/main/java/com/matrix/system/hiveErp/action/AchieveRuleAction.java
New file
@@ -0,0 +1,129 @@
package com.matrix.system.hiveErp.action;
import cn.hutool.core.date.DateTime;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.BasePageQueryDto;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.dao.SysUsersDao;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.AchieveRule;
import com.matrix.system.hive.dao.AchieveRuleDao;
import com.matrix.system.hiveErp.pojo.AchieveRuleItem;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
 * 业绩规则Api
 *
 * @author jiangyouyao
 * @date 2021-06-03
 **/
@RestController
@AllArgsConstructor
@RequestMapping(value = "/admin/achieveRule")
public class AchieveRuleAction {
    private AchieveRuleDao achieveRuleDao;
    private SysUsersDao sysUsersDao;
    /**
     * 新增业绩规则
     * @param achieveRule
     * @return
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody @Validated AchieveRule achieveRule) {
        String rules = JSONUtil.toJsonStr(achieveRule.getRuleItemList());
        achieveRule.setRules(rules);
        QueryUtil.setQueryLimitCom(achieveRule);
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        achieveRule.setCreateTime(DateTime.now());
        achieveRule.setUpdateTime(DateTime.now());
        achieveRule.setCreateBy(user.getSuName());
        achieveRule.setUpdateBy(user.getSuName());
        achieveRuleDao.insert(achieveRule);
        return AjaxResult.buildSuccessInstance("新增成功");
    }
    /**
     * 修改业绩规则
     *
     * @param achieveRule
     * @return
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody @Validated AchieveRule achieveRule) {
        if (achieveRule.getId() == null) {
            return AjaxResult.buildFailInstance("id不能为空");
        }
        String rules = JSONUtil.toJsonStr(achieveRule.getRuleItemList());
        achieveRule.setRules(rules);
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        achieveRule.setUpdateBy(user.getSuName());
        achieveRule.setUpdateTime(DateTime.now());
        achieveRuleDao.updateById(achieveRule);
        return AjaxResult.buildSuccessInstance("修改成功");
    }
    /**
     * 删除id
     *
     * @param id
     * @return
     */
    @GetMapping("/removeById/{id}")
    public AjaxResult removeById(@PathVariable Long id) {
        achieveRuleDao.deleteById(id);
        return AjaxResult.buildSuccessInstance("删除成功");
    }
    /**
     * 分页查询规则
     *
     * @param pageDto
     * @return
     */
    @PostMapping("/selectList")
    public AjaxResult selectList(@RequestBody BasePageQueryDto pageDto) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        Page<AchieveRule> page = new Page<>(pageDto.getPageNum(), pageDto.getPageSize());
        LambdaQueryWrapper<AchieveRule> lambdaQueryWrapper = new LambdaQueryWrapper<AchieveRule>()
                .eq(AchieveRule::getCompanyId, user.getCompanyId());
        if (StringUtils.isNotBlank(pageDto.getKeywords())) {
            lambdaQueryWrapper.like(AchieveRule::getName, pageDto.getKeywords());
        }
        IPage<AchieveRule> achieveRuleIPage = achieveRuleDao.selectPage(page, lambdaQueryWrapper);
        achieveRuleIPage.getRecords().stream().forEach(item->{
            item.setRuleItemList(JSONUtil.toList(JSONUtil.parseArray(item.getRules()), AchieveRuleItem.class));
            item.setRules(null);
        });
        AjaxResult result = AjaxResult.buildSuccessInstance(achieveRuleIPage.getRecords(), achieveRuleIPage.getTotal());
        return result;
    }
    @PostMapping("/selectListForm")
    public AjaxResult selectListForm(BasePageQueryDto pageDto) {
        return selectList(pageDto);
    }
}
zq-erp/src/main/java/com/matrix/system/hiveErp/pojo/AchieveRuleItem.java
New file
@@ -0,0 +1,56 @@
package com.matrix.system.hiveErp.pojo;
import lombok.Data;
/**
 * 绩效规则明细
 * @author JIANGYOUYAO
 * @date 2021/6/3 0003
 */
@Data
public class AchieveRuleItem {
    /**
     * 类型,1本金消耗
     */
    public static final int ACHIEVE_TYPE_BJ=1;
    /**
     * 类型,2赠送消耗
     */
    public static final int ACHIEVE_TYPE_ZS =2;
    /**
     * 计算类型 1 固定值
     */
    public static final int ACHIEVE_TYPE_FIXED=1;
    /**
     * 计算类型 2百分比
     */
    public static final int ACHIEVE_TYPE_PERCENTAGE=2;
    /**
     * 类型,1本金消耗,2赠送消耗
     */
    private Integer achieveType;
    /**
     * 计算类型 1 固定值,2百分比
     */
    private Integer calculationType;
    /**
     * 区间-低
     */
    private Double Lower ;
    /**
     * 区间-高
     */
    private Double upper ;
    /**
     * 业绩值
     */
    private Double achieve;
}
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();
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, "保存成功");
        }
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;
    }
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("已经存在上级");
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)));
                }
            });
        }
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;
    }
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()));
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);
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("未配置订单钉钉提醒");
        }
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));
        //如果是积分支付则需要返还积分
zq-erp/src/main/java/filecopy.java
New file
@@ -0,0 +1,80 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
 * 文件对比复制
 * @author JIANGYOUYAO
 * @date 2021/6/7 0007
 */
public class filecopy {
    static  String targetFilePath="/mnt/sdc/webresource";
    static  String sourceFilePaht="/mnt/sdc/webresourceback";
    public static void main(String[] args) throws IOException {
        File sourceFile=new File(sourceFilePaht);
        traverseFolder(sourceFile);
    }
    public static  void traverseFolder(File file) throws IOException {
        if (file.exists()) {
            File[] files = file.listFiles();
            if (null == files || files.length == 0) {
                System.out.println("文件夹是空的!");
                return;
            } else {
                for (File file2 : files) {
                    if (file2.isDirectory()) {
                        //对比target是否存在
                        final String s = file2.getCanonicalPath().replaceAll("webresourceback", "webresource");
                        File f=new File(s);
                        if(!f.exists()){
                            System.out.println("复制文件:" + file2.getAbsolutePath());
                            f.mkdir();
                        }else{
                            System.out.println("文件:" + file2.getAbsolutePath()+"存在");
                        }
                        traverseFolder(file2);
                    } else {
                        //对比target是否存在,不存在则copy
                        final String s = file2.getCanonicalPath().replaceAll("webresourceback", "webresource");
                        File f=new File(s);
                        if(!f.exists()){
                            System.out.println("复制文件:" + file2.getAbsolutePath());
                            FileInputStream in=new FileInputStream(file2);
                            FileOutputStream out=new FileOutputStream(f);
                            byte[] buff=new byte[1024];
                            int length=in.read(buff);
                            while (length>0){
                                out.write(buff,0,length);
                                length=in.read(buff);
                            }
                            out.close();
                            in.close();
                        }else{
                            System.out.println("文件:" + file2.getAbsolutePath()+"存在");
                        }
                    }
                }
            }
        } else {
            System.out.println("文件不存在!");
        }
    }
}
zq-erp/src/main/resources/config/application.properties
@@ -3,19 +3,20 @@
#线上测试环境
#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
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)">
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveNewDao.xml
@@ -95,6 +95,7 @@
        left join sys_proj_services l on a.service_order_id=l.id
        left join sys_order_item j on a.order_item_id=j.ID
        <where>
            and    a.company_id = #{record.companyId}
            <if test="record!=null">
                <if
                    test="(record.shopId!=null and record.shopId!='') or  (record.shopId!='' and record.shopId==0)  ">
@@ -118,9 +119,7 @@
                <if test="record.beaultId != null and record.beaultId !='' ">
                    and    a.beault_id = #{record.beaultId}
                </if>
                <if test="record.companyId != null and record.companyId !='' ">
                    and    a.company_id = #{record.companyId}
                </if>
                <if test="record.beaultId != null and record.beaultId !='' ">
                    and    a.beault_id = #{record.beaultId}
                </if>
@@ -196,7 +195,41 @@
        </where>
    </select>
<!--
 统计员工业绩
select
        u.name,
        g.su_name guwen,
        cast(SUM(b.ZK_TOTAL) AS decimal(15,2)) as zk_total,
        cast(SUM(a.his_consume) AS decimal(15,2)),
        cast(SUM(a.free_consume) AS decimal(15,2)),
        cast(SUM(a.proj_percentage) AS decimal(15,2)),
        cast(SUM(a.number_of_people) AS decimal(15,2)),
        cast(SUM(a.proj_num) AS decimal(15,2)),
        cast(SUM(a.proj_time) AS decimal(15,2)),
        h.shop_short_name shop_name,
        a.order_type,
        a.achieveType
        from
        achieve_new a
        left join sys_order b on a.order_id=b.id
        left join sys_vip_info c on a.vip_id=c.id
        left join sys_vip_level d on c.LEVEL_ID=d.id
        left join shopping_goods e on a.shopping_goods_id=e.id
        LEFT JOIN sys_users f on a.beault_id=f.su_id
        LEFT JOIN sys_users g on a.sale_id = g.su_id
        LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID
        LEFT JOIN shopping_goods_category i ON e.cate_id = i.id
        left join sys_proj_services l on a.service_order_id=l.id
        left join sys_order_item j on a.order_item_id=j.ID
        left join achieve_rule u on u.id=e.achieve_rule_id
 where h.shop_short_name='龙华店'
    GROUP BY g.su_name , a.order_type, h.id,a.achieveType
    ORDER BY g.su_name
-->
    <select id="findSumDailyInfoNew" resultMap="AchieveNewMap">
@@ -1090,6 +1123,68 @@
          and date_format(datatime, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d')
    </select>
    <select id="achieveNewStatistics" resultType="com.matrix.system.hive.vo.AchieveNewStatisticsVo">
        select
            u.name ruleName,
            f.su_name guwen,
            f.su_id gwid,
            g.su_name createBy,
            g.su_id createId,
            cast(SUM(b.ZK_TOTAL) AS decimal(15,2)) as zk_total,
            cast(SUM(a.his_consume) AS decimal(15,2)) his_consume,
            cast(SUM(a.free_consume) AS decimal(15,2)) free_consume,
            cast(SUM(a.proj_percentage) AS decimal(15,2)) proj_percentage,
            cast(SUM(a.number_of_people) AS decimal(15,2)) number_of_people,
            cast(SUM(a.proj_num) AS decimal(15,2)) proj_num,
            cast(SUM(case when a.pay_method = '划扣' then goods_cash end )AS decimal(15,2)) card_cash,
            cast(SUM(a.proj_time) AS decimal(15,2)) proj_time,
            cast(SUM(case when a.pay_method = '现金' then goods_cash end )AS decimal(15,2)) goods_cash,
            h.shop_short_name shop_name,
            a.order_type
        from
            achieve_new a
                left join sys_order b on a.order_id=b.id
                left join sys_vip_info c on a.vip_id=c.id
                left join sys_vip_level d on c.LEVEL_ID=d.id
                left join shopping_goods e on a.shopping_goods_id=e.id
                LEFT JOIN sys_users f on a.beault_id=f.su_id
                LEFT JOIN sys_users g on a.sale_id = g.su_id
                LEFT JOIN sys_shop_info h ON a.SHOP_ID = h.ID
                LEFT JOIN shopping_goods_category i ON e.cate_id = i.id
                left join sys_proj_services l on a.service_order_id=l.id
                left join sys_order_item j on a.order_item_id=j.ID
                left join achieve_rule u on u.id=e.achieve_rule_id
        <where>
            and a.company_id = #{record.companyId}
            <if test="record.shopId != null">
                and a.shop_id = #{record.shopId}
            </if>
            <if test="record.achieveRuleId != null">
                and u.id = #{record.achieveRuleId}
            </if>
            <if test="record.staffName != null and record.staffName!=''">
            <!-- 创建人和归属人都有业绩 -->
                and (f.su_name like concat('%',#{record.staffName},'%')  or g.su_name like concat('%',#{record.staffName},'%')  )
            </if>
            <if test="record.orderType != null and record.orderType != '' ">
                and a.order_type= #{record.orderType}
            </if>
            <if test="record.beginTime != null ">
                and a.datatime >= #{record.beginTime}
            </if>
            <if test="record.endTime != null   ">
                <![CDATA[and a.datatime <= #{record.endTime}]]>
            </if>
        </where>
        GROUP BY g.su_id , f.su_id, a.order_type, h.id,a.achieveType,u.name
        <if test="record.sort !=null and record.sort!=''"> order by ${record.sort} ${record.order}</if>
    </select>
    <update id="updateAchieveNumOfPeople">
        <foreach collection="list" item="item" index="index"
zq-erp/src/main/resources/mybatis/mapper/hive/AchieveRuleDao.xml
New file
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.matrix.system.hive.dao.AchieveRuleDao">
</mapper>
zq-erp/src/main/resources/mybatis/mapper/hive/OnlinebookingDao.xml
@@ -17,7 +17,7 @@
            <result property="staffId" column="staff_id" />
            <result property="vipName" column="vip_name" />
            <result property="tel" column="tel" />
            <result property="bizUserId" column="sys_vip_info_id" />
            <result property="bizUserId" column="biz_user_id" />
            <result property="formId" column="form_id" />
        <result property="productId" column="product_id" />
@@ -42,7 +42,7 @@
            <result property="staffId" column="staff_id" />
            <result property="vipName" column="vip_name" />
            <result property="tel" column="tel" />
            <result property="bizUserId" column="sys_vip_info_id" />
            <result property="bizUserId" column="biz_user_id" />
            <result property="productId" column="product_id" />
        <result property="orderNo" column="order_no" />
        <result property="formId" column="form_id" />
@@ -66,7 +66,7 @@
            staff_id,
            vip_name,
            tel,
            sys_vip_info_id,
            biz_user_id,
            product_id,
            order_no,
            form_id
@@ -129,7 +129,7 @@
                    tel = #{tel},
                </if>
                <if test="(bizUserId!=null and bizUserId!='') or (bizUserId!='' and bizUserId==0)">
                    sys_vip_info_id = #{bizUserId},
                    biz_user_id = #{bizUserId},
                </if>
                <if test="(productId!=null and productId!='') or (productId!='' and productId==0)">
                    product_id = #{productId},
@@ -199,7 +199,7 @@
        staff_id,
        vip_name,
        tel,
        sys_vip_info_id,
        biz_user_id,
        product_id,
        order_no,
        form_id,
@@ -303,7 +303,7 @@
        staff_id,
        vip_name,
        tel,
        sys_vip_info_id,
        biz_user_id,
        product_id
        from onlinebooking
        where 1=1
@@ -417,7 +417,7 @@
            staff_id,
            vip_name,
            tel,
            sys_vip_info_id,
            biz_user_id,
            product_id,
            order_no
        from onlinebooking
@@ -442,7 +442,7 @@
        staff_id,
        vip_name,
        tel,
        sys_vip_info_id,
        biz_user_id,
        product_id
        from onlinebooking
        where 1=1
@@ -495,7 +495,7 @@
        staff_id,
        vip_name,
        tel,
        sys_vip_info_id,
        biz_user_id,
        product_id,
        order_no
        from onlinebooking
@@ -547,7 +547,7 @@
        staff_id,
        vip_name,
        tel,
        sys_vip_info_id,
        biz_user_id,
        product_id,
        order_no,
        form_id,
@@ -565,7 +565,7 @@
                and vip_Id  = #{record.vipId}
            </if>
            <if test="(record.bizUserId!=null and record.bizUserId!='') or (record.bizUserId!='' and record.bizUserId==0)">
                and sys_vip_info_id  = #{record.bizUserId}
                and biz_user_id  = #{record.bizUserId}
            </if>
            <if test="(record.time!=null and record.time!='') or (record.time!='' and record.time==0)">
                and time  = #{record.time}
@@ -611,7 +611,7 @@
                and vip_Id  = #{record.vipId}
            </if>
            <if test="(record.bizUserId!=null and record.bizUserId!='') or (record.bizUserId!='' and record.bizUserId==0)">
                and sys_vip_info_id  = #{record.bizUserId}
                and biz_user_id  = #{record.bizUserId}
            </if>
            <if test="(record.time!=null and record.time!='') or (record.time!='' and record.time==0)">
                and time  = #{record.time}
zq-erp/src/main/resources/mybatis/mapper/hive/ShoppingGoodsDao.xml
@@ -85,12 +85,15 @@
        <result property="goodsSortName" column="goodsSortName" />
        <result property="achieveRuleName" column="achieveRuleName" />
        <result property="payMethods" column="pay_methods" />
        <result property="invalidTime" column="invalid_time" />
        <result property="useValid" column="use_valid" />
        <result property="buyValid" column="buy_valid" />
        <result property="isInfinite" column="is_infinite" />
        <result property="achieveRuleId" column="achieve_rule_id" />
@@ -160,11 +163,14 @@
        <!-- 服务项目信息 -->
        <result property="proReward" column="proReward" />
        <result property="timeLength" column="TIME_LENGTH" />
        <result property="achieveRuleId" column="achieve_rule_id" />
        <!-- 扩展属性 -->
        <result property="cateName" column="cate_name" />
        <result property="goodsSortName" column="goodsSortName" />
        <result property="achieveRuleName" column="achieveRuleName" />
    </resultMap>
@@ -301,7 +307,9 @@
        use_valid,
        invalid_time,
        pay_methods,
        is_infinite
        is_infinite,
        achieve_rule_id
        )
        VALUES (
        #{id},
@@ -362,7 +370,9 @@
            #{useValid},
            #{invalidTime},
            #{payMethods},
            #{isInfinite}
            #{isInfinite},
            #{achieveRuleId}
        )
    </insert>
@@ -538,6 +548,10 @@
            <if test="isInfinite != null and isInfinite !='' ">
                is_infinite = #{isInfinite},
            </if>
            <if test="achieveRuleId != null and achieveRuleId !='' ">
                achieve_rule_id = #{achieveRuleId},
            </if>
                invalid_time = #{invalidTime},
                buy_valid = #{buyValid},
                use_valid = #{useValid},
@@ -576,8 +590,9 @@
    <select id="selectInPage" resultMap="ShoppingGoodsMap">
        select
        a.*,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from shopping_goods_category t where t.id=a.cate_id) cate_name,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) as  goodsSortName,
        (select NAME from shopping_goods_category t where t.id=a.cate_id) as cate_name,
        (select  shop_name from  sys_shop_info h where  a.SHOP_ID=h.ID ) as shop_name
        from shopping_goods a
        where 1=1
@@ -652,6 +667,11 @@
            </if>
            <if test="record.achieveRuleId != null and record.achieveRuleId !='' ">
                and achieve_rule_id = #{record.achieveRuleId}
            </if>
            <if test="record.headquarters != null and record.headquarters !='' ">
                and headquarters = #{record.headquarters}
@@ -718,7 +738,9 @@
            <if test="record.isVipCar != null and record.isVipCar !='' ">
                and is_vip_car = #{record.isVipCar}
            </if>
            <if test="record.achieveRuleId != null and record.achieveRuleId !='' ">
                and achieve_rule_id = #{record.achieveRuleId}
            </if>
            <if test="record.isCourse != null and record.isCourse !=''">
                and is_course = #{record.isCourse}
@@ -763,6 +785,7 @@
    <select id="selectAll" resultMap="ShoppingGoodsSimpleMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from
        shopping_goods_category t where t.id=cate_id)
@@ -868,6 +891,7 @@
    <select id="findByCode" resultMap="ShoppingGoodsMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from shopping_goods_category t where
        t.id=cate_id)
@@ -880,6 +904,7 @@
    <select id="selectSimpleMapById" resultMap="ShoppingGoodsSimpleMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from
        shopping_goods_category t where t.id=cate_id)
@@ -899,6 +924,7 @@
    <select id="selectByModel" resultMap="ShoppingGoodsMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from
        shopping_goods_category t where t.id=cate_id)
@@ -978,6 +1004,7 @@
    <select id="selectByModel1" resultMap="ShoppingGoodsMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from
        shopping_goods_category t where t.id=cate_id)
@@ -1056,6 +1083,7 @@
    <select id="selectInPageNoTaocan" resultMap="ShoppingGoodsMap">
        select
        *,
        (select name from achieve_rule f where f.id=a.achieve_rule_id) as achieveRuleName,
        (select TYPE_NAME from sys_goods_type b where b.id=a.goods_sort_id) goodsSortName,
        (select NAME from
        shopping_goods_category t where t.id=cate_id)
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">
zq-erp/src/main/resources/templates/views/admin/hive-erp/products/achieverule-list.html
New file
@@ -0,0 +1,402 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <LINK rel="Bookmark" href="../images/favicon.ico">
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script>
    <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
    <title></title>
    <style>
        .panel-body {
            overflow: hidden;
        }
        .buttonPanel {
            background: #ffffff;
            padding: 10px 10px;
            margin: 0px 0px 10px 0px;
        }
        .rowPanel {
            background: #ffffff;
            padding: 0px 10px;
            padding-top: 10px;
            margin: 0px 0px 10px 0px;
        }
        .paginationStyle {
            background: #ffffff;
            padding: 10px 10px;
            margin: 0px 0px 10px 0px;
            text-align: right;
        }
    </style>
</head>
<body>
<div class="panel-body" id="app">
    <el-row class="buttonPanel">
        <el-button @click="openForm('add')" type="primary">新增</el-button>
    </el-row>
    <el-row class="rowPanel">
        <el-form ref="form" :model="form" inline>
            <el-form-item label="规则名称" prop="queryKey">
                <el-input v-model="form.keyword" placeholder="请输入规则名称"></el-input>
            </el-form-item>
            <el-button type="primary" @click="search">搜索</el-button>
            <el-button @click="resetForm('form')">重置</el-button>
        </el-form>
    </el-row>
    <el-row class="table-style">
        <el-table id="proj" :data="table.rows" :height="height" stripe @sort-change="sortChange">
            <el-table-column
                    prop="name"
                    label="规则名称">
            </el-table-column>
            <el-table-column
                    prop="updateTime"
                    sortable="custom"
                    label="修改时间"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="updateBy"
                    label="修改人">
            </el-table-column>
            <el-table-column
                    prop="createTime"
                    sortable="custom"
                    label="创建时间"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="createBy"
                    label="创建人"
                    width="180">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="openForm('modify', scope.row)" size="small">修改</el-button>
                    <el-button type="text" @click="remove(scope.$index, scope.row)" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="paginationStyle">
        <el-pagination background
                       @size-change="changePageSize"
                       @current-change="changeCurrentPage"
                       :current-page="table.currentPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :page-size="table.pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="table.total">
        </el-pagination>
    </el-row>
    <el-dialog
            :title="title"
            :visible.sync="dialogVisible"
            width="60%"
            :before-close="handleClose">
        <el-form :model="formData" ref="ruleForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="规则名称"  >
                <el-input style="width: 200px" v-model="formData.name"></el-input>
                <el-button type="primary" @click="addRuleItem()" size="small">添加规则</el-button>
            </el-form-item>
            <el-form-item label="绩效方案" >
                <el-table
                        :data="formData.ruleItemList"
                        style="width: 100%">
                    <el-table-column
                            label="业绩类型"
                    >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.achieveType" placeholder="请选择业绩类型">
                                <el-option label="本金消耗" :value="1"></el-option>
                                <el-option label="赠送消耗" :value="2"></el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="计算方式"
                    >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.calculationType" placeholder="请选择计算方式">
                                <el-option label="固定金额" :value="1"></el-option>
                                <el-option label="百分比(%)" :value="2"></el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="区间"
                            width="240">
                        <template slot-scope="scope">
                            <el-input style="width: 100px" v-model="scope.row.lower"></el-input>
                            -
                            <el-input style="width: 100px" v-model="scope.row.upper"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="业绩">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.achieve"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-button  type="text" @click="removeRuleItem(scope.$index, scope.row)" size="small">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitForm">确 定</el-button>
            </span>
</el-dialog>
</div>
</body>
<script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var vue = new Vue({
        el: '#app',
        data: {
            table: {
                rows: [],
                total: 0,
                pageSize: 10,
                currentPage: 1,
            },
            form: {
                queryKey: null,
            },
            height: 'calc(100vh - 240px)',
            dialogVisible: false,
            title: '',
            formData: {
                name: '',
                ruleItemList: [
                    {
                        achieveType: 1,
                        calculationType: 1,
                        lower: '',
                        upper: '',
                        achieve: '',
                    }
                ]
            },
            type: '',
        },
        created: function () {
            this.loadData();
            window.addEventListener("keydown", this.keydown);
        },
        methods: {
            changePageSize(val) {
                this.table.pageSize = val;
                this.loadData();
            },
            changeCurrentPage(val) {
                this.table.currentPage = val;
                this.loadData();
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            sortChange: function (column) {
                if (column.order) {
                    if (column.order.indexOf("desc")) {
                        this.form.order = "desc";
                    } else {
                        this.form.order = "asc";
                    }
                    this.form.sort = column.prop;
                    this.loadData();
                }
            },
            loadData: function () {
                let _this = this;
                let data = _this.getRequestParam();
                data.pageSize = _this.table.pageSize;
                data.pageNum = _this.table.currentPage;
                AjaxProxy.requst({
                    app: _this,
                    data: data,
                    url: basePath + '/admin/achieveRule/selectList',
                    callback: function (data) {
                        _this.table.rows = data.rows;
                        _this.table.total = data.total;
                    }
                });
            },
            getRequestParam() {
                let _this = this;
                return {
                    queryKey: _this.form.queryKey,
                }
            },
            search: function () {
                this.table.currentPage = 1;
                this.loadData();
            },
            keydown(evt) {
                if (evt.keyCode == 13) {
                    this.search();
                }
            },
            remove(index, row) {
                let _this = this;
                this.$confirm('确认删除该规则吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    AjaxProxy.requst({
                        app: _this,
                        type: 'GET',
                        url: basePath + "/admin/achieveRule/removeById/" + row.id,
                        callback: function (data) {
                            _this.loadData();
                            _this.$message({
                                type: 'success',
                                message: data.info,
                            });
                        }
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            //开启表单弹窗
            openForm(type, data) {
                if (type == 'add') {
                    this.title = '新增规则';
                    //this.$refs['formName'].resetFields();
                } else {
                    this.title = '修改规则';
                    this.formData = data;
                }
                this.type = type;
                this.dialogVisible = true;
            },
            //提交表单
            submitForm() {
                let url = basePath + "/admin/achieveRule/add";
                if (this.type == 'modify') {
                    url = basePath + "/admin/achieveRule/update";
                }
                let data=this.formData;
                if(MTools.isBlank(data.name)){this.$message.error("请输入规则名称");return;}
                if(data.ruleItemList.length<1){
                    this.$message.error("最少需要一个计算规则");;return;}
                let flag=true;
                data.ruleItemList.forEach(item=>{
                    if(MTools.isBlank(item.lower)){
                        this.$message.error("请输入业绩下限");flag=false;}
                    else if(MTools.isBlank(item.upper)){
                        this.$message.error("请输入业绩上限");flag=false;}
                    else if(MTools.isBlank(item.achieve)){
                        this.$message.error("请输入业绩金额或者比例");flag=false;}
                })
                if(flag){
                    var _this=this;
                    AjaxProxy.requst({
                        app: _this,
                        data:data,
                        url:url,
                        callback: function (data) {
                            _this.$message.success(data.info);
                            _this.loadData();
                            _this.dialogVisible = false;
                            _this.formData={
                                name: '',
                                ruleItemList: [
                                    {
                                        achieveType: 1,
                                        calculationType: 1,
                                        lower: '',
                                        upper: '',
                                        achieve: '',
                                    }
                                ]
                            };
                        }
                    });
                }
            },
            handleClose(done) {
                this.$confirm('确认关闭?')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            addRuleItem(){
                this.formData.ruleItemList.push(
                    {
                        achieveType: 1,
                        calculationType: 1,
                        lower: '',
                        upper: '',
                        achieve: '',
                    }
                );
            },
            removeRuleItem(index,row){
                this.formData.ruleItemList.splice(index, 1);
            },
        }
    });
</script>
</body>
</html>
zq-erp/src/main/resources/templates/views/admin/hive-erp/statistics/achieveNewStatiostics.html
New file
@@ -0,0 +1,366 @@
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <LINK rel="Bookmark" href="../images/favicon.ico">
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script>
    <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
    <title></title>
    <style>
        .panel-body{
            overflow: hidden;
        }
        .buttonPanel{
            background: #ffffff;
            padding: 10px 10px ;
            margin: 0px 0px 10px 0px;
        }
        .rowPanel{
            background: #ffffff;
            padding: 0px 10px ;
            padding-top: 10px;
            margin: 0px 0px 10px 0px;
        }
        .paginationStyle{
            background: #ffffff;
            padding: 10px 10px;
            margin: 0px 0px 10px 0px;
            text-align: right;
        }
    </style>
</head>
<body>
<div class="panel-body" id="app">
    <el-row class="buttonPanel">
            <el-button @click="exportExcel" type="primary" >导出</el-button>
    </el-row>
    <el-row class="rowPanel"  >
        <el-form ref="form" :model="form" inline >
            <el-form-item label="业绩规则"  >
                <el-select v-model="form.achieveRuleId" filterable placeholder="请选择业绩规则">
                    <el-option
                            v-for="item in achieveRulsList"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="员工姓名"  >
                <el-input v-model="form.staffName"></el-input>
            </el-form-item>
            <el-form-item label="统计门店"  >
                <el-select v-model="form.shopId" placeholder="请选择">
                    <el-option
                            v-for="item in shopList"
                            :key="item.shopShortName"
                            :label="item.shopShortName"
                            :value="item.id">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="订单类型" >
                <el-select v-model="form.orderType" placeholder="请选择">
                    <el-option
                            v-for="item in orderTypeList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="统计时间" prop="datetimeArr">
                <el-date-picker
                        v-model="form.datetimeArr"
                        type="daterange"
                        range-separator="至" format="yyyy-MM-dd HH:mm"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期">
                </el-date-picker>
            </el-form-item>
            <el-button type="primary" @click="search" >搜索</el-button>
            <el-button @click="resetForm('form')">重置</el-button>
        </el-form>
    </el-row>
    <el-row class="table-style"  >
        <el-table id="proj" :data="table.rows"  :height="height" stripe @sort-change="sortChange">
            <el-table-column
                    sortable="custom"
                    prop="ruleName"
                    label="规则名称"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="shopName"
                    label="门店名称"
                    show-overflow-tooltip
                    width="240">
            </el-table-column>
            <el-table-column
                    prop="guwen"
                    label="业绩归属人"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="createBy"
                    label="业绩创建人"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="zkTotal"
                    label="订单金额">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="goodsCash"
                    label="现金">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="cardCash"
                    label="划扣">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="hisConsume"
                    label="本金消耗">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="freeConsume"
                    label="赠送消耗">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="projPercentage"
                    label="服务提成">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="numberOfPeople"
                    label="人头">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="projNum"
                    label="项目个数">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="projTime"
                    label="服务时间">
            </el-table-column>
            <el-table-column
                    sortable="custom"
                    prop="orderType"
                    label="订单类型">
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="paginationStyle"  >
        <el-pagination background
                       @size-change="changePageSize"
                       @current-change="changeCurrentPage"
                       :current-page="table.currentPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :page-size="table.pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="table.total">
        </el-pagination>
    </el-row>
</div>
</body>
<script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var vue = new Vue({
        el: '#app',
        data: {
            table:{
                rows:[],
                total:0,
                pageSize:10,
                currentPage:1,
            },
            form:{
                achieveRuleId:null,
                staffName:null,
                shopId:null,
                orderType:'',
                order:'',
                sort:'',
                beginTime:'',
                endTime:'',
            },
            height:'calc(100vh - 240px)',
            //提成规则
            achieveRulsList:[],
            //业绩用户列表
            userList: [],
            shopList:[{id:0,shopShortName:'全部'}],
            orderTypeList:[
                {value:'',label:'全部'},
                {value:'订单',label:'订单'},
                {value:'服务单',label:'服务单'},
            ],
        },
        created: function () {
            let _this=this;
            //获取业绩用户列表
            AjaxProxy.requst({
                app: _this,
                url: basePath + '/admin/shopAll',
                callback: function (data) {
                    _this.userList = data.rows;
                }
            });
            AjaxProxy.requst({
                app:_this,
                url:basePath+"/admin/shopInfo/findAll",
                callback:function (data) {
                    data.rows.forEach(shop=>{
                        _this.shopList.push(shop);
                    });
                }
            })
            this.getAchieveRule();
           this.loadData();
            window.addEventListener("keydown", this.keydown);
        },
        methods: {
            changePageSize(val) {
                this.table.pageSize = val;
                this.loadData();
            },
            changeCurrentPage(val) {
                this.table.currentPage = val;
                this.loadData();
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
                this.form={
                    achieveRuleId:null,
                    staffName:null,
                    shopId:null,
                    orderType:'',
                    order:'',
                    sort:'',
                    beginTime:'',
                    endTime:'',
                };
            },
            sortChange:function (column){
                if(column.order){
                    if(column.order.indexOf("desc")){
                        this.form.order="desc";
                    }else{
                        this.form.order="asc";
                    }
                    this.form.sort=column.prop;
                    this.loadData();
                }
            },
            loadData:function(){
                let _this = this;
                let data=_this.getRequestParam();
                data.pageSize=_this.table.pageSize;
                data.pageNum=_this.table.currentPage;
                AjaxProxy.requst({
                    app: _this,
                    data:data,
                    url: basePath + '/admin/achieve/achieveNewStatistics',
                    callback: function (data) {
                        _this.table.rows = data.rows;
                        _this.table.total=data.total;
                    }
                });
            },
            /**
             * 获取规则
             */
            getAchieveRule(){
                let _this = this;
                AjaxProxy.requst({
                    app: _this,
                    data: {pageNum:1,pageSize:1000},
                    url: basePath + "/admin/achieveRule/selectList",
                    callback: function (data) {
                        _this.achieveRulsList=data.rows;
                    }
                });
            },
            getRequestParam(){
                let _this = this;
                return   {
                    achieveRuleId:_this.form.achieveRuleId,
                    staffName:_this.form.staffName,
                    shopId:_this.form.shopId,
                    orderType:_this.form.orderType,
                    beginTime:_this.form.datetimeArr?moment(_this.form.datetimeArr[0]).format("YYYY-MM-DD HH:mm"):'',
                    endTime:_this.form.datetimeArr?moment(_this.form.datetimeArr[1]).format("YYYY-MM-DD HH:mm"):'',
                    order:_this.form.order,
                    sort:_this.form.sort,
                }
            },
            search:function(){
                this.table.currentPage=1;
                this.loadData();
            },
            keydown(evt){
                if(evt.keyCode==13) {
                    this.search();
                }
            },
            //导出
          exportExcel(){
            window.location.href=basePath+"/admin/achieve/exportAchieveNewStatisticsExcel?"+MTools.jsonToUrlParam(this.getRequestParam());
        }
        }
    });
</script>
</body>
</html>
zq-erp/src/main/resources/templates/views/admin/hive-erp/statistics/daily-list-new.html
@@ -149,7 +149,6 @@
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var vue = new Vue({
        el : "#app",
@@ -184,10 +183,11 @@
        },
        methods : {
            queryTableData () {
                let _this = this;
                var form = _this.form;
                var page = _this.page;
                var params = _this.form;
                let form = _this.form;
                let page = _this.page;
                let params = _this.form;
                params.limit = page.size;
                params.offset = (page.currentPage - 1) * page.size;
@@ -195,11 +195,14 @@
                    params.beginTime = form.timeRange?moment(form.timeRange[0]).format("YYYY-MM-DD HH:mm"):'';
                    params.endTime = form.timeRange?moment(form.timeRange[1]).format("YYYY-MM-DD HH:mm"):'';
                }
                $.AjaxProxy({
                    p:params
                }).invoke(basePath + "/admin/achieve/findDailyInfoNew", function (loj) {
                    _this.tableData = loj.getValue("rows");
                    _this.page.total = loj.getResult().total;
                AjaxProxy.requst({
                    app: _this,
                    data: params,
                    url: basePath + "/admin/achieve/findDailyInfoNew",
                    callback: function (loj) {
                        _this.tableData = loj.rows;
                        _this.page.total = loj.total;
                    }
                });
            },
            queryCustomColumns() {
zq-erp/src/main/resources/templates/views/admin/hive/products/goods-form.html
@@ -83,6 +83,19 @@
                        </el-form-item>
                    </el-col>
                    <el-col :offset="2" :span="10" v-if="form.goodType!='家居产品'">
                        <el-form-item label="业绩规则" prop="achieveRuleId">
                            <el-select v-model="form.achieveRuleId" filterable placeholder="请选择业绩规则">
                                <el-option
                                        v-for="item in achieveRulsList"
                                        :key="item.id"
                                        :label="item.name"
                                        :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
@@ -1097,7 +1110,8 @@
            loading_zhk: false,
            /******综合卡表格数据END********/
            //提成规则
            achieveRulsList:[],
            //默认充值卡选中项
            defaultCates: [],
@@ -1145,6 +1159,8 @@
                useDateNum : '',
                buyDateNum : '',
                payMethods : '',
                achieveRuleId:'',
            },
            submitUrl: '/admin/shoppinggoods/addShoppingGoods',
            modifySubmitUrl: '/admin/shoppinggoods/modifyShoppingGoods',
@@ -1174,6 +1190,7 @@
            this.getGoodstype();
            this.getDictionary();
            this.getShopInfo();
            this.getAchieveRule();
            if(goodType=='家居产品'){
                this.getSupplierList();
            }
@@ -1194,6 +1211,21 @@
        methods: {
            /**
             * 获取规则
             */
            getAchieveRule(){
                let _this = this;
                AjaxProxy.requst({
                    app: _this,
                    data: {pageNum:1,pageSize:1000},
                    url: basePath + "/admin/achieveRule/selectList",
                    callback: function (data) {
                        _this.achieveRulsList=data.rows;
                    }
                });
            },
            /**
             * 商品分类树形组件格式化
             */
            normalizer(node) {
zq-erp/src/main/resources/templates/views/admin/hive/products/shoppinggoods-md-list.html
@@ -62,6 +62,16 @@
                    <option value=''>请选择项目状态</option>
                </select>
            </div>
            <div class="form-group mr-20">
                <label for="staus">业绩规则</label>
                <select class="form-control autoFull" name="achieveRuleId"
                        data-filed="name"
                        data-value="id"
                        th:data-url="@{/admin/achieveRule/selectListForm}"
                        data-param="{pageNum:1,pageSize:1000}">
                    <option value=''>请选择业绩规则</option>
                </select>
            </div>
            <div class="form-group mr-20">
                <label for="isPresent">是否赠送</label>
@@ -114,6 +124,7 @@
                <th data-field="isPresent">是否赠送</th>
                <th data-field="goodType" data-sortable="true">类型</th>
                <th data-field="cateName">分类</th>
                <th data-field="achieveRuleName" >业绩规则</th>
                <th data-field="createTime"  data-sortable="true" data-formatter="MGrid.getTime">创建时间</th>
            </tr>
            </thead>
zq-erp/src/main/resources/templates/views/admin/hive/products/shoppinggoods-zb-list.html
@@ -63,6 +63,16 @@
                    <option value=''>请选择项目状态</option>
                </select>
            </div>
            <div class="form-group mr-20">
                <label for="staus">业绩规则</label>
                <select class="form-control autoFull" name="achieveRuleId"
                        data-filed="name"
                        data-value="id"
                        th:data-url="@{/admin/achieveRule/selectListForm}"
                        data-param="{pageNum:1,pageSize:1000}">
                    <option value=''>请选择业绩规则</option>
                </select>
            </div>
            <div class="form-group mr-20">
                <label for="isPresent">是否赠送</label>
@@ -110,6 +120,7 @@
                <th data-field="isPresent">是否赠送</th>
                <th data-field="goodType" data-sortable="true">类型</th>
                <th data-field="cateName" >分类</th>
                <th data-field="achieveRuleName" >业绩规则</th>
                <th data-field="createTime"  data-sortable="true" data-formatter="MGrid.getTime">创建时间</th>
            </tr>
            </thead>
zq-erp/src/main/resources/templates/views/admin/hive/statistics/daily-list-new.html
@@ -151,7 +151,6 @@
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
<script type="text/javascript" th:inline="javascript">
    var vue = new Vue({
        el : "#app",
@@ -187,10 +186,11 @@
        },
        methods : {
            queryTableData () {
                let _this = this;
                var form = _this.form;
                var page = _this.page;
                var params = _this.form;
                let form = _this.form;
                let page = _this.page;
                let params = _this.form;
                params.limit = page.size;
                params.offset = (page.currentPage - 1) * page.size;
@@ -198,11 +198,14 @@
                    params.beginTime = form.timeRange?moment(form.timeRange[0]).format("YYYY-MM-DD HH:mm"):'';
                    params.endTime = form.timeRange?moment(form.timeRange[1]).format("YYYY-MM-DD HH:mm"):'';
                }
                $.AjaxProxy({
                    p:params
                }).invoke(basePath + "/admin/achieve/findDailyInfoNew", function (loj) {
                    _this.tableData = loj.getValue("rows");
                    _this.page.total = loj.getResult().total;
                AjaxProxy.requst({
                    app: _this,
                    data: params,
                    url: basePath + "/admin/achieve/findDailyInfoNew",
                    callback: function (loj) {
                        _this.tableData = loj.rows;
                        _this.page.total = loj.total;
                    }
                });
            },
            queryCustomColumns() {
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">
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()));
    }
zq-erp/src/test/java/com/matrix/JyyTests2.java
New file
@@ -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());
                }
    }
}
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",