Merge branch 'api' into score_shop
# Conflicts:
#	zq-erp/pom.xml
 
	
	
	
	
	
	
	
	
	
	
	
	
	
 |  |  | 
 |  |  | 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; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 小程序消息模板 | 
 |  |  | 
 |  |  |     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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @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); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  | 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 | 
 |  |  | 
 |  |  |         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; | 
 |  |  |     } | 
 |  |  |      | 
 
 |  |  | 
 |  |  |     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); | 
 
 |  |  | 
 |  |  |         // url权限拦截 | 
 |  |  |         registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**"); | 
 |  |  |         //小程序公司与域名对应关系拦截 | 
 |  |  |         registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**"); | 
 |  |  |         registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**") | 
 |  |  |                 .excludePathPatterns("/wxCommon/wxapi/wxpayCallback"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     // =====================================订单包裹相关 | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 省内包裹 | 
 |  |  |      */ | 
 |  |  |     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"; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 待开票 | 
 |  |  | 
 |  |  |     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"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  |  | 
 |  |  | 
 |  |  |             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() | 
 
 |  |  | 
 |  |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |  | 
 |  |  |         ShopProductAttribute service=new ShopProductAttribute(); | 
 |  |  |         BeanUtils.copyProperties(cpfl,service); | 
 |  |  |         service.setAttrName("服务"); | 
 |  |  |         service.setAttrName("属性"); | 
 |  |  |         service.setAttrCode("service"); | 
 |  |  |         shopProductAttributeDao.batchInsert(Arrays.asList(cpfl,service)); | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  |     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") | 
 |  |  | 
 |  |  |  | 
 |  |  |             newShopAdvertisType.setCreateBy(user.getSuName()); | 
 |  |  |             newShopAdvertisType.setUpdateBy(user.getSuName()); | 
 |  |  |  | 
 |  |  |             newShopAdvertisType.setCompanyId(user.getCompanyId()); | 
 |  |  |             shopAdvertisTypeDao.insert(newShopAdvertisType); | 
 |  |  |         } else { | 
 |  |  |             shopAdvertisTypeDao.updateByModel(newShopAdvertisType); | 
 |  |  | 
 |  |  |             collect.forEach(ad -> { | 
 |  |  |                 ad.setCreateBy(user.getSuName()); | 
 |  |  |                 ad.setUpdateBy(user.getSuName()); | 
 |  |  |                 ad.setCompanyId(user.getCompanyId()); | 
 |  |  |                 ad.setTypeId(newShopAdvertisType.getAdtId()); | 
 |  |  |             }); | 
 |  |  |  | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |      * @param shopCoupon | 
 |  |  |      */ | 
 |  |  |     private void productLabeling(ShopCoupon shopCoupon) { | 
 |  |  |         SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
 |  |  |         Date now = new Date(); | 
 |  |  |         Boolean needUpdate = false; | 
 |  |  |         //优惠券处于可用状态 | 
 |  |  | 
 |  |  |             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())) { | 
 
 |  |  | 
 |  |  | 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 小程序页面 | 
 |  |  | 
 |  |  |     @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()); | 
 |  |  | 
 |  |  |        @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() + "重复"); | 
 
 |  |  | 
 |  |  | 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 | 
 |  |  |      */ | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     private static String accessToken = ""; | 
 |  |  |  | 
 |  |  |     private static String appid = ""; | 
 |  |  |     private static String secret = ""; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * @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(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |         accessToken = ""; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public static String getAccessToken() throws IOException { | 
 |  |  |     public  String getAccessToken(Long companyId) throws IOException { | 
 |  |  |  | 
 |  |  |         if (isTokenInvalid()) { | 
 |  |  |             synchronized (accessToken) { | 
 |  |  | 
 |  |  |                     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; | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private BizUserDao bizUserDao; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     WeChatApiTools weChatApiTools; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |         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); | 
 |  |  | 
 |  |  |                     bizUser.setOpenId(openId); | 
 |  |  |                     bizUser.setLastLoginTime(new Date()); | 
 |  |  |                     bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER); | 
 |  |  |                     bizUser.setCompanyId(HostInterceptor.getCompanyId()); | 
 |  |  |                     bizUserService.add(bizUser); | 
 |  |  |  | 
 |  |  |                 } else { | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         //获取当前购物车产品可用的优惠券 | 
 |  |  |         List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(addShopOrderPOJO.getShopId(),notCouponuyCart); | 
 |  |  |         List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(bizUser.getCompanyId(),notCouponuyCart); | 
 |  |  |  | 
 |  |  |         //获取用户使用的优惠券 | 
 |  |  |         CouponReceiveInfoVO shopCoupon = new CouponReceiveInfoVO(); | 
 |  |  | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         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()); | 
 |  |  |         //结算金额信息 | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |                 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())) { | 
 |  |  | 
 |  |  |                         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 校验支付金额 | 
 |  |  | 
 |  |  |                 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)"); | 
 |  |  | 
 |  |  |         return null; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |             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, "保存成功"); | 
 |  |  |         } | 
 |  |  |  | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     ShopActivitiesSeckillInfoDao shopActivitiesSeckillInfoDao; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     BusParameterSettingsDao busParameterSettingsDao; | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 生成二维码 | 
 |  |  |      */ | 
 |  |  | 
 |  |  |                 qrcodeImgParam = getQrcodeImgParam(loginUser, qrcodeVo); | 
 |  |  |                 shareQrcord.setProductId(qrcodeVo.getProductId()); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             qrcodeImgParam.logo=""; | 
 |  |  |             //绘制二维码 | 
 |  |  |             drawQrcode(qrcodeImgParam); | 
 |  |  |  | 
 |  |  | 
 |  |  |         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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     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()); | 
 |  |  |  | 
 |  |  | 
 |  |  |         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); | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.util.Calendar; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  | 
 |  |  |  | 
 |  |  |     @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) { | 
 |  |  | 
 |  |  |         } 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()))); | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private WXShopOrderService wxShopOrderService; | 
 |  |  |     @Autowired | 
 |  |  |     private WxShopActivitiesSecKillService wxShopActivitiesSecKillService; | 
 |  |  |     private WxShopActivitiesSecKillService wxShopActvitiesSecKillService; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private RedisUserLoginUtils redisUserLoginUtils; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @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); | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     @PostMapping(value = "/createSecKill") | 
 |  |  |     public AjaxResult createSecKill(@RequestBody CreateSecKillDTO secKillDTO) throws Exception { | 
 |  |  |         return wxShopActivitiesSecKillService.createSecKillOrder(secKillDTO); | 
 |  |  |         return wxShopActvitiesSecKillService.createSecKillOrder(secKillDTO); | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | 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.*; | 
 |  |  | 
 |  |  |      * | 
 |  |  |      * @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); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         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()); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |         // 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); | 
 |  |  | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } 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); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice); | 
 |  |  |     BigDecimal calculationPostage(BigDecimal payPrice,Long companyId); | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 创建订单 | 
 |  |  | 
 |  |  |      */ | 
 |  |  |     AjaxResult updateStockAndVolumeById(Integer orderId); | 
 |  |  |  | 
 |  |  |     DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Integer addrId); | 
 |  |  |     DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Long companyId); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |      * 根据购物车选中的产品 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public List<CouponReceiveInfoVO> getCartVoCouponList(Long shopId,List<ShopShoppingCart> shopShoppingCarts); | 
 |  |  |     public List<CouponReceiveInfoVO> getCartVoCouponList(Long companyId,List<ShopShoppingCart> shopShoppingCarts); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |      * 根据状态获取我的优惠券 | 
 |  |  |      *  | 
 |  |  |      * | 
 |  |  |      * @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获取优惠券列表 | 
 |  |  | 
 |  |  |      * 根据标签获取优惠券列表 | 
 |  |  |      * | 
 |  |  |      * @param tag | 
 |  |  |      * @param shopId | 
 |  |  |      * @param companyId | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     AjaxResult getCouponListByTag(String tag, Long shopId); | 
 |  |  |     AjaxResult getCouponListByTag(String tag, Long companyId); | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据产品id查询该产品符合的优惠活动 | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //计算订单优惠信息 | 
 |  |  |         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; | 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @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()); | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         discountExplain.setPostage(calculationPostage(receiveAddrId, discountExplain.getPayPrice())); | 
 |  |  |         discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(),companyId)); | 
 |  |  |  | 
 |  |  |         //计算实际支付 | 
 |  |  |         discountExplain.setPayPrice(discountExplain.getPayPrice().add(discountExplain.getPostage())); | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |         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); | 
 |  |  |  | 
 |  |  | 
 |  |  |         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); | 
 
 |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private ShopOrder createOrder(CreateSecKillDTO secKillDTO) { | 
 |  |  |         BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); | 
 |  |  |         ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(secKillDTO.getAddressId()); | 
 |  |  |         if (shopReceiveAddress == null) { | 
 |  |  |             throw new GlobleException("请选择正确的收获地址"); | 
 |  |  | 
 |  |  |         shopOrder.setUpdateBy("微信小程序生成"); | 
 |  |  |         shopOrder.setCommodityPrice(secKillDTO.getPrice()); | 
 |  |  |         shopOrder.setPurchaseQuantity(1); | 
 |  |  |         shopOrder.setCompanyId(bizUser.getCompanyId()); | 
 |  |  |         //购买方式 | 
 |  |  |         shopOrder.setShippingMethod(secKillDTO.getShippingMethod()); | 
 |  |  |         //生成订单号 | 
 |  |  | 
 |  |  |         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); | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |     @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<>(); | 
 |  |  | 
 |  |  |  | 
 |  |  |         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)) { | 
 |  |  |             //根据优惠力度排序,优惠力度大的先参与计算 | 
 |  |  | 
 |  |  |      * 根据订单状态查询优惠券列表 | 
 |  |  |      * | 
 |  |  |      * | 
 |  |  |      * @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); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |                 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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @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; | 
 
 |  |  | 
 |  |  | 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; | 
 |  |  | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } 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); | 
 
 |  |  | 
 |  |  |                                         @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); | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     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); | 
 |  |  | } | 
 
 |  |  | 
 |  |  |  | 
 |  |  |     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); | 
 |  |  |  | 
 |  |  | } | 
 
 |  |  | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | import java.io.IOException; | 
 |  |  | import java.util.ArrayList; | 
 |  |  | import java.util.Date; | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | 
 |  |  |     @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(0); | 
 |  |  |         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(0); | 
 |  |  |             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("不存在需要同步的产品"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |     @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); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  | } | 
 
 |  |  | 
 |  |  | 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 | 
 
 |  |  | 
 |  |  | #spring.datasource.url=jdbc:mysql://119.3.52.84:3306/hive_prd?useUnicode=true&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.url=jdbc:mysql://121.37.162.173:3306/hive_prd?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 
 |  |  | 
 |  |  |         <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"> | 
 |  |  | 
 |  |  |         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 | 
 |  |  |         ( | 
 |  |  | 
 |  |  |         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>--> | 
 
 |  |  | 
 |  |  |         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() | 
 |  |  | 
 |  |  |         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对象是否为空 --> | 
 
 |  |  | 
 |  |  |         <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查询--> | 
 |  |  | 
 |  |  |         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> | 
 |  |  |  | 
 |  |  |     <!-- 根据编码查询--> | 
 
 |  |  | 
 |  |  |                 <!--<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> | 
 
 |  |  | 
 |  |  |                                     <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> | 
 
 |  |  | 
 |  |  |                     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("请填写库存",{ | 
 |  |  | 
 |  |  |                     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; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             } |