Helius
2021-03-10 62d2a24a0d2c5bca61f727ac3d9e6bd7ce162151
modify
40 files modified
956 ■■■■■ changed files
zq-erp/pom.xml 9 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/tools/WxTempLateMsgUtil.java 108 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java 2 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java 3 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java 75 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/interceptor/HostInterceptor.java 17 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/common/service/impl/InitShopProductCateService.java 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java 8 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java 4 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java 3 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java 29 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WeChatApiTools.java 50 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java 8 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java 9 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java 35 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java 33 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java 21 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java 12 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java 18 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java 31 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java 10 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java 62 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java 6 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java 4 ●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java 32 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java 13 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java 265 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/config/application.properties 3 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml 6 ●●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductAttributeDao.xml 4 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html 11 ●●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html 2 ●●● patch | view | raw | blame | history
zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html 20 ●●●● patch | view | raw | blame | history
zq-erp/pom.xml
@@ -385,10 +385,11 @@
                <filtering>true</filtering>
                <excludes>
                                       <exclude>config/dev/*</exclude>
                                       <exclude>config/prd/*</exclude>
                                       <exclude>config/test/*</exclude>
                                  <exclude>config/xcx/*</exclude>
                    <exclude>config/dev/*</exclude>
                    <exclude>config/prd/*</exclude>
                    <exclude>config/test/*</exclude>
                    <exclude>config/xcx/*</exclude>
  <!--
                                       <exclude>config/config.json</exclude>
zq-erp/src/main/java/com/matrix/component/tools/WxTempLateMsgUtil.java
@@ -1,15 +1,7 @@
package com.matrix.component.tools;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.shopXcx.api.WeChatApiTools;
import net.sf.json.JSONObject;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 小程序消息模板
@@ -141,87 +133,7 @@
    public static int sendWxTemplateMsg(List<String> valueList, String openId,
                                        String page, String tempId, String formId) {
        if (StringUtils.isBlank(openId)) {
            return 0;
        }
        String access_token = "";
        try {
            access_token = WeChatApiTools.getAccessToken();
        } catch (IOException e1) {
            LogUtil.error("获取accesstoken失败", e1.getMessage());
        }
        // 发送模板URL
        String url = WxApiConstants.XCX_TEMPLATEMSG_SEN.replace("ACCESS_TOKEN", access_token);
        WxTemplate temp = new WxTemplate();
        // 跳转地址
        if (StringUtils.isNotBlank(page)) {
            temp.setPage(page);
        }
        temp.setTouser(openId);
        // 消息模版ID
        temp.setTemplateId(tempId);
        Map<String, Object> tempLateMsgMap = new HashMap<String, Object>();
        // 设置模板消息的值
        for (int i = 0; i < valueList.size(); i++) {
            TemplateData keyword = new TemplateData();
            keyword.setValue(valueList.get(i));
            tempLateMsgMap.put(TEMP_KEYWORD + (i + 1), keyword);
        }
        temp.setData(tempLateMsgMap);
        String jsonString = JSONObject.fromObject(temp).toString();
        LogUtil.info("组装模板消息={}", jsonString);
        HttpRequest reqObj = new HttpRequest();
        HttpResponse result = null;
        try {
            result = reqObj.sendHttpsPost(url, null, jsonString);
        } catch (IOException e) {
            LogUtil.error("发送模板通知出错了", e);
        }
        JSONObject json = JSONObject.fromObject(result.getDataString());
        LogUtil.info("发送模板消息结果={}", json);
        int res = 0;
        if (json == null) {
            return res;
        } else {
            res = json.getInt(ERRCODE);
            if (res == Integer.parseInt(SEND_ERROR_40001)) {
                String new_access_token = "";
                try {
                    new_access_token = WeChatApiTools.getAccessToken();
                } catch (IOException e1) {
                    LogUtil.error("获取new_access_token失败", e1.getMessage());
                }
                url = WxApiConstants.XCX_TEMPLATEMSG_SEN.replace("ACCESS_TOKEN", new_access_token);
                try {
                    result = reqObj.sendHttpsPost(url, null, jsonString);
                } catch (IOException e) {
                    LogUtil.error("发送new_access_token模板通知出错了", e);
                }
                json = JSONObject.fromObject(result.getDataString());
                if (json == null) {
                    return res;
                } else {
                    res = json.getInt(ERRCODE);
                    if (res != 0) {
                        // 添加发送失败 信息
                        LogUtil.info("发送new_access_token模板消息错误错误 errcode:{} errmsg:{}" + "," + json.getInt("errcode")
                                + "," + json.getString("errmsg"));
                    } else {
                        return 1;
                    }
                }
            } else if (res != 0) {
                // 添加发送失败 信息
                LogUtil.info("发送模板消息错误错误 errcode:{} errmsg:{}" + "," + json.getInt("errcode") + ","
                        + json.getString("errmsg"));
            } else {
                return 1;
            }
        }
        LogUtil.info("模板消息发送结果:" + res);
        return 0;
    }
@@ -231,25 +143,7 @@
     * @param temp {temp}
     */
    public static void  sendSubscribeMsg(WxSubscribeDto temp) {
        String access_token = "";
        try {
            access_token = WeChatApiTools.getAccessToken();
        } catch (IOException e1) {
            LogUtil.error("获取accesstoken失败", e1.getMessage());
        }
        // 发送模板URL
        String url = WxApiConstants.XCX_TEMPLATEMSG_SEN.replace("ACCESS_TOKEN", access_token);
        String jsonString = JSONObject.fromObject(temp).toString();
        LogUtil.info("组装模板消息={}", jsonString);
        HttpRequest reqObj = new HttpRequest();
        HttpResponse result = null;
        try {
            result = reqObj.sendHttpsPost(url, null, jsonString);
        } catch (IOException e) {
            LogUtil.error("发送模板通知出错了", e);
        }
        JSONObject json = JSONObject.fromObject(result.getDataString());
        LogUtil.info("发送模板消息结果={}", json);
    }
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java
@@ -14,6 +14,7 @@
import com.matrix.component.wechat.externalInterface.service.RefundService;
import com.matrix.component.wechat.externalInterface.service.ScanPayQueryService;
import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
/**
 * User: rizenguo Date: 2014/12/1 Time: 17:05
@@ -55,9 +56,10 @@
        log.info("------------------request createPrapareOrder taking :" + totalTimeCost + "ms"+"--response="+payServiceResponseString);
        // 将从API返回的XML数据映射到Java对象
        JsApiPayResData jsApiPayResData = (JsApiPayResData) Util.getObjectFromXML(payServiceResponseString,
        Object data =  Util.getObjectFromXML(payServiceResponseString,
                JsApiPayResData.class);
        JsApiPayResData jsApiPayResData=new JsApiPayResData();
        BeanUtils.copyProperties(data,jsApiPayResData);
        return jsApiPayResData;
    }
    
zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java
@@ -67,6 +67,8 @@
    public static Object getObjectFromXML(String xml, Class<?> tClass) {
        //将从API返回的XML数据映射到Java对象
        XStream xStreamForResponseData = new XStream();
        XStream.setupDefaultSecurity(xStreamForResponseData);
        xStreamForResponseData.allowTypes(new Class[]{tClass});
        xStreamForResponseData.alias("xml", tClass);
        xStreamForResponseData.ignoreUnknownElements();//暂时忽略掉一些新增的字段
        return xStreamForResponseData.fromXML(xml);
zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java
@@ -76,7 +76,8 @@
        // url权限拦截
        registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**");
        //小程序公司与域名对应关系拦截
        registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**");
        registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**")
                .excludePathPatterns("/wxCommon/wxapi/wxpayCallback");
    }
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -262,41 +262,11 @@
    // =====================================订单包裹相关
    /**
     * 省内包裹
     */
    public static final String IN_PROVINCE_PACKAGE = "IN_PROVINCE_PACKAGE";
    /**
     * 外省包裹
     */
    public static final String OUT_PROVINCE_PACKAGE = "OUT_PROVINCE_PACKAGE";
    /**
     * 省内免邮费包裹
     */
    public static final String PROVINCE_OVER_FREE_PACKAGE = "PROVINCE_OVER_FREE_PACKAGE";
    // =====================================订单短信提醒相关
    /**
     * 短信提醒
     */
    public static final String MSG_ALERT = "MSG_ALERT";
    /**
     * 短信提醒号码(多个以",分割")
     */
    public static final String MSG_ALERT_MOBILE = "MSG_ALERT_MOBILE";
    /**
     * 短信提醒内容
     */
    public static final String MSG_ALERT_CONTENT = "MSG_ALERT_CONTENT";
    /**
     * 商户余额不足短信提醒内容
     */
    public static final String MSG_ALERT_NSF = "MSG_ALERT_NSF";
    /**
     * 待开票
@@ -542,51 +512,14 @@
    public static final String REFUND_FAIL_NOTENOUGH = "NOTENOUGH";
    // =====================================分销相关
    /**
     * 成为分销商最低额度(查询数据字典时使用)
     * 运费
     */
    public static final String BECOMING_DISTRIBUTOR_CONDITION = "BECOMING_DISTRIBUTOR_CONDITION";
    public static final String PACKAGE_PRICE = "PACKAGE_PRICE";
    /**
     * 用户等级-分销商
     * 免免邮金额
     */
    public static final Integer USER_VIP_DISTRIBUTOR = 1;
    /**
     * 积分业务类型-获得
     */
    public static final Integer SCORE_BUSINESS_TYPE_GET = 1;
    /**
     * 积分业务类型-兑换
     */
    public static final Integer SCORE_BUSINESS_TYPE_EXCHANGE = 2;
    /**
     * 免费配送距离
     */
    public static final String DELIVERY_DISTANCE = "delivery_distance";
    /**
     * 支持学校列表
     */
    public static final String SCHOOL = "SCHOOL";
    /**
     * 省运费关系
     */
    public static final String IN_PROVINCE_PACKAGE_PRICE = "IN_PROVINCE_PACKAGE_PRICE";
    public static final String FIRST_OUT_PROVINCE_PACKAGE_PRICE = "FIRST_OUT_PROVINCE_PACKAGE_PRICE";
    public static final String SECOND_OUT_PROVINCE_PACKAGE_PRICE = "SECOND_OUT_PROVINCE_PACKAGE_PRICE";
    public static final String IN_PROVINCE_PACKAGE_LIST = "IN_PROVINCE_PACKAGE_LIST";
    public static final String FIRST_PROVINCE_PACKAGE_LIST = "FIRST_PROVINCE_PACKAGE_LIST";
    public static final String SECOND_PROVINCE_PACKAGE_LIST = "SECOND_PROVINCE_PACKAGE_LIST";
    /**
     * 起送费
     */
    public static final String QSFY = "QSFY";
    public static final String FREE_PACKAGE_PRICE = "FREE_PACKAGE_PRICE";
    /**
zq-erp/src/main/java/com/matrix/system/common/interceptor/HostInterceptor.java
@@ -1,13 +1,9 @@
package com.matrix.system.common.interceptor;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysCompany;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@@ -45,17 +41,8 @@
            LogUtil.debug("匹配到公司{}", company.getComName());
            return true;
        } else {
        // 获得请求的域名
        String host = WebUtil.getRequest().getServerName();
        //判断是否为debug模式
        if(MatrixConstance.DEBUG){
            String debugHost=request.getHeader("debugHost");
            if(StringUtils.isNotBlank(debugHost)){
                host=debugHost;
                WebUtil.getSession().removeAttribute(ATTR_COMPANY);
                LogUtil.debug("debugHost={}",host);
            }
        }
        // 获得请求的域名--由小程序直接传过来companyCode参数对应公司的网址
        String host = request.getHeader("companyCode");
        LogUtil.debug("当前请求域名{}", host);
            @SuppressWarnings("unchecked")
            Map<String, SysCompany> companyMap = (Map<String, SysCompany>) WebUtil.getServletContext()
zq-erp/src/main/java/com/matrix/system/common/service/impl/InitShopProductCateService.java
@@ -2,9 +2,6 @@
import com.matrix.core.constance.MatrixConstance;
import com.matrix.system.common.bean.SysCompany;
import com.matrix.system.common.bean.SysRole;
import com.matrix.system.common.dao.SysRoleDao;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.shopXcx.bean.ShopProductAttribute;
import com.matrix.system.shopXcx.dao.ShopProductAttributeDao;
import org.springframework.beans.BeanUtils;
@@ -40,7 +37,8 @@
        ShopProductAttribute service=new ShopProductAttribute();
        BeanUtils.copyProperties(cpfl,service);
        service.setAttrName("服务");
        service.setAttrName("属性");
        service.setAttrCode("service");
        shopProductAttributeDao.batchInsert(Arrays.asList(cpfl,service));
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysOrderServiceImpl.java
@@ -681,6 +681,14 @@
            return true;
        } else {
            // 不是一卡通,
            // 判断卡是否可应用于所有产品
            ShoppingGoods cardGoods = shoppingGoodsDao.selectById(moneyCardUse.getGoodsId());
            if (cardGoods != null) {
                if (Dictionary.FLAG_YES.equals(cardGoods.getCarIsAll())) {
                    return true;
                }
            }
            // 比较分类
            MoneyCardAssemble moneyCardAssemble = new MoneyCardAssemble();
            moneyCardAssemble.setCardId(moneyCardUse.getGoodsId());
zq-erp/src/main/java/com/matrix/system/hive/service/imp/SysProjServicesServiceImpl.java
@@ -299,12 +299,9 @@
     */
    @Override
    public VerifyResult checkArrears(SysProjServices sysProjServices) {
        //检测欠款
       /* for (SysBeauticianState sysBeauticianState : sysProjServices.getServiceItems()) {
        // 检测欠款
       for (SysBeauticianState sysBeauticianState : sysProjServices.getServiceItems()) {
            SysProjUse sysProjUse = projUseService.findById(sysBeauticianState.getPuseId());
            ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(sysProjUse.getProjId());
            SysOrderItem orderItem = sysOrderItemService.findById(sysProjUse.getOrderItemId());
@@ -333,7 +330,7 @@
                    return new VerifyResult(true, shoppingGoods.getName() + "存在欠款" + orderItem.getArrears() + "元 , 不能消费赠送项目,订单编号[ " + sysOrderService.findById(orderItem.getOrderId()).getOrderNo() + " ] ");
                }
            }
        }*/
        }
        return new VerifyResult(false);
    }
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java
@@ -103,6 +103,7 @@
    public @ResponseBody
    AjaxResult modifyShopAdvertisType(@RequestBody ShopAdvertisType newShopAdvertisType) {
        SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
        if (StringUtils.isNotBlank(newShopAdvertisType.getNodeStyle())) {
            String style = newShopAdvertisType.getNodeStyle();
            style = style.replaceAll("px", "rpx")
@@ -116,7 +117,7 @@
            newShopAdvertisType.setCreateBy(user.getSuName());
            newShopAdvertisType.setUpdateBy(user.getSuName());
            newShopAdvertisType.setCompanyId(user.getCompanyId());
            shopAdvertisTypeDao.insert(newShopAdvertisType);
        } else {
            shopAdvertisTypeDao.updateByModel(newShopAdvertisType);
@@ -135,6 +136,7 @@
            collect.forEach(ad -> {
                ad.setCreateBy(user.getSuName());
                ad.setUpdateBy(user.getSuName());
                ad.setCompanyId(user.getCompanyId());
                ad.setTypeId(newShopAdvertisType.getAdtId());
            });
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java
@@ -14,7 +14,6 @@
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.shopXcx.bean.ShopCoupon;
import com.matrix.system.shopXcx.bean.ShopProduct;
import com.matrix.system.shopXcx.dao.ShopCouponDao;
@@ -269,6 +268,7 @@
     * @param shopCoupon
     */
    private void productLabeling(ShopCoupon shopCoupon) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        Date now = new Date();
        Boolean needUpdate = false;
        //优惠券处于可用状态
@@ -279,6 +279,7 @@
            if (shopCoupon.getIsAll() == 1) {
                ShopProduct productQuery = new ShopProduct();
                productQuery.setDelFlag(2);
                productQuery.setCompanyId(user.getCompanyId());
                shopProductList = shopProductDao.selectByModel(productQuery);
            } else {
                if (StringUtils.isNotBlank(shopCoupon.getProductIds())) {
zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java
@@ -1,30 +1,29 @@
package com.matrix.system.shopXcx.action;
import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.constance.SystemMessageCode;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.ModelUtils;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.web.BaseAction;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.core.anotations.RemoveRequestToken;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.tools.ServiceUtil;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.shopXcx.bean.ShopPage;
import com.matrix.system.shopXcx.dao.ShopPageDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import com.matrix.core.exception.GlobleException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.matrix.core.anotations.SaveRequestToken;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
import java.util.List;
import java.util.Map;
import com.matrix.system.shopXcx.bean.ShopPage;
import org.springframework.web.servlet.ModelAndView;
/**
 * @description 小程序页面
@@ -77,10 +76,11 @@
    @RemoveRequestToken    
       @RequestMapping(value =  "/addShopPage")
    public @ResponseBody AjaxResult addShopPage(ShopPage shopPage) {
        if (serviceUtil.addCheckRepeat("shop_page", "code", shopPage.getCode())) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        if (serviceUtil.addCheckRepeatTowColumn("shop_page", "code", shopPage.getCode(),"company_id", user.getCompanyId())) {
            throw new GlobleException("code重复");
        }
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        shopPage.setCreateBy(user.getSuName());
        shopPage.setUpdateBy(user.getSuName());
        shopPage.setCompanyId(user.getCompanyId());
@@ -103,9 +103,10 @@
       @RequestMapping(value =  "/modifyShopPage")
    public @ResponseBody AjaxResult modifyShopPage(ShopPage newShopPage) {
           ShopPage oldShopPage = WebUtil.getSessionAttribute(BEV);
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        // 校验去重
        if (serviceUtil.updateCheckRepeat("shop_page",
        if (serviceUtil.updateCheckRepeatTowColumn("shop_page",
                "company_id", user.getCompanyId(),
                "code", newShopPage.getCode(),
                "id",newShopPage.getId())) {
            throw new GlobleException("编号" + newShopPage.getCode() + "重复");
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WeChatApiTools.java
@@ -1,23 +1,25 @@
package com.matrix.system.shopXcx.api;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.component.tools.HttpRequest;
import com.matrix.component.tools.HttpResponse;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
@Service
public class WeChatApiTools {
    /**
     * 小程序秘钥
     */
    private static final String XCX_SECRET = "xcx_secret";
    /**
     * 小程序appid
     */
    private static final String XCX_APPID = "xcx_appid";
    @Autowired
    private BusParameterSettingsDao busParameterSettingsDao;
    /**
     * 微信登录url
     */
@@ -33,8 +35,6 @@
     */
    private static String accessToken = "";
    private static String appid = "";
    private static String secret = "";
    /**
@@ -46,31 +46,27 @@
     * @param code
     * @return
     */
    public static String getXcxLoginUrl(String code) {
    public  String getXcxLoginUrl(String code,Long companyId) {
        String wechatLoginUrl = PropertiesUtil.getString(WECHAT_LOGIN_URL);
        return String.format(wechatLoginUrl, getAppid(), getSecret(), code);
        return String.format(wechatLoginUrl, getAppid(companyId), getSecret(companyId), code);
    }
    /**
     * 获取小程序APPId
     * @return
     */
    public static String  getAppid(){
        if(StringUtils.isBlank(appid)){
            appid = PropertiesUtil.getString(XCX_APPID);
        }
        return  appid;
    public  String  getAppid(Long companyId){
        BusParameterSettings appId = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_APPID, companyId);
        return  appId.getParamValue();
    }
    /**
     * 获取小程序秘钥
     * @return
     */
    public static String  getSecret(){
        if(StringUtils.isBlank(secret)){
            secret = PropertiesUtil.getString(XCX_SECRET);
        }
        return  secret;
    public  String  getSecret(Long companyId){
        BusParameterSettings secret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.MINIPROGRAM_SECRET, companyId);
        return  secret.getParamValue();
    }
@@ -83,7 +79,7 @@
        accessToken = "";
    }
    public static String getAccessToken() throws IOException {
    public  String getAccessToken(Long companyId) throws IOException {
        if (isTokenInvalid()) {
            synchronized (accessToken) {
@@ -93,7 +89,7 @@
                    HttpResponse result = null;
                    result = reqObj
                            .sendHttpGet("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
                                    + getAppid() + "&secret=" + getSecret(), null);
                                    + getAppid(companyId) + "&secret=" + getSecret(companyId), null);
                    JSONObject json = JSONObject.fromObject(result.getDataString());
                    String access_token = json.getString("access_token");
                    accessToken = access_token;
zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java
@@ -1,6 +1,5 @@
package com.matrix.system.shopXcx.api;
import com.alibaba.fastjson.JSON;
import com.matrix.biz.bean.BizUser;
import com.matrix.biz.dao.BizUserDao;
import com.matrix.biz.service.BizUserService;
@@ -12,6 +11,7 @@
import com.matrix.core.tools.StringUtils;
import com.matrix.core.web.BaseAction;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.interceptor.HostInterceptor;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -42,7 +42,8 @@
    @Autowired
    private BizUserDao bizUserDao;
    @Autowired
    WeChatApiTools weChatApiTools;
@@ -68,7 +69,7 @@
        AjaxResult res = new AjaxResult();
        LogUtil.info("code:{}" + code);
        if (StringUtils.isNotBlank(code)) {
            String requrl = WeChatApiTools.getXcxLoginUrl(code);
            String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId());
            String reslutData = HttpCurlUtil.sendGetHttp(requrl, null);
            JSONObject json = JSONObject.fromObject(reslutData);
            LogUtil.debug("微信登录获取到登录信息={}", json);
@@ -94,6 +95,7 @@
                    bizUser.setOpenId(openId);
                    bizUser.setLastLoginTime(new Date());
                    bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER);
                    bizUser.setCompanyId(HostInterceptor.getCompanyId());
                    bizUserService.add(bizUser);
                } else {
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java
@@ -10,7 +10,6 @@
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.ShoppingGoods;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
@@ -117,7 +116,7 @@
            }
        }
        //获取当前购物车产品可用的优惠券
        List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(addShopOrderPOJO.getShopId(),notCouponuyCart);
        List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(bizUser.getCompanyId(),notCouponuyCart);
        //获取用户使用的优惠券
        CouponReceiveInfoVO shopCoupon = new CouponReceiveInfoVO();
@@ -151,13 +150,9 @@
        }
        Integer addrId = null;
        if (shopReceiveAddress != null) {
            addrId = shopReceiveAddress.getAddrId();
        }
        //得到订单计价说明
        DiscountExplain discountExplain = shopOrderService.buildDiscountExplain(cartList, shopCoupon.getReceiveId(), addrId);
        DiscountExplain discountExplain = shopOrderService.buildDiscountExplain(cartList, shopCoupon.getReceiveId(), bizUser.getCompanyId());
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, buyCart, buyCart.size());
        //结算金额信息
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java
@@ -1,16 +1,14 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.biz.dao.BizUserDao;
import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.component.wechat.externalInterface.common.Signature;
import com.matrix.component.wechat.externalInterface.common.Util;
import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
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.common.interceptor.HostInterceptor;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin;
@@ -22,6 +20,7 @@
import com.matrix.system.shopXcx.dao.ShopOrderDao;
import com.matrix.system.shopXcx.dao.ShopPayLogDao;
import com.matrix.system.shopXcx.mqTask.MQTaskRouting;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
@@ -29,12 +28,10 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xml.sax.SAXException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -110,16 +107,25 @@
                notityXml.append(inputLine);
            }
            request.getReader().close();
            // XMl转对象
            NotifyData data = (NotifyData) Util.getObjectFromXML(notityXml.toString(), NotifyData.class);
            LogUtil.info(data.toString());
            LogUtil.info("notityXml ---- :{} ", notityXml);
            // XMl转对象
            Object bb = Util.getObjectFromXML(notityXml.toString(), NotifyData.class);
            NotifyData    data = new NotifyData();
            BeanUtils.copyProperties(bb,data);
            LogUtil.info("----return_code = {}", data.getReturn_code());
            // 返回状态码 SUCCESS/FAIL
            if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) {
                orderId = data.getAttach();
                // 检验订单状态
                ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId));
                // 校验签名
                BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, HostInterceptor.getCompanyId());
                BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, order.getCompanyId());
                if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) {
                    // 校验业务结果
                    if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) {
@@ -129,14 +135,13 @@
                        Double total_fee = Double.parseDouble(data.getTotal_fee());
                        // 商户订单号
                        String payNum = data.getOut_trade_no();
                        orderId = data.getAttach();
                        LogUtil.info("支付回调关键信息---total_fee:{},payNum:{},orderId:{}", total_fee, payNum, orderId);
                        // 订单ID
                        BigDecimal payMoney = new BigDecimal(total_fee).divide(new BigDecimal(100), 2,
                                RoundingMode.HALF_UP);
                        // 检验订单状态
                        ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId));
                        if (order != null && ShopOrder.ORDER_PAY_STATUS_WAIT == order.getPayStatus()) {
                            ShopPayLog payLog = new ShopPayLog();
                            // TODO 校验支付金额
@@ -219,7 +224,7 @@
                threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:003)");
                resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "通信标识失败");
            }
        } catch (ParserConfigurationException | IOException | SAXException e) {
        } catch (Exception e) {
            LogUtil.error("支付回调签名错误", e);
            threadResult.putInMap("status", "err");
            threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:004)");
@@ -271,4 +276,6 @@
        return null;
    }
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java
@@ -1,24 +1,22 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.component.tools.WxUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.biz.bean.BizUser;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.bean.CustomerDataDictionary;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService;
import com.matrix.system.shopXcx.api.tools.SMSTools;
import com.matrix.system.shopXcx.bean.ShopDeliveryInfo;
import com.matrix.system.shopXcx.bean.ShopOrder;
import com.matrix.system.shopXcx.bean.ShopRefundRecord;
import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao;
import com.matrix.system.shopXcx.dao.ShopOrderDao;
import com.matrix.system.shopXcx.dao.ShopRefundRecordDao;
import com.matrix.component.tools.WxUtils;
import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService;
import com.matrix.system.shopXcx.api.tools.SMSTools;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -175,25 +173,6 @@
            modifyMap.put("id", orderId);
            modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_APPLY_MONEYBACK);
            shopOrderDao.updateByMap(modifyMap);
            //从数据字典获取需要发送的手机号码和短信提醒内容
            BusParameterSettings busParameterSetting1 =busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_CONTENT_REFUND",17L);
            String msg = busParameterSetting1.getParamValue();
            //TODO 写死微商城17L公司id
            BusParameterSettings busParameterSetting= busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_MOBILE",17L);
            String phons = busParameterSetting.getParamValue();
            phons.replace(',',',');
            List<String> result = Arrays.asList(phons.split(","));
            if(CollectionUtils.isNotEmpty(result)){
                for(String phon : result){
                    smsTools.sendMsg(phon, msg + "退订回T" );
                }
            }
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功");
        }
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java
@@ -9,7 +9,9 @@
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.PropertiesUtil;
import com.matrix.core.tools.UUIDUtil;
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.dao.SysShopInfoDao;
import com.matrix.system.hive.plugin.util.CollectionUtils;
import com.matrix.system.shopXcx.api.pojo.QrcodeImgParam;
@@ -81,6 +83,9 @@
    @Autowired
    ShopActivitiesSeckillInfoDao shopActivitiesSeckillInfoDao;
    @Autowired
    BusParameterSettingsDao busParameterSettingsDao;
    /**
     * 生成二维码
     */
@@ -137,7 +142,7 @@
                qrcodeImgParam = getQrcodeImgParam(loginUser, qrcodeVo);
                shareQrcord.setProductId(qrcodeVo.getProductId());
            }
            qrcodeImgParam.logo="";
            //绘制二维码
            drawQrcode(qrcodeImgParam);
@@ -186,8 +191,8 @@
        qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg;
        qrcodeImgParam.title = "【秒杀】" + shopProduct.getTitle();
        qrcodeImgParam.price = "¥" +seckillInfo.getSiPrice();
        qrcodeImgParam.logo = "深圳肽妍";
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品";
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验";
        return qrcodeImgParam;
    }
@@ -224,8 +229,8 @@
        qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg;
        qrcodeImgParam.title = "【拼团】" + shopProduct.getTitle();
        qrcodeImgParam.price = "¥" + price.getGpPrice();
        qrcodeImgParam.logo = "深圳肽妍";
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品";
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验";
        return qrcodeImgParam;
    }
@@ -233,6 +238,8 @@
    private QrcodeImgParam getQrcodeImgParam(BizUser loginUser, QrcodeVo qrcodeVo) throws Exception {
        ShopProduct shopProduct = shopProductDao.selectById(qrcodeVo.getProductId());
        String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID());
@@ -255,9 +262,9 @@
        qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg;
        qrcodeImgParam.title = shopProduct.getTitle();
        qrcodeImgParam.price = "¥" + shopProduct.getPrice().toString();
        qrcodeImgParam.logo = "深圳肽妍";
        ShopCoupon shopCoupon = shopProduct.getShopCoupon();
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品";
        qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验";
        if (shopCoupon != null) {
            String beginTiem = DateUtil.dateFormatStr(shopCoupon.getBeginTime(), DateUtil.DATE_FORMAT_SPLITE_DD);
            String endTiem = DateUtil.dateFormatStr(shopCoupon.getEndTime(), DateUtil.DATE_FORMAT_SPLITE_DD);
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java
@@ -4,7 +4,6 @@
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.hive.dao.SysVipInfoDao;
import com.matrix.system.shopXcx.api.service.WXShopOrderService;
import com.matrix.system.shopXcx.api.service.WxShopActivitiesGroupService;
import com.matrix.system.shopXcx.api.vo.WxActivitiesGroupBuyVO;
@@ -17,8 +16,6 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
@@ -201,6 +198,7 @@
    @PostMapping(value = "/calPrice")
    public AjaxResult calPrice(@RequestBody CreateGroupBuyDTO createGroupBuyDTO) {
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopActivitiesGroupPrice groupPrice = shopActivitiesGroupPriceDao.selectById(createGroupBuyDTO.getGpId());
        // 判断参数中gjId是否为空,若为空则为团长开团。再判断团长价是否为空,如果不为空则拥有团长价
        if (createGroupBuyDTO.getGjId() == null) {
@@ -212,7 +210,7 @@
        } else {
            createGroupBuyDTO.setPrice(groupPrice.getGpPrice());
        }
        BigDecimal postage = wxShopOrderService.calculationPostage(createGroupBuyDTO.getAddressId(), createGroupBuyDTO.getPrice());
        BigDecimal postage = wxShopOrderService.calculationPostage(createGroupBuyDTO.getPrice(),bizUser.getCompanyId());
        BigDecimal payPrice = createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount())).add(postage);
        AjaxResult ajaxResult = new AjaxResult(AjaxResult.STATUS_SUCCESS, null);
        ajaxResult.putInMap("billPrice", createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount())));
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java
@@ -1,5 +1,7 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.biz.bean.BizUser;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.system.shopXcx.api.service.WXShopOrderService;
import com.matrix.system.shopXcx.api.service.WxShopActivitiesSecKillService;
@@ -37,7 +39,10 @@
    @Autowired
    private WXShopOrderService wxShopOrderService;
    @Autowired
    private WxShopActivitiesSecKillService wxShopActivitiesSecKillService;
    private WxShopActivitiesSecKillService wxShopActvitiesSecKillService;
    @Autowired
    private RedisUserLoginUtils redisUserLoginUtils;
    /**
@@ -106,12 +111,13 @@
     */
    @PostMapping(value = "/calSecKillPrice")
    public AjaxResult calSecKillPrice(@RequestBody SecKillVO secKillVO) {
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopActivitiesSeckillInfo seckillInfo = shopActivitiesSeckillInfoDao.selectById(secKillVO.getId());
        if (seckillInfo == null) {
            return AjaxResult.buildFailInstance("参数有误");
        }
        BigDecimal postage = wxShopOrderService.calculationPostage(secKillVO.getAddressId(), seckillInfo.getSiPrice());
        BigDecimal postage = wxShopOrderService.calculationPostage(seckillInfo.getSiPrice(),bizUser.getCompanyId());
        BigDecimal payPrice = seckillInfo.getSiPrice().multiply(BigDecimal.valueOf(secKillVO.getCount())).add(postage);
        AjaxResult ajaxResult = new AjaxResult(AjaxResult.STATUS_SUCCESS, null);
        ajaxResult.putInMap("totalPrice", payPrice);
@@ -128,6 +134,6 @@
     */
    @PostMapping(value = "/createSecKill")
    public AjaxResult createSecKill(@RequestBody CreateSecKillDTO secKillDTO) throws Exception {
        return wxShopActivitiesSecKillService.createSecKillOrder(secKillDTO);
        return wxShopActvitiesSecKillService.createSecKillOrder(secKillDTO);
    }
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java
@@ -1,11 +1,11 @@
package com.matrix.system.shopXcx.api.action;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.shopXcx.dao.ShopCouponDao;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import com.matrix.system.shopXcx.dao.ShopCouponDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@@ -58,11 +58,11 @@
     *
     * @return
     */
    @RequestMapping(value = "getMyCouponInfoByStatus/{shopId}/{status}")
    @RequestMapping(value = "getMyCouponInfoByStatus/{status}")
    @ResponseBody
    public AjaxResult getMyCouponInfo(@PathVariable("shopId") Long shopId,@PathVariable("status") Integer status, @RequestBody PaginationVO pageVo) {
    public AjaxResult getMyCouponInfo(@PathVariable("status") Integer status, @RequestBody PaginationVO pageVo) {
        return shopCouponService.getMyCouponInfoByStatus(shopId,status, pageVo);
        return shopCouponService.getMyCouponInfoByStatus(HostInterceptor.getCompanyId(),status, pageVo);
    }
    /**
@@ -76,10 +76,10 @@
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, shopCouponService.getCouponListByProductId(productId));
    }
    @GetMapping(value = "getCouponListByTag/{shopId}/{tag}")
    @GetMapping(value = "getCouponListByTag/{tag}")
    @ResponseBody
    public AjaxResult getCouponListByTag(@PathVariable("tag") String tag,@PathVariable("shopId") Long shopId) {
        return shopCouponService.getCouponListByTag(tag,shopId);
    public AjaxResult getCouponListByTag(@PathVariable("tag") String tag) {
        return shopCouponService.getCouponListByTag(tag, HostInterceptor.getCompanyId());
    }
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java
@@ -1,19 +1,14 @@
package com.matrix.system.shopXcx.api.service;
import com.matrix.core.tools.LogUtil;
import com.matrix.biz.bean.BizUser;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.bean.CustomerDataDictionary;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.core.tools.LogUtil;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.shopXcx.api.vo.ShopCartBillVo;
import com.matrix.system.shopXcx.api.vo.ShopCartVo;
import com.matrix.system.shopXcx.bean.ShopCoupon;
import com.matrix.system.shopXcx.bean.ShopShoppingCart;
import com.matrix.system.shopXcx.dao.ShopShoppingCartDao;
import com.matrix.system.shopXcx.api.vo.ShopCartBillVo;
import com.matrix.system.shopXcx.api.vo.ShopCartVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -108,13 +103,9 @@
        // 1表示没有优惠的默认分组
        ShopCartVo def = new ShopCartVo();
        /**
         * 同城配送标题
         * //DataDictionary qsfy = dataDictionaryDao.selectByTypeCode(AppConstance.QSFY);
         * //def.setMsg("2公里内满" + qsfy.getValue() + "元免配送费");
         */
        def.setMsg("肽研官方商城");
        def.setMsg("商城");
        def.setCartList(new ArrayList<>());
        // 组合默认分组
        cartList.add(def);
@@ -316,15 +307,9 @@
                }
            }
        } else {
            BusParameterSettings qsfy= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L);
            shopCartVo.setSubtotal(selectSum);
            shopCartVo.setSrcPrice(selectSum);
            if (selectSum.compareTo(new BigDecimal(qsfy.getParamValue())) < 0) {
                shopCartVo.setSatisfactionCoupon(false);
            } else {
                shopCartVo.setSubtotal(selectSum);
                shopCartVo.setSrcPrice(selectSum);
                shopCartVo.setSatisfactionCoupon(true);
            }
        }
    }
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java
@@ -18,7 +18,7 @@
    BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice);
    BigDecimal calculationPostage(BigDecimal payPrice,Long companyId);
    /**
     * 创建订单
@@ -93,5 +93,5 @@
     */
    AjaxResult updateStockAndVolumeById(Integer orderId);
    DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Integer addrId);
    DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Long companyId);
}
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java
@@ -18,7 +18,7 @@
     * 根据购物车选中的产品
     * @return
     */
    public List<CouponReceiveInfoVO> getCartVoCouponList(Long shopId,List<ShopShoppingCart> shopShoppingCarts);
    public List<CouponReceiveInfoVO> getCartVoCouponList(Long companyId,List<ShopShoppingCart> shopShoppingCarts);
    /**
@@ -42,12 +42,12 @@
     * 根据状态获取我的优惠券
     * 
     *
     * @param shopId
     * @param companyId
     * @param status
     * @param pageVo
     * @return
     */
    AjaxResult getMyCouponInfoByStatus(Long shopId, Integer status, PaginationVO pageVo);
    AjaxResult getMyCouponInfoByStatus(Long companyId, Integer status, PaginationVO pageVo);
    /**
     * 根据产品ID获取优惠券列表
@@ -62,10 +62,10 @@
     * 根据标签获取优惠券列表
     *
     * @param tag
     * @param shopId
     * @param companyId
     * @return
     */
    AjaxResult getCouponListByTag(String tag, Long shopId);
    AjaxResult getCouponListByTag(String tag, Long companyId);
    /**
     * 根据产品id查询该产品符合的优惠活动
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java
@@ -3,10 +3,6 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.matrix.biz.bean.BizUser;
import com.matrix.system.common.bean.BusParameterSettings;
import com.matrix.system.common.bean.CustomerDataDictionary;
import com.matrix.system.common.dao.BusParameterSettingsDao;
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
import com.matrix.component.rabbitmq.RabiitMqTemplate;
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.component.tools.WxUtils;
@@ -16,7 +12,10 @@
import com.matrix.core.pojo.AjaxResult;
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.common.dao.CustomerDataDictionaryDao;
import com.matrix.system.common.interceptor.HostInterceptor;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.bean.ShoppingGoods;
@@ -99,52 +98,20 @@
    private BusParameterSettingsDao busParameterSettingsDao;
    @Override
    public BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice) {
    public BigDecimal calculationPostage(BigDecimal payPrice,Long companyId) {
        BigDecimal postage = BigDecimal.ZERO;
        if (addressId != null) {
            ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(addressId);
            BusParameterSettings sn= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L);
            BusParameterSettings pydq= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SECOND_PROVINCE_PACKAGE_LIST,17L);
            if (sn.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) {
                //省内邮费计算
                postage = getPostageByDataBictionary(AppConstance.IN_PROVINCE_PACKAGE_PRICE, payPrice);
            } else if (pydq.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) {
                //偏远地区
                postage = getPostageByDataBictionary(AppConstance.SECOND_OUT_PROVINCE_PACKAGE_PRICE, payPrice);
            } else {
                //其他地区
                postage = getPostageByDataBictionary(AppConstance.FIRST_OUT_PROVINCE_PACKAGE_PRICE, payPrice);
        BusParameterSettings yf = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.PACKAGE_PRICE, companyId);
        BusParameterSettings myje = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.FREE_PACKAGE_PRICE, companyId);
        if(yf!=null&&myje!=null){
            if (Double.parseDouble(myje.getParamValue()) > payPrice.doubleValue()) {
                postage = new BigDecimal(yf.getParamValue());
            }
        }
        return postage;
    }
    //todo 根据数据字典计算运费  运费设置为0 后面再改配置在改计算规则
    private BigDecimal getPostageByDataBictionary(String code, BigDecimal payPrice) {
        /*CustomerDataDictionary dd = dataDictionaryDao.selectByTypeCode(code);
        BigDecimal postage = BigDecimal.ZERO;
        if (StringUtils.isNotBlank(dd.getValue())) {
            if (StringUtils.isNotBlank(dd.getExtValue())
                    && payPrice.compareTo(new BigDecimal(dd.getExtValue())) >= 0) {
                //达到条件免邮
                postage = BigDecimal.ZERO;
            } else {
                postage = new BigDecimal(dd.getValue());
            }
        }*/
        return BigDecimal.ZERO;
    }
    /**
@@ -190,13 +157,14 @@
        }
        //计算订单优惠信息
        DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), shopReceiveAddress.getAddrId());
        DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), bizUser.getCompanyId());
        ShopOrder shopOrder = new ShopOrder();
        shopOrder.setCompanyId(bizUser.getCompanyId());
        shopOrder.setStoreId(Integer.parseInt(addShopOrderPOJO.getShopId().toString()));
        shopOrder.setOrderType(ShopOrder.ORDER_TYPE_SERVICE);
        //默认设置为产品类型
        shopOrder.setOrderType(ShopOrder.ORDER_TYPE_GOODS);
        List<ShopOrderDetails> details = new ArrayList<>();
        Integer cartCount = 0;
@@ -308,7 +276,7 @@
    }
    @Override
    public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Integer receiveAddrId) {
    public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Long companyId) {
        ShopCartBillVo shopCartBill = shoppingCartService.buildShopCartBillVo(cartList);
        DiscountExplain discountExplain = new DiscountExplain();
        discountExplain.setActivity(shopCartBill.getBillCouponTotal());
@@ -325,7 +293,7 @@
            }
        }
        discountExplain.setPostage(calculationPostage(receiveAddrId, discountExplain.getPayPrice()));
        discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(),companyId));
        //计算实际支付
        discountExplain.setPayPrice(discountExplain.getPayPrice().add(discountExplain.getPostage()));
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java
@@ -8,7 +8,6 @@
import com.matrix.component.wechat.externalInterface.protocol.paramProtocol.BrandWCPayRequestData;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.constance.Dictionary;
@@ -318,8 +317,9 @@
        if (shopReceiveAddress == null) {
            throw new GlobleException("请选择正确的收获地址");
        }
        BizUser user=redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopOrder shopOrder = new ShopOrder();
        shopOrder.setCompanyId(user.getCompanyId());
        shopOrder.setStoreId(Integer.parseInt(createGroupBuyDTO.getShopId().toString()));
        shopOrder.setOrderType(ShopOrder.ORDER_TYPE_SERVICE);
@@ -389,7 +389,7 @@
        shopOrder.setPayResult(ShopOrder.ORDER_WX_STATUS_WAIT_PAY);
        //如果没有提交购买方式或配送方式不是物流
        //获取邮费
        BigDecimal postPrice = wxShopOrderService.calculationPostage(createGroupBuyDTO.getAddressId(), createGroupBuyDTO.getPrice());
        BigDecimal postPrice = wxShopOrderService.calculationPostage(createGroupBuyDTO.getPrice(),user.getCompanyId());
        shopOrder.setPostage(postPrice);
        BigDecimal payPrice = createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount())).add(shopOrder.getPostage());
        shopOrder.setOrderMoney(payPrice);
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java
@@ -126,6 +126,7 @@
    }
    private ShopOrder createOrder(CreateSecKillDTO secKillDTO) {
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(secKillDTO.getAddressId());
        if (shopReceiveAddress == null) {
            throw new GlobleException("请选择正确的收获地址");
@@ -177,6 +178,7 @@
        shopOrder.setUpdateBy("微信小程序生成");
        shopOrder.setCommodityPrice(secKillDTO.getPrice());
        shopOrder.setPurchaseQuantity(1);
        shopOrder.setCompanyId(bizUser.getCompanyId());
        //购买方式
        shopOrder.setShippingMethod(secKillDTO.getShippingMethod());
        //生成订单号
@@ -201,7 +203,7 @@
        shopOrder.setPayResult(ShopOrder.ORDER_WX_STATUS_WAIT_PAY);
        //如果没有提交购买方式或配送方式不是物流
        //获取邮费
        BigDecimal postPrice = wxShopOrderService.calculationPostage(secKillDTO.getAddressId(), secKillDTO.getPrice());
        BigDecimal postPrice = wxShopOrderService.calculationPostage(secKillDTO.getPrice(),bizUser.getCompanyId());
        shopOrder.setPostage(postPrice);
        BigDecimal payPrice = secKillDTO.getPrice().multiply(BigDecimal.valueOf(secKillDTO.getCount())).add(shopOrder.getPostage());
        shopOrder.setOrderMoney(payPrice);
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java
@@ -8,14 +8,8 @@
import com.matrix.component.redis.RedisUserLoginUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.shopXcx.bean.ShopCoupon;
import com.matrix.system.shopXcx.bean.ShopCouponRecord;
import com.matrix.system.shopXcx.bean.ShopProductAttrRef;
import com.matrix.system.shopXcx.bean.ShopShoppingCart;
import com.matrix.system.shopXcx.dao.ShopCouponDao;
import com.matrix.system.shopXcx.dao.ShopCouponRecordDao;
import com.matrix.system.shopXcx.dao.ShopProductAttrRefDao;
import com.matrix.system.shopXcx.dao.ShopReceiveAddressDao;
import com.matrix.system.shopXcx.bean.*;
import com.matrix.system.shopXcx.dao.*;
import com.matrix.system.shopXcx.api.service.WxShopCouponService;
import com.matrix.system.shopXcx.api.tools.WxShopCouponUtil;
import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil;
@@ -51,13 +45,16 @@
    @Autowired
    private WxShopCouponUtil wxShopCouponUtil;
    @Autowired
    private ShopProductDao productDao;
    /**
     * 根据购物车选中的产品,计算合适的优惠券
     *
     * @return
     */
    public List<CouponReceiveInfoVO> getCartVoCouponList(Long shopId,List<ShopShoppingCart> shopShoppingCarts) {
    public List<CouponReceiveInfoVO> getCartVoCouponList(Long companyId,List<ShopShoppingCart> shopShoppingCarts) {
        //可用优惠券列表
        List<CouponReceiveInfoVO> shopCoupons = new ArrayList<>();
@@ -65,7 +62,7 @@
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        //1.找到用户所有的优惠券
        List<CouponReceiveInfoVO> userAllCoupon = shopCouponRecordDao.selectMyCouponByStatus(shopId, bizUser.getOpenId(), AppConstance.MY_COUPON_NOT_USE,
        List<CouponReceiveInfoVO> userAllCoupon = shopCouponRecordDao.selectMyCouponByStatus(companyId, bizUser.getOpenId(), AppConstance.MY_COUPON_NOT_USE,
                null);
        if (CollectionUtils.isNotEmpty(userAllCoupon)) {
            //根据优惠力度排序,优惠力度大的先参与计算
@@ -215,20 +212,20 @@
     * 根据订单状态查询优惠券列表
     *
     *
     * @param shopId
     * @param companyId
     * @param status 1=已使用;2=未使用;3=过期
     * @return
     */
    @Override
    public AjaxResult getMyCouponInfoByStatus(Long shopId, Integer status, PaginationVO pageVo) {
    public AjaxResult getMyCouponInfoByStatus(Long companyId, Integer status, PaginationVO pageVo) {
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        // 如果查询使用或未使用状态的优惠券列表
        if (AppConstance.MY_COUPON_USE.equals(status) || AppConstance.MY_COUPON_NOT_USE.equals(status)) {
            List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyCouponByStatus(shopId,bizUser.getOpenId(), status,
            List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyCouponByStatus(companyId,bizUser.getOpenId(), status,
                    pageVo);
            return new AjaxResult(AjaxResult.STATUS_SUCCESS, list);
        }
        List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyPastCoupon(shopId,bizUser.getOpenId(), pageVo);
        List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyPastCoupon(companyId,bizUser.getOpenId(), pageVo);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, list);
    }
@@ -290,7 +287,8 @@
                attrIds.addAll(ids);
            }
        }
        List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds);
        ShopProduct shopProduct = productDao.selectById(productId);
        List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds,shopProduct.getCompanyId());
        return list;
    }
@@ -305,10 +303,10 @@
     * @return
     */
    @Override
    public AjaxResult getCouponListByTag(String tag, Long shopId) {
    public AjaxResult getCouponListByTag(String tag, Long companyId) {
        BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class);
        boolean newPeople = wxShopCouponUtil.verifyIsNewPeople(bizUser.getOpenId());
        List<ShopCoupon> couponList = shopCouponDao.selectCouponListByTag(newPeople, bizUser.getOpenId(), tag,shopId);
        List<ShopCoupon> couponList = shopCouponDao.selectCouponListByTag(newPeople, bizUser.getOpenId(), tag,companyId);
        AjaxResult res = new AjaxResult(AjaxResult.STATUS_SUCCESS, couponList);
        res.putInMap("isNewPeople", newPeople);
        return res;
zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java
@@ -1,20 +1,18 @@
package com.matrix.system.shopXcx.api.service.impl;
import com.alibaba.fastjson.JSON;
import com.matrix.core.constance.SystemErrorCode;
import com.matrix.component.tools.HttpCurlUtil;
import com.matrix.core.exception.GlobleException;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.tools.LogUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService;
import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo;
import com.matrix.system.shopXcx.bean.ShopDeliveryInfo;
import com.matrix.system.shopXcx.bean.ShopLogisticsInfo;
import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao;
import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao;
import com.matrix.component.tools.HttpCurlUtil;
import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService;
import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo;
import com.matrix.system.shopXcx.api.vo.SfLogisticsInfoVo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -145,12 +143,11 @@
                    }
                }
            } else {
                throw new GlobleException(SystemErrorCode.REQUEST_INVALID, logisticsInfoVo.getReason());
                throw new GlobleException(logisticsInfoVo.getReason());
            }
        } catch (Exception e) {
            LogUtil.error("物流信息查询失败", e);
            throw new GlobleException(SystemErrorCode.REQUEST_INVALID);
            throw new GlobleException("物流信息查询失败");
        }
        List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId());
        result.setStatus(AjaxResult.STATUS_SUCCESS);
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java
@@ -45,7 +45,7 @@
                                        @Param("productId") Integer productId, @Param("attrIds") List<String> attrIds);
    List<ShopCoupon> selectCouponListByTag(@Param("isNewPeople") boolean isNewPeople, @Param("userId") String userId,
                                           @Param("tag") String tag,@Param("shopId") Long shopId);
                                           @Param("tag") String tag,@Param("companyId") Long companyId);
    public int updateStateByStateAndIds(@Param("list") List<String> list, @Param("state") int state);
@@ -55,7 +55,7 @@
    ShopCoupon selectByIdAndUserId(@Param("id") Integer id, @Param("userId") String userId);
    public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds);
    public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds, @Param("companyId")Long companyId);
    ShopCoupon getCouponByTitle(@Param("title")String title, @Param("companyId")Long companyId);
}
zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java
@@ -43,9 +43,9 @@
    CouponReceiveInfoVO selectMyCouponByReceiveId(@Param("receiveId") Integer receiveId);
    List<CouponReceiveInfoVO> selectMyCouponByStatus(@Param("shopId") Long shopId, @Param("userId") String userId, @Param("status") Integer status,
    List<CouponReceiveInfoVO> selectMyCouponByStatus(@Param("companyId") Long shopId, @Param("userId") String userId, @Param("status") Integer status,
                                                     @Param("pageVo") PaginationVO pageVo);
    List<CouponReceiveInfoVO> selectMyPastCoupon(@Param("shopId")Long shopId, @Param("userId") String userId, @Param("pageVo") PaginationVO pageVo);
    List<CouponReceiveInfoVO> selectMyPastCoupon(@Param("companyId")Long shopId, @Param("userId") String userId, @Param("pageVo") PaginationVO pageVo);
}
zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java
@@ -80,135 +80,146 @@
    @Transactional(rollbackFor = Exception.class)
    public void createOrder(ShopOrder orderDto) {
        BizUser bizUser = bizUserService.findByOpenId(orderDto.getUserId());
        SysOrder order = new SysOrder();
        SysVipInfo vipInfo = vipDao.selectByPhone(bizUser.getPhoneNumber());
        if(SysVipInfo.UNDEAL_VIP==vipInfo.getIsDeal()){
            //非成交客户下单更新客户为成交客户
            vipInfo.setIsDeal(SysVipInfo.DEAL_VIP);
            vipDao.update(vipInfo);
        }
        //获取订单归属门店
        order.setCompanyId(vipInfo.getCompanyId());
        order.setShopId(Long.parseLong(orderDto.getStoreId()+""));
        //同步的订单订单编号保持一致
        order.setOrderNo(orderDto.getOrderNo());
        order.setVipId(vipInfo.getId());
        order.setOrderTime(new Date());
        order.setRemark(AppConstance.WX_ORDER_FLAG);
        order.setStaffId(vipInfo.getStaffId());
        order.setIsCross(2 + "");
        order.setStatu(Dictionary.ORDER_STATU_YFK);
        order.setCardPay(0.00);
        order.setCashPay(orderDto.getOrderMoney().doubleValue());
        order.setTotal(orderDto.getOrderMoney().doubleValue());
        order.setZkTotal(orderDto.getOrderMoney().doubleValue());
        order.setPayTime(new Date());
        order.setArrears(0D);
        int i = sysOrderDao.insert(order);
        // 创建订单明细,并计算总价与折扣总价
        // 总价
        double total = 0;
        double zkTotal = 0;
        int count = 0;
        // 设置订单条目
        //判断是否存在需要同步的产品,只有绑定了erp中产品的才同步
        boolean needTb=false;
        for (ShopOrderDetails orderItemDto : orderDto.getDetails()) {
            ShopSku shopSku = shopSkuDao.selectById(orderItemDto.getsId());
            if (StringUtils.isBlank(shopSku.getStockCode())) {
                LogUtil.warn("销售产品未绑定erp中的产品,无法进行同步");
            }
            String goodsCode =shopSku.getStockCode();
            ShoppingGoods shoppingGoods = shoppingGoodsService.findById(Long.parseLong(goodsCode));
            if (shoppingGoods == null) {
                LogUtil.warn("无效的商品id{}", shopSku.getAtrid());
            }
            SysOrderItem orderItem = new SysOrderItem();
            orderItem.setOrderId(order.getId());
            orderItem.setCount(orderItemDto.getCount());
            orderItem.setIsFree(orderItemDto.getPrice().doubleValue() > 0 ? "否" : "是");
            orderItem.setType(shoppingGoods.getGoodType());
            orderItem.setStatus(Dictionary.ORDER_STATU_YFK);
            orderItem.setPrice(orderItemDto.getPrice().doubleValue());
            orderItem.setZkPrice(orderItemDto.getPrice().doubleValue());
            orderItem.setGoodsId(shoppingGoods.getId());
            // 设置对应产品的id
            switch (shoppingGoods.getGoodType()) {
                case Dictionary.SHOPPING_GOODS_TYPE_JJCP:
                    orderItemDao.insert(orderItem);
                    break;
                // 购买的是单个项目
                case Dictionary.SHOPPING_GOODS_TYPE_XM:
                    orderItemDao.insert(orderItem);
                    break;
                case Dictionary.SHOPPING_GOODS_TYPE_TC:
                    // 每一个套餐都看成一个单独的订单条目
                    count = orderItem.getCount();
                    for (int j = 0; j < count; j++) {
                        orderItem.setCount(1);
                        orderItem.setId(null);
                        orderItemDao.insert(orderItem);
                    }
                    break;
                case Dictionary.SHOPPING_GOODS_TYPE_CZK:
                    // 新增明细
                    orderItem.setGoodsId(shoppingGoods.getId());
                    // 每一个充值卡都看成一个单独的订单条目
                    count = orderItem.getCount();
                    for (int j = 0; j < count; j++) {
                        orderItem.setCount(1);
                        orderItem.setId(null);
                        orderItemDao.insert(orderItem);
                    }
                    break;
                case Dictionary.SHOPPING_GOODS_TYPE_ZHK:
                    // 新增明细
                    orderItem.setGoodsId(shoppingGoods.getId());
                    // 每一个充值卡都看成一个单独的订单条目
                    count = orderItem.getCount();
                    for (int j = 0; j < count; j++) {
                        orderItem.setCount(1);
                        orderItem.setId(null);
                        orderItemDao.insert(orderItem);
                    }
                    break;
            if (StringUtils.isNotBlank(shopSku.getStockCode())) {
                needTb=true;
            }
        }
        // 处理收款逻辑
        SysOrder sourceOrder = sysOrderDao.selectById(order.getId());
        sourceOrder.setItems(orderItemDao.selectByOrderId(order.getId()));
        // 设置会员充值卡使用情况
        orderService.addMoneyCardUse(sourceOrder);
        if(needTb){
        // 改变客户项目套餐使用情况
        orderService.addTaocanProj(sourceOrder);
            BizUser bizUser = bizUserService.findByOpenId(orderDto.getUserId());
            SysOrder order = new SysOrder();
            //TODO 根据公司id区分
            SysVipInfo vipInfo = vipDao.selectByPhone(bizUser.getPhoneNumber());
            if(SysVipInfo.UNDEAL_VIP==vipInfo.getIsDeal()){
                //非成交客户下单更新客户为成交客户
                vipInfo.setIsDeal(SysVipInfo.DEAL_VIP);
                vipDao.update(vipInfo);
            }
        // 设置销量
        orderService.setShopSelCount(sourceOrder);
            //获取订单归属门店
            order.setCompanyId(orderDto.getCompanyId());
            order.setShopId(Long.parseLong(orderDto.getStoreId()+""));
            //同步的订单订单编号保持一致
            order.setOrderNo(orderDto.getOrderNo());
            order.setVipId(vipInfo.getId());
            order.setOrderTime(new Date());
            order.setRemark(AppConstance.WX_ORDER_FLAG);
            order.setStaffId(vipInfo.getStaffId());
            order.setIsCross(2 + "");
            order.setStatu(Dictionary.ORDER_STATU_YFK);
            order.setCardPay(0.00);
            order.setCashPay(orderDto.getOrderMoney().doubleValue());
            order.setTotal(orderDto.getOrderMoney().doubleValue());
            order.setZkTotal(orderDto.getOrderMoney().doubleValue());
            order.setPayTime(new Date());
            order.setArrears(0D);
            int i = sysOrderDao.insert(order);
            // 创建订单明细,并计算总价与折扣总价
            int count = 0;
            // 设置订单条目
            for (ShopOrderDetails orderItemDto : orderDto.getDetails()) {
        SysOrderFlow flow = new SysOrderFlow();
        flow.setFlowNo(codeService.getFlowCode() + "-" + i);
        Long goodsId = sourceOrder.getItems().get(0).getGoodsId();
        ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId);
        flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品");
        flow.setOrderId(sourceOrder.getId());
        flow.setVipId(sourceOrder.getVipId());
        flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY);
                ShopSku shopSku = shopSkuDao.selectById(orderItemDto.getsId());
        flow.setAmount(orderDto.getOrderMoney());
        flow.setPayMethod("微信");
                if (StringUtils.isBlank(shopSku.getStockCode())) {
                    LogUtil.warn("销售产品未绑定erp中的产品,无法进行同步");
                }
        flow.setShopId(sourceOrder.getShopId());
        flow.setCompanyId(sourceOrder.getCompanyId());
        sysOrderFlowDao.insert(flow);
                String goodsCode =shopSku.getStockCode();
                ShoppingGoods shoppingGoods = shoppingGoodsService.findById(Long.parseLong(goodsCode));
                if (shoppingGoods == null) {
                    LogUtil.warn("无效的商品id{}", shopSku.getAtrid());
                }
                SysOrderItem orderItem = new SysOrderItem();
                orderItem.setOrderId(order.getId());
                orderItem.setCount(orderItemDto.getCount());
                orderItem.setIsFree(orderItemDto.getPrice().doubleValue() > 0 ? "否" : "是");
                orderItem.setType(shoppingGoods.getGoodType());
                orderItem.setStatus(Dictionary.ORDER_STATU_YFK);
                orderItem.setPrice(orderItemDto.getPrice().doubleValue());
                orderItem.setZkPrice(orderItemDto.getPrice().doubleValue());
                orderItem.setGoodsId(shoppingGoods.getId());
                // 设置对应产品的id
                switch (shoppingGoods.getGoodType()) {
                    case Dictionary.SHOPPING_GOODS_TYPE_JJCP:
                        orderItemDao.insert(orderItem);
                        break;
                    // 购买的是单个项目
                    case Dictionary.SHOPPING_GOODS_TYPE_XM:
                        orderItemDao.insert(orderItem);
                        break;
                    case Dictionary.SHOPPING_GOODS_TYPE_TC:
                        // 每一个套餐都看成一个单独的订单条目
                        count = orderItem.getCount();
                        for (int j = 0; j < count; j++) {
                            orderItem.setCount(1);
                            orderItem.setId(null);
                            orderItemDao.insert(orderItem);
                        }
                        break;
                    case Dictionary.SHOPPING_GOODS_TYPE_CZK:
                        // 新增明细
                        orderItem.setGoodsId(shoppingGoods.getId());
                        // 每一个充值卡都看成一个单独的订单条目
                        count = orderItem.getCount();
                        for (int j = 0; j < count; j++) {
                            orderItem.setCount(1);
                            orderItem.setId(null);
                            orderItemDao.insert(orderItem);
                        }
                        break;
                    case Dictionary.SHOPPING_GOODS_TYPE_ZHK:
                        // 新增明细
                        orderItem.setGoodsId(shoppingGoods.getId());
                        // 每一个充值卡都看成一个单独的订单条目
                        count = orderItem.getCount();
                        for (int j = 0; j < count; j++) {
                            orderItem.setCount(1);
                            orderItem.setId(null);
                            orderItemDao.insert(orderItem);
                        }
                        break;
                }
            }
            // 处理收款逻辑
            SysOrder sourceOrder = sysOrderDao.selectById(order.getId());
            sourceOrder.setItems(orderItemDao.selectByOrderId(order.getId()));
            // 设置会员充值卡使用情况
            orderService.addMoneyCardUse(sourceOrder);
            // 改变客户项目套餐使用情况
            orderService.addTaocanProj(sourceOrder);
            // 设置销量
            orderService.setShopSelCount(sourceOrder);
            SysOrderFlow flow = new SysOrderFlow();
            flow.setFlowNo(codeService.getFlowCode() + "-" + i);
            Long goodsId = sourceOrder.getItems().get(0).getGoodsId();
            ShoppingGoods goods = shoppingGoodsDao.selectById(goodsId);
            flow.setFlowContent(goods.getName() + "等" + sourceOrder.getItems().size() + "件产品");
            flow.setOrderId(sourceOrder.getId());
            flow.setVipId(sourceOrder.getVipId());
            flow.setFlowType(SysOrderFlow.FLOW_TYPE_BUY);
            flow.setAmount(orderDto.getOrderMoney());
            flow.setPayMethod("微信");
            flow.setShopId(sourceOrder.getShopId());
            flow.setCompanyId(sourceOrder.getCompanyId());
            sysOrderFlowDao.insert(flow);
        }else{
            LogUtil.info("不存在需要同步的产品");
        }
    }
@@ -218,14 +229,14 @@
    @Override
    public void handle(String consumerTag, Delivery message) throws IOException {
            String orderId = new String(message.getBody(), "UTF-8");
            LogUtil.debug("收到创建订单任务orderId={}", orderId);
            //获取订单信息
            ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId));
            //获取订单详情
            List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId));
            order.setDetails(orderDetails);
            createOrder(order);
        String orderId = new String(message.getBody(), "UTF-8");
        LogUtil.debug("收到创建订单任务orderId={}", orderId);
        //获取订单信息
        ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId));
        //获取订单详情
        List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId));
        order.setDetails(orderDetails);
        createOrder(order);
    }
}
zq-erp/src/main/resources/config/application.properties
@@ -8,9 +8,6 @@
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=chuhuan
#spring.datasource.password=chuhuan
#spring.datasource.url=jdbc:mysql://175.6.132.141:3306/hive_v2_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml
@@ -526,6 +526,7 @@
        <result property="tag" column="tag"/>
        <result property="isUsing" column="is_using"/>
        <result property="kind" column="kind"/>
        <result property="companyId" column="company_id"/>
    </resultMap>
    <select id="selectUsableCouponByProductInfo" resultMap="WxShopCouponMap">
@@ -561,7 +562,8 @@
        select *
        from shop_coupon
        where
        kind=2 and now() >= begin_time and end_time >= now()
        company_id=#{companyId}
        and kind=2 and now() >= begin_time and end_time >= now()
        and is_open = 1
        and (is_all = 1 or
        (
@@ -584,7 +586,7 @@
        ifnull(scr.is_using, 0) is_using
        from shop_coupon sc left join shop_coupon_record scr
        on sc.id = scr.c_id and user_id = #{userId}
        where sc.shop_id=#{shopId} and sc.kind=1  and now() >= begin_time and end_time >= now() and is_open = 1
        where sc.company_id=#{companyId} and sc.kind=1  and now() >= begin_time and end_time >= now() and is_open = 1
        <!--<if test="!isNewPeople">-->
        <!--and get_limit = 1-->
        <!--</if>-->
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml
@@ -270,7 +270,7 @@
        sc.min_amount minAmount, sc.offset_amount offsetAmount, sc.is_all isAll,
        sc.product_ids productIds, sc.attr_ids attrIds, scr.is_using isUsing
        from shop_coupon sc, shop_coupon_record scr
        where sc.shop_id=#{shopId} and sc.id = scr.c_id and scr.user_id = #{userId} and is_using = #{status}
        where sc.company_id=#{companyId} and sc.id = scr.c_id and scr.user_id = #{userId} and is_using = #{status}
        and is_open = 1
        <if test="status == 2">
            and now() >= begin_time and end_time >= now()
@@ -296,7 +296,7 @@
        sc.min_amount minAmount, sc.offset_amount offsetAmount, sc.is_all isAll,
        sc.product_ids productIds, sc.attr_ids attrIds, scr.is_using isUsing
        from shop_coupon sc, shop_coupon_record scr
        where sc.shop_id=#{shopId} and sc.id = scr.c_id and scr.user_id = #{userId}
        where sc.company_id=#{companyId} and sc.id = scr.c_id and scr.user_id = #{userId}
        and (isnull(order_id) or order_id = 0)
        and now() > end_time and is_open = 1
        <if test="pageVo != null"><!-- 判断pageVo对象是否为空 -->
zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopProductAttributeDao.xml
@@ -39,7 +39,7 @@
        <result property="attrMark" column="attr_mark" />
        <result property="sort"    column="sort"/>
        <result property="companyId" column="company_id" />
        <collection property="child" column="{attrId=attr_id, shopId=shop_id}" select="selectByParentIds"/>
        <collection property="child" column="{attrId=attr_id, companyId=company_id}" select="selectByParentIds"/>
    </resultMap>
    <!-- 根据id查询-->
@@ -47,7 +47,7 @@
        select
        <include refid="columns" ></include>
        from shop_product_attribute
        where  parent_id=#{attrId} and shop_id=#{shopId}
        where  parent_id=#{attrId} and company_id=#{companyId}
    </select>
    <!-- 根据编码查询-->
zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html
@@ -143,9 +143,14 @@
                <!--<span class="text-danger">*</span>-->
            </label>
            <div class="col-sm-4">
                <input autocomplete="off"   type="text" class="form-control" name="tag"
                        ignore="ignore"
                       th:value="${obj.tag}"nullmsg="优惠券名称不能为空">
                <select class="form-control" dataType="*" nullmsg="请选择" name="tag">
                    <!--                    <option value=''>请选择</option>-->
                    <option value='zqyhq' th:if="${obj.tag == 'zqyhq'}" selected>专区券</option>
                    <option value='zqyhq' th:unless="${obj.tag == 'zqyhq'}">专区券</option>
                    <option value='gmyhq' th:if="${obj.tag == 'gmyhq'}" selected>全场券</option>
                    <option value='gmyhq' th:unless="${obj.tag == 'gmyhq'}">全场券</option>
                </select>
            </div>
        </div>
zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html
@@ -60,7 +60,7 @@
                                    <div class="form-group mr-20 ml-20">
                                        <span class="serch-title">物流公司:</span>
                                        <select class="form-control autoFull" style="width: 190px"
                                                th:data-url="@{/wxapi/dataDictionary/getListByParentCode/kdgs}" data-value="typeCode"
                                                th:data-url="@{/admin/customerDictionary/getListByParentCode/kdgs}" data-value="typeCode"
                                                data-filed="typeName" name="logisticsCompanyCode">
                                            <option value=''>--请选择物流公司--</option>
                                        </select>
zq-erp/src/main/resources/templates/views/admin/shop/shopProduct-form.html
@@ -797,15 +797,7 @@
                    flag = true;
                    return false;
                }
                var path = tds.eq(length - 6).find("img").attr("src");
                if(path == null){
                    layer.msg("请填写规格图片",{
                        icon : 2,
                        time : 2000
                    });
                    flag = true;
                    return false;
                }
                var stock = tds.eq(length - 5).find("input").val();
                if(stock == ""){
                    layer.msg("请填写库存",{
@@ -832,15 +824,7 @@
                    flag = true;
                    return false;
                }
                var erpNo = tds.eq(length - 2).find("input").val();
                if(erpNo == ""){
                    layer.msg("请填写erp产品编号,否则订单无法和erp同步",{
                        icon : 2,
                        time : 2000
                    });
                    flag = true;
                    return false;
                }
            }