From 087cd794187727bf9a34fcef3027cd56f6dec436 Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Wed, 10 Mar 2021 15:20:54 +0800 Subject: [PATCH] Merge branch 'api' of http://120.27.238.55:7000/r/beauty-erp into api --- zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java | 32 +- zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java | 35 +- zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java | 3 zq-erp/src/main/resources/config/application.properties | 9 zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java | 3 zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java | 13 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java | 31 - zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java | 21 + zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java | 1 zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java | 4 zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java | 2 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java | 6 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java | 33 -- zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java | 6 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java | 6 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java | 9 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java | 12 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java | 62 +--- zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html | 2 zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml | 6 zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java | 18 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java | 10 zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java | 265 ++++++++++--------- zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java | 75 ----- zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java | 29 +- zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html | 11 zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java | 4 zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java | 4 31 files changed, 312 insertions(+), 412 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java index 9eab399..37b94c2 100644 --- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java +++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/business/JsApiPayBusiness.java @@ -14,6 +14,7 @@ import com.matrix.component.wechat.externalInterface.service.RefundService; import com.matrix.component.wechat.externalInterface.service.ScanPayQueryService; import org.apache.log4j.Logger; +import org.springframework.beans.BeanUtils; /** * User: rizenguo Date: 2014/12/1 Time: 17:05 @@ -55,9 +56,10 @@ log.info("------------------request createPrapareOrder taking :" + totalTimeCost + "ms"+"--response="+payServiceResponseString); // 将从API返回的XML数据映射到Java对象 - JsApiPayResData jsApiPayResData = (JsApiPayResData) Util.getObjectFromXML(payServiceResponseString, + Object data = Util.getObjectFromXML(payServiceResponseString, JsApiPayResData.class); - + JsApiPayResData jsApiPayResData=new JsApiPayResData(); + BeanUtils.copyProperties(data,jsApiPayResData); return jsApiPayResData; } diff --git a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java index 4c0692a..393f57b 100644 --- a/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java +++ b/zq-erp/src/main/java/com/matrix/component/wechat/externalInterface/common/Util.java @@ -67,6 +67,8 @@ public static Object getObjectFromXML(String xml, Class<?> tClass) { //将从API返回的XML数据映射到Java对象 XStream xStreamForResponseData = new XStream(); + XStream.setupDefaultSecurity(xStreamForResponseData); + xStreamForResponseData.allowTypes(new Class[]{tClass}); xStreamForResponseData.alias("xml", tClass); xStreamForResponseData.ignoreUnknownElements();//暂时忽略掉一些新增的字段 return xStreamForResponseData.fromXML(xml); diff --git a/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java b/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java index c48dfe0..8520ba6 100644 --- a/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java +++ b/zq-erp/src/main/java/com/matrix/config/MvcCoreConfig.java @@ -76,7 +76,8 @@ // url权限拦截 registry.addInterceptor(suAuthorityInterceptor).addPathPatterns("/**/su/**"); //小程序公司与域名对应关系拦截 - registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**"); + registry.addInterceptor(hostInterceptor).addPathPatterns("/**/wxapi/**") + .excludePathPatterns("/wxCommon/wxapi/wxpayCallback"); } diff --git a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java index 705a50f..957ed99 100644 --- a/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java +++ b/zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java @@ -262,41 +262,11 @@ // =====================================订单包裹相关 - /** - * 省内包裹 - */ - public static final String IN_PROVINCE_PACKAGE = "IN_PROVINCE_PACKAGE"; - /** - * 外省包裹 - */ - public static final String OUT_PROVINCE_PACKAGE = "OUT_PROVINCE_PACKAGE"; - /** - * 省内免邮费包裹 - */ - public static final String PROVINCE_OVER_FREE_PACKAGE = "PROVINCE_OVER_FREE_PACKAGE"; // =====================================订单短信提醒相关 - /** - * 短信提醒 - */ - public static final String MSG_ALERT = "MSG_ALERT"; - /** - * 短信提醒号码(多个以",分割") - */ - public static final String MSG_ALERT_MOBILE = "MSG_ALERT_MOBILE"; - - /** - * 短信提醒内容 - */ - public static final String MSG_ALERT_CONTENT = "MSG_ALERT_CONTENT"; - - /** - * 商户余额不足短信提醒内容 - */ - public static final String MSG_ALERT_NSF = "MSG_ALERT_NSF"; /** * 待开票 @@ -542,51 +512,14 @@ public static final String REFUND_FAIL_NOTENOUGH = "NOTENOUGH"; - // =====================================分销相关 /** - * 成为分销商最低额度(查询数据字典时使用) + * 运费 */ - public static final String BECOMING_DISTRIBUTOR_CONDITION = "BECOMING_DISTRIBUTOR_CONDITION"; - + public static final String PACKAGE_PRICE = "PACKAGE_PRICE"; /** - * 用户等级-分销商 + * 免免邮金额 */ - public static final Integer USER_VIP_DISTRIBUTOR = 1; - - /** - * 积分业务类型-获得 - */ - public static final Integer SCORE_BUSINESS_TYPE_GET = 1; - - /** - * 积分业务类型-兑换 - */ - public static final Integer SCORE_BUSINESS_TYPE_EXCHANGE = 2; - - /** - * 免费配送距离 - */ - public static final String DELIVERY_DISTANCE = "delivery_distance"; - /** - * 支持学校列表 - */ - public static final String SCHOOL = "SCHOOL"; - - - /** - * 省运费关系 - */ - public static final String IN_PROVINCE_PACKAGE_PRICE = "IN_PROVINCE_PACKAGE_PRICE"; - public static final String FIRST_OUT_PROVINCE_PACKAGE_PRICE = "FIRST_OUT_PROVINCE_PACKAGE_PRICE"; - public static final String SECOND_OUT_PROVINCE_PACKAGE_PRICE = "SECOND_OUT_PROVINCE_PACKAGE_PRICE"; - - public static final String IN_PROVINCE_PACKAGE_LIST = "IN_PROVINCE_PACKAGE_LIST"; - public static final String FIRST_PROVINCE_PACKAGE_LIST = "FIRST_PROVINCE_PACKAGE_LIST"; - public static final String SECOND_PROVINCE_PACKAGE_LIST = "SECOND_PROVINCE_PACKAGE_LIST"; - /** - * 起送费 - */ - public static final String QSFY = "QSFY"; + public static final String FREE_PACKAGE_PRICE = "FREE_PACKAGE_PRICE"; /** diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java index 3057829..d07aa26 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopAdvertisTypeAction.java @@ -103,6 +103,7 @@ public @ResponseBody AjaxResult modifyShopAdvertisType(@RequestBody ShopAdvertisType newShopAdvertisType) { SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); + if (StringUtils.isNotBlank(newShopAdvertisType.getNodeStyle())) { String style = newShopAdvertisType.getNodeStyle(); style = style.replaceAll("px", "rpx") @@ -116,7 +117,7 @@ newShopAdvertisType.setCreateBy(user.getSuName()); newShopAdvertisType.setUpdateBy(user.getSuName()); - + newShopAdvertisType.setCompanyId(user.getCompanyId()); shopAdvertisTypeDao.insert(newShopAdvertisType); } else { shopAdvertisTypeDao.updateByModel(newShopAdvertisType); @@ -135,6 +136,7 @@ collect.forEach(ad -> { ad.setCreateBy(user.getSuName()); ad.setUpdateBy(user.getSuName()); + ad.setCompanyId(user.getCompanyId()); ad.setTypeId(newShopAdvertisType.getAdtId()); }); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java index b08d002..d60a263 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopCouponAction.java @@ -14,7 +14,6 @@ import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.constance.Dictionary; -import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.shopXcx.bean.ShopCoupon; import com.matrix.system.shopXcx.bean.ShopProduct; import com.matrix.system.shopXcx.dao.ShopCouponDao; @@ -269,6 +268,7 @@ * @param shopCoupon */ private void productLabeling(ShopCoupon shopCoupon) { + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); Date now = new Date(); Boolean needUpdate = false; //优惠券处于可用状态 @@ -279,6 +279,7 @@ if (shopCoupon.getIsAll() == 1) { ShopProduct productQuery = new ShopProduct(); productQuery.setDelFlag(2); + productQuery.setCompanyId(user.getCompanyId()); shopProductList = shopProductDao.selectByModel(productQuery); } else { if (StringUtils.isNotBlank(shopCoupon.getProductIds())) { diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java index 6de4994..7a02327 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/action/ShopPageAction.java @@ -1,30 +1,29 @@ package com.matrix.system.shopXcx.action; +import com.matrix.core.anotations.RemoveRequestToken; +import com.matrix.core.anotations.SaveRequestToken; import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.constance.SystemMessageCode; +import com.matrix.core.exception.GlobleException; +import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.tools.ModelUtils; import com.matrix.core.tools.StringUtils; -import com.matrix.core.web.BaseAction; -import com.matrix.core.constance.SystemErrorCode; -import com.matrix.core.anotations.RemoveRequestToken; +import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.tools.ServiceUtil; import com.matrix.system.hive.action.util.QueryUtil; +import com.matrix.system.shopXcx.bean.ShopPage; import com.matrix.system.shopXcx.dao.ShopPageDao; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import com.matrix.core.exception.GlobleException; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import com.matrix.core.anotations.SaveRequestToken; -import com.matrix.core.pojo.AjaxResult; -import com.matrix.core.tools.WebUtil; -import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.servlet.ModelAndView; import java.util.List; import java.util.Map; -import com.matrix.system.shopXcx.bean.ShopPage; -import org.springframework.web.servlet.ModelAndView; /** * @description 小程序页面 @@ -77,10 +76,11 @@ @RemoveRequestToken @RequestMapping(value = "/addShopPage") public @ResponseBody AjaxResult addShopPage(ShopPage shopPage) { - if (serviceUtil.addCheckRepeat("shop_page", "code", shopPage.getCode())) { + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + if (serviceUtil.addCheckRepeatTowColumn("shop_page", "code", shopPage.getCode(),"company_id", user.getCompanyId())) { throw new GlobleException("code重复"); } - SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + shopPage.setCreateBy(user.getSuName()); shopPage.setUpdateBy(user.getSuName()); shopPage.setCompanyId(user.getCompanyId()); @@ -103,9 +103,10 @@ @RequestMapping(value = "/modifyShopPage") public @ResponseBody AjaxResult modifyShopPage(ShopPage newShopPage) { ShopPage oldShopPage = WebUtil.getSessionAttribute(BEV); - + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); // 校验去重 - if (serviceUtil.updateCheckRepeat("shop_page", + if (serviceUtil.updateCheckRepeatTowColumn("shop_page", + "company_id", user.getCompanyId(), "code", newShopPage.getCode(), "id",newShopPage.getId())) { throw new GlobleException("编号" + newShopPage.getCode() + "重复"); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java index 90ab0c2..e5bbb53 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/WxUserAction.java @@ -95,6 +95,7 @@ bizUser.setOpenId(openId); bizUser.setLastLoginTime(new Date()); bizUser.setUserType(AppConstance.USER_TYPE_CUSTOMER); + bizUser.setCompanyId(HostInterceptor.getCompanyId()); bizUserService.add(bizUser); } else { diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java index 54ca9f5..7c7577a 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WXShopOrderAction.java @@ -10,7 +10,6 @@ import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.constance.AppConstance; -import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.ShoppingGoods; import com.matrix.system.hive.dao.ShoppingGoodsDao; @@ -117,7 +116,7 @@ } } //获取当前购物车产品可用的优惠券 - List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(addShopOrderPOJO.getShopId(),notCouponuyCart); + List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(bizUser.getCompanyId(),notCouponuyCart); //获取用户使用的优惠券 CouponReceiveInfoVO shopCoupon = new CouponReceiveInfoVO(); @@ -151,13 +150,9 @@ } - Integer addrId = null; - if (shopReceiveAddress != null) { - addrId = shopReceiveAddress.getAddrId(); - } //得到订单计价说明 - DiscountExplain discountExplain = shopOrderService.buildDiscountExplain(cartList, shopCoupon.getReceiveId(), addrId); + DiscountExplain discountExplain = shopOrderService.buildDiscountExplain(cartList, shopCoupon.getReceiveId(), bizUser.getCompanyId()); AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, buyCart, buyCart.size()); //结算金额信息 diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java index cb91885..ff78386 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxCommonAction.java @@ -1,16 +1,14 @@ package com.matrix.system.shopXcx.api.action; -import com.matrix.biz.dao.BizUserDao; import com.matrix.component.rabbitmq.RabiitMqTemplate; -import com.matrix.core.pojo.AjaxResult; -import com.matrix.core.tools.LogUtil; import com.matrix.component.wechat.externalInterface.common.Signature; import com.matrix.component.wechat.externalInterface.common.Util; import com.matrix.component.wechat.externalInterface.protocol.queryProtocol.NotifyData; +import com.matrix.core.pojo.AjaxResult; +import com.matrix.core.tools.LogUtil; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.SysVipInfoDao; import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin; @@ -22,6 +20,7 @@ import com.matrix.system.shopXcx.dao.ShopOrderDao; import com.matrix.system.shopXcx.dao.ShopPayLogDao; import com.matrix.system.shopXcx.mqTask.MQTaskRouting; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; @@ -29,12 +28,10 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; -import org.xml.sax.SAXException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; @@ -110,16 +107,25 @@ notityXml.append(inputLine); } request.getReader().close(); - // XMl转对象 - NotifyData data = (NotifyData) Util.getObjectFromXML(notityXml.toString(), NotifyData.class); - LogUtil.info(data.toString()); LogUtil.info("notityXml ---- :{} ", notityXml); + + + // XMl转对象 + Object bb = Util.getObjectFromXML(notityXml.toString(), NotifyData.class); + NotifyData data = new NotifyData(); + BeanUtils.copyProperties(bb,data); LogUtil.info("----return_code = {}", data.getReturn_code()); + // 返回状态码 SUCCESS/FAIL if (AppConstance.CODE_SUCCESS.equals(data.getReturn_code())) { + + orderId = data.getAttach(); + // 检验订单状态 + ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); + // 校验签名 - BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, HostInterceptor.getCompanyId()); + BusParameterSettings paySecret = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.WECHARPAY_SECRET, order.getCompanyId()); if (Signature.checkIsSignValidFromResponseString(notityXml.toString(),paySecret.getParamValue())) { // 校验业务结果 if (AppConstance.CODE_SUCCESS.equals(data.getResult_code())) { @@ -129,14 +135,13 @@ Double total_fee = Double.parseDouble(data.getTotal_fee()); // 商户订单号 String payNum = data.getOut_trade_no(); - orderId = data.getAttach(); + LogUtil.info("支付回调关键信息---total_fee:{},payNum:{},orderId:{}", total_fee, payNum, orderId); // 订单ID BigDecimal payMoney = new BigDecimal(total_fee).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP); - // 检验订单状态 - ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); + if (order != null && ShopOrder.ORDER_PAY_STATUS_WAIT == order.getPayStatus()) { ShopPayLog payLog = new ShopPayLog(); // TODO 校验支付金额 @@ -219,7 +224,7 @@ threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:003)"); resXml = AppConstance.RESULT_XML_FAIL.replace(ERRORMSG, "通信标识失败"); } - } catch (ParserConfigurationException | IOException | SAXException e) { + } catch (Exception e) { LogUtil.error("支付回调签名错误", e); threadResult.putInMap("status", "err"); threadResult.putInMap("msg", "查询支付信息失败,请联系客服或者刷新支付信息(错误码:004)"); @@ -271,4 +276,6 @@ return null; } + + } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java index 9ad03ff..66b4c64 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxRefundRecordAction.java @@ -1,24 +1,22 @@ package com.matrix.system.shopXcx.api.action; +import com.matrix.biz.bean.BizUser; +import com.matrix.component.redis.RedisUserLoginUtils; +import com.matrix.component.tools.WxUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.LogUtil; -import com.matrix.biz.bean.BizUser; -import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.CustomerDataDictionary; +import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.CustomerDataDictionaryDao; -import com.matrix.component.redis.RedisUserLoginUtils; -import com.matrix.system.common.constance.AppConstance; - +import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; +import com.matrix.system.shopXcx.api.tools.SMSTools; import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; import com.matrix.system.shopXcx.bean.ShopOrder; import com.matrix.system.shopXcx.bean.ShopRefundRecord; import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; import com.matrix.system.shopXcx.dao.ShopOrderDao; import com.matrix.system.shopXcx.dao.ShopRefundRecordDao; -import com.matrix.component.tools.WxUtils; -import com.matrix.system.shopXcx.api.service.WxShopRefundRecordService; -import com.matrix.system.shopXcx.api.tools.SMSTools; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -175,25 +173,6 @@ modifyMap.put("id", orderId); modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_APPLY_MONEYBACK); shopOrderDao.updateByMap(modifyMap); - //从数据字典获取需要发送的手机号码和短信提醒内容 - BusParameterSettings busParameterSetting1 =busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_CONTENT_REFUND",17L); - - String msg = busParameterSetting1.getParamValue(); - - - //TODO 写死微商城17L公司id - BusParameterSettings busParameterSetting= busParameterSettingsDao.selectCompanyParamByCode("MSG_ALERT_MOBILE",17L); - - - String phons = busParameterSetting.getParamValue(); - - phons.replace(',',','); - List<String> result = Arrays.asList(phons.split(",")); - if(CollectionUtils.isNotEmpty(result)){ - for(String phon : result){ - smsTools.sendMsg(phon, msg + "退订回T" ); - } - } return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java index dbf53bc..ba10a99 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShareProductAction.java @@ -9,7 +9,9 @@ import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.PropertiesUtil; import com.matrix.core.tools.UUIDUtil; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.hive.plugin.util.CollectionUtils; import com.matrix.system.shopXcx.api.pojo.QrcodeImgParam; @@ -81,6 +83,9 @@ @Autowired ShopActivitiesSeckillInfoDao shopActivitiesSeckillInfoDao; + @Autowired + BusParameterSettingsDao busParameterSettingsDao; + /** * 生成二维码 */ @@ -137,7 +142,7 @@ qrcodeImgParam = getQrcodeImgParam(loginUser, qrcodeVo); shareQrcord.setProductId(qrcodeVo.getProductId()); } - + qrcodeImgParam.logo=""; //绘制二维码 drawQrcode(qrcodeImgParam); @@ -186,8 +191,8 @@ qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg; qrcodeImgParam.title = "【秒杀】" + shopProduct.getTitle(); qrcodeImgParam.price = "¥" +seckillInfo.getSiPrice(); - qrcodeImgParam.logo = "深圳肽妍"; - qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品"; + + qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验"; return qrcodeImgParam; } @@ -224,8 +229,8 @@ qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg; qrcodeImgParam.title = "【拼团】" + shopProduct.getTitle(); qrcodeImgParam.price = "¥" + price.getGpPrice(); - qrcodeImgParam.logo = "深圳肽妍"; - qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品"; + + qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验"; return qrcodeImgParam; } @@ -233,6 +238,8 @@ private QrcodeImgParam getQrcodeImgParam(BizUser loginUser, QrcodeVo qrcodeVo) throws Exception { ShopProduct shopProduct = shopProductDao.selectById(qrcodeVo.getProductId()); + + String qrcodeSavePath = WxacodeUtil.getWxacode(qrcodeVo.getScene(), qrcodeVo.getPath(), UUIDUtil.getRandomID()); @@ -255,9 +262,9 @@ qrcodeImgParam.targetImg = baseSavePath + "/" + "wxacode" + "/" + targetImg; qrcodeImgParam.title = shopProduct.getTitle(); qrcodeImgParam.price = "¥" + shopProduct.getPrice().toString(); - qrcodeImgParam.logo = "深圳肽妍"; + ShopCoupon shopCoupon = shopProduct.getShopCoupon(); - qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验肽妍产品"; + qrcodeImgParam.couponName = loginUser.getNickName() + "邀您体验"; if (shopCoupon != null) { String beginTiem = DateUtil.dateFormatStr(shopCoupon.getBeginTime(), DateUtil.DATE_FORMAT_SPLITE_DD); String endTiem = DateUtil.dateFormatStr(shopCoupon.getEndTime(), DateUtil.DATE_FORMAT_SPLITE_DD); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java index b33e744..6054384 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesGroupBuyController.java @@ -4,7 +4,6 @@ import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.system.common.interceptor.HostInterceptor; -import com.matrix.system.hive.dao.SysVipInfoDao; import com.matrix.system.shopXcx.api.service.WXShopOrderService; import com.matrix.system.shopXcx.api.service.WxShopActivitiesGroupService; import com.matrix.system.shopXcx.api.vo.WxActivitiesGroupBuyVO; @@ -17,8 +16,6 @@ import org.springframework.web.bind.annotation.*; import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; import java.util.List; /** @@ -201,6 +198,7 @@ @PostMapping(value = "/calPrice") public AjaxResult calPrice(@RequestBody CreateGroupBuyDTO createGroupBuyDTO) { + BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); ShopActivitiesGroupPrice groupPrice = shopActivitiesGroupPriceDao.selectById(createGroupBuyDTO.getGpId()); // 判断参数中gjId是否为空,若为空则为团长开团。再判断团长价是否为空,如果不为空则拥有团长价 if (createGroupBuyDTO.getGjId() == null) { @@ -212,7 +210,7 @@ } else { createGroupBuyDTO.setPrice(groupPrice.getGpPrice()); } - BigDecimal postage = wxShopOrderService.calculationPostage(createGroupBuyDTO.getAddressId(), createGroupBuyDTO.getPrice()); + BigDecimal postage = wxShopOrderService.calculationPostage(createGroupBuyDTO.getPrice(),bizUser.getCompanyId()); BigDecimal payPrice = createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount())).add(postage); AjaxResult ajaxResult = new AjaxResult(AjaxResult.STATUS_SUCCESS, null); ajaxResult.putInMap("billPrice", createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount()))); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java index af6cc71..d931daf 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopActivitiesSecKillAction.java @@ -1,5 +1,7 @@ package com.matrix.system.shopXcx.api.action; +import com.matrix.biz.bean.BizUser; +import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.system.shopXcx.api.service.WXShopOrderService; import com.matrix.system.shopXcx.api.service.WxShopActivitiesSecKillService; @@ -37,7 +39,10 @@ @Autowired private WXShopOrderService wxShopOrderService; @Autowired - private WxShopActivitiesSecKillService wxShopActivitiesSecKillService; + private WxShopActivitiesSecKillService wxShopActvitiesSecKillService; + + @Autowired + private RedisUserLoginUtils redisUserLoginUtils; /** @@ -106,12 +111,13 @@ */ @PostMapping(value = "/calSecKillPrice") public AjaxResult calSecKillPrice(@RequestBody SecKillVO secKillVO) { + BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); ShopActivitiesSeckillInfo seckillInfo = shopActivitiesSeckillInfoDao.selectById(secKillVO.getId()); if (seckillInfo == null) { return AjaxResult.buildFailInstance("参数有误"); } - BigDecimal postage = wxShopOrderService.calculationPostage(secKillVO.getAddressId(), seckillInfo.getSiPrice()); + BigDecimal postage = wxShopOrderService.calculationPostage(seckillInfo.getSiPrice(),bizUser.getCompanyId()); BigDecimal payPrice = seckillInfo.getSiPrice().multiply(BigDecimal.valueOf(secKillVO.getCount())).add(postage); AjaxResult ajaxResult = new AjaxResult(AjaxResult.STATUS_SUCCESS, null); ajaxResult.putInMap("totalPrice", payPrice); @@ -128,6 +134,6 @@ */ @PostMapping(value = "/createSecKill") public AjaxResult createSecKill(@RequestBody CreateSecKillDTO secKillDTO) throws Exception { - return wxShopActivitiesSecKillService.createSecKillOrder(secKillDTO); + return wxShopActvitiesSecKillService.createSecKillOrder(secKillDTO); } } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java index 25d3e4c..b57dc41 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxShopCouponAction.java @@ -1,11 +1,11 @@ package com.matrix.system.shopXcx.api.action; +import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; - -import com.matrix.component.redis.RedisUserLoginUtils; -import com.matrix.system.shopXcx.dao.ShopCouponDao; +import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.shopXcx.api.service.WxShopCouponService; +import com.matrix.system.shopXcx.dao.ShopCouponDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -58,11 +58,11 @@ * * @return */ - @RequestMapping(value = "getMyCouponInfoByStatus/{shopId}/{status}") + @RequestMapping(value = "getMyCouponInfoByStatus/{status}") @ResponseBody - public AjaxResult getMyCouponInfo(@PathVariable("shopId") Long shopId,@PathVariable("status") Integer status, @RequestBody PaginationVO pageVo) { + public AjaxResult getMyCouponInfo(@PathVariable("status") Integer status, @RequestBody PaginationVO pageVo) { - return shopCouponService.getMyCouponInfoByStatus(shopId,status, pageVo); + return shopCouponService.getMyCouponInfoByStatus(HostInterceptor.getCompanyId(),status, pageVo); } /** @@ -76,10 +76,10 @@ return new AjaxResult(AjaxResult.STATUS_SUCCESS, shopCouponService.getCouponListByProductId(productId)); } - @GetMapping(value = "getCouponListByTag/{shopId}/{tag}") + @GetMapping(value = "getCouponListByTag/{tag}") @ResponseBody - public AjaxResult getCouponListByTag(@PathVariable("tag") String tag,@PathVariable("shopId") Long shopId) { - return shopCouponService.getCouponListByTag(tag,shopId); + public AjaxResult getCouponListByTag(@PathVariable("tag") String tag) { + return shopCouponService.getCouponListByTag(tag, HostInterceptor.getCompanyId()); } } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java index 4f9f35a..5180721 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/ShoppingCartService.java @@ -1,19 +1,14 @@ package com.matrix.system.shopXcx.api.service; -import com.matrix.core.tools.LogUtil; import com.matrix.biz.bean.BizUser; -import com.matrix.system.common.bean.BusParameterSettings; -import com.matrix.system.common.bean.CustomerDataDictionary; -import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.common.dao.CustomerDataDictionaryDao; import com.matrix.component.redis.RedisUserLoginUtils; -import com.matrix.system.common.constance.AppConstance; - +import com.matrix.core.tools.LogUtil; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.shopXcx.api.vo.ShopCartBillVo; +import com.matrix.system.shopXcx.api.vo.ShopCartVo; import com.matrix.system.shopXcx.bean.ShopCoupon; import com.matrix.system.shopXcx.bean.ShopShoppingCart; import com.matrix.system.shopXcx.dao.ShopShoppingCartDao; -import com.matrix.system.shopXcx.api.vo.ShopCartBillVo; -import com.matrix.system.shopXcx.api.vo.ShopCartVo; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -108,13 +103,9 @@ // 1表示没有优惠的默认分组 ShopCartVo def = new ShopCartVo(); - /** - * 同城配送标题 - * //DataDictionary qsfy = dataDictionaryDao.selectByTypeCode(AppConstance.QSFY); - * //def.setMsg("2公里内满" + qsfy.getValue() + "元免配送费"); - */ - def.setMsg("肽研官方商城"); + + def.setMsg("商城"); def.setCartList(new ArrayList<>()); // 组合默认分组 cartList.add(def); @@ -316,15 +307,9 @@ } } } else { - BusParameterSettings qsfy= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L); - - shopCartVo.setSubtotal(selectSum); - shopCartVo.setSrcPrice(selectSum); - if (selectSum.compareTo(new BigDecimal(qsfy.getParamValue())) < 0) { - shopCartVo.setSatisfactionCoupon(false); - } else { + shopCartVo.setSubtotal(selectSum); + shopCartVo.setSrcPrice(selectSum); shopCartVo.setSatisfactionCoupon(true); - } } } } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java index ac90aef..3dabe15 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WXShopOrderService.java @@ -18,7 +18,7 @@ - BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice); + BigDecimal calculationPostage(BigDecimal payPrice,Long companyId); /** * 创建订单 @@ -93,5 +93,5 @@ */ AjaxResult updateStockAndVolumeById(Integer orderId); - DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Integer addrId); + DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer id, Long companyId); } diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java index b406cb6..13d6e99 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/WxShopCouponService.java @@ -18,7 +18,7 @@ * 根据购物车选中的产品 * @return */ - public List<CouponReceiveInfoVO> getCartVoCouponList(Long shopId,List<ShopShoppingCart> shopShoppingCarts); + public List<CouponReceiveInfoVO> getCartVoCouponList(Long companyId,List<ShopShoppingCart> shopShoppingCarts); /** @@ -42,12 +42,12 @@ * 根据状态获取我的优惠券 * * - * @param shopId + * @param companyId * @param status * @param pageVo * @return */ - AjaxResult getMyCouponInfoByStatus(Long shopId, Integer status, PaginationVO pageVo); + AjaxResult getMyCouponInfoByStatus(Long companyId, Integer status, PaginationVO pageVo); /** * 根据产品ID获取优惠券列表 @@ -62,10 +62,10 @@ * 根据标签获取优惠券列表 * * @param tag - * @param shopId + * @param companyId * @return */ - AjaxResult getCouponListByTag(String tag, Long shopId); + AjaxResult getCouponListByTag(String tag, Long companyId); /** * 根据产品id查询该产品符合的优惠活动 diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java index 4b74dbb..dce9db6 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WXShopOrderServiceImpl.java @@ -3,10 +3,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.matrix.biz.bean.BizUser; -import com.matrix.system.common.bean.BusParameterSettings; -import com.matrix.system.common.bean.CustomerDataDictionary; -import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.common.dao.CustomerDataDictionaryDao; import com.matrix.component.rabbitmq.RabiitMqTemplate; import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.component.tools.WxUtils; @@ -16,7 +12,10 @@ import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; +import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.common.dao.CustomerDataDictionaryDao; import com.matrix.system.common.interceptor.HostInterceptor; import com.matrix.system.constance.Dictionary; import com.matrix.system.hive.bean.ShoppingGoods; @@ -99,52 +98,20 @@ private BusParameterSettingsDao busParameterSettingsDao; @Override - public BigDecimal calculationPostage(Integer addressId, BigDecimal payPrice) { + public BigDecimal calculationPostage(BigDecimal payPrice,Long companyId) { BigDecimal postage = BigDecimal.ZERO; - if (addressId != null) { - ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(addressId); - - - BusParameterSettings sn= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.IN_PROVINCE_PACKAGE_LIST,17L); - - - BusParameterSettings pydq= busParameterSettingsDao.selectCompanyParamByCode(AppConstance.SECOND_PROVINCE_PACKAGE_LIST,17L); - - - - if (sn.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) { - //省内邮费计算 - postage = getPostageByDataBictionary(AppConstance.IN_PROVINCE_PACKAGE_PRICE, payPrice); - } else if (pydq.getParamValue().indexOf(shopReceiveAddress.getAddrProvince()) > -1) { - //偏远地区 - postage = getPostageByDataBictionary(AppConstance.SECOND_OUT_PROVINCE_PACKAGE_PRICE, payPrice); - } else { - //其他地区 - postage = getPostageByDataBictionary(AppConstance.FIRST_OUT_PROVINCE_PACKAGE_PRICE, payPrice); + BusParameterSettings yf = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.PACKAGE_PRICE, companyId); + BusParameterSettings myje = busParameterSettingsDao.selectCompanyParamByCode(AppConstance.FREE_PACKAGE_PRICE, companyId); + if(yf!=null&&myje!=null){ + if (Double.parseDouble(myje.getParamValue()) > payPrice.doubleValue()) { + postage = new BigDecimal(yf.getParamValue()); } - } + return postage; } - //todo 根据数据字典计算运费 运费设置为0 后面再改配置在改计算规则 - private BigDecimal getPostageByDataBictionary(String code, BigDecimal payPrice) { - /*CustomerDataDictionary dd = dataDictionaryDao.selectByTypeCode(code); - - - BigDecimal postage = BigDecimal.ZERO; - if (StringUtils.isNotBlank(dd.getValue())) { - if (StringUtils.isNotBlank(dd.getExtValue()) - && payPrice.compareTo(new BigDecimal(dd.getExtValue())) >= 0) { - //达到条件免邮 - postage = BigDecimal.ZERO; - } else { - postage = new BigDecimal(dd.getValue()); - } - }*/ - return BigDecimal.ZERO; - } /** @@ -190,13 +157,14 @@ } //计算订单优惠信息 - DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), shopReceiveAddress.getAddrId()); + DiscountExplain discountExplain = buildDiscountExplain(cartList, addShopOrderPOJO.getCouponReceiveId(), bizUser.getCompanyId()); ShopOrder shopOrder = new ShopOrder(); shopOrder.setCompanyId(bizUser.getCompanyId()); shopOrder.setStoreId(Integer.parseInt(addShopOrderPOJO.getShopId().toString())); - shopOrder.setOrderType(ShopOrder.ORDER_TYPE_SERVICE); + //默认设置为产品类型 + shopOrder.setOrderType(ShopOrder.ORDER_TYPE_GOODS); List<ShopOrderDetails> details = new ArrayList<>(); Integer cartCount = 0; @@ -308,7 +276,7 @@ } @Override - public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Integer receiveAddrId) { + public DiscountExplain buildDiscountExplain(List<ShopCartVo> cartList, Integer receiveId, Long companyId) { ShopCartBillVo shopCartBill = shoppingCartService.buildShopCartBillVo(cartList); DiscountExplain discountExplain = new DiscountExplain(); discountExplain.setActivity(shopCartBill.getBillCouponTotal()); @@ -325,7 +293,7 @@ } } - discountExplain.setPostage(calculationPostage(receiveAddrId, discountExplain.getPayPrice())); + discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(),companyId)); //计算实际支付 discountExplain.setPayPrice(discountExplain.getPayPrice().add(discountExplain.getPostage())); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java index be14cdf..755f560 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesGroupServiceImpl.java @@ -8,7 +8,6 @@ import com.matrix.component.wechat.externalInterface.protocol.paramProtocol.BrandWCPayRequestData; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; -import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.constance.Dictionary; @@ -318,8 +317,9 @@ if (shopReceiveAddress == null) { throw new GlobleException("请选择正确的收获地址"); } - + BizUser user=redisUserLoginUtils.getLoginUser(BizUser.class); ShopOrder shopOrder = new ShopOrder(); + shopOrder.setCompanyId(user.getCompanyId()); shopOrder.setStoreId(Integer.parseInt(createGroupBuyDTO.getShopId().toString())); shopOrder.setOrderType(ShopOrder.ORDER_TYPE_SERVICE); @@ -389,7 +389,7 @@ shopOrder.setPayResult(ShopOrder.ORDER_WX_STATUS_WAIT_PAY); //如果没有提交购买方式或配送方式不是物流 //获取邮费 - BigDecimal postPrice = wxShopOrderService.calculationPostage(createGroupBuyDTO.getAddressId(), createGroupBuyDTO.getPrice()); + BigDecimal postPrice = wxShopOrderService.calculationPostage(createGroupBuyDTO.getPrice(),user.getCompanyId()); shopOrder.setPostage(postPrice); BigDecimal payPrice = createGroupBuyDTO.getPrice().multiply(BigDecimal.valueOf(createGroupBuyDTO.getCount())).add(shopOrder.getPostage()); shopOrder.setOrderMoney(payPrice); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java index bf2e433..1453dca 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopActivitiesSecKillServiceImpl.java @@ -126,6 +126,7 @@ } private ShopOrder createOrder(CreateSecKillDTO secKillDTO) { + BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(secKillDTO.getAddressId()); if (shopReceiveAddress == null) { throw new GlobleException("请选择正确的收获地址"); @@ -177,6 +178,7 @@ shopOrder.setUpdateBy("微信小程序生成"); shopOrder.setCommodityPrice(secKillDTO.getPrice()); shopOrder.setPurchaseQuantity(1); + shopOrder.setCompanyId(bizUser.getCompanyId()); //购买方式 shopOrder.setShippingMethod(secKillDTO.getShippingMethod()); //生成订单号 @@ -201,7 +203,7 @@ shopOrder.setPayResult(ShopOrder.ORDER_WX_STATUS_WAIT_PAY); //如果没有提交购买方式或配送方式不是物流 //获取邮费 - BigDecimal postPrice = wxShopOrderService.calculationPostage(secKillDTO.getAddressId(), secKillDTO.getPrice()); + BigDecimal postPrice = wxShopOrderService.calculationPostage(secKillDTO.getPrice(),bizUser.getCompanyId()); shopOrder.setPostage(postPrice); BigDecimal payPrice = secKillDTO.getPrice().multiply(BigDecimal.valueOf(secKillDTO.getCount())).add(shopOrder.getPostage()); shopOrder.setOrderMoney(payPrice); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java index e9fd5af..bf87285 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopCouponServiceImpl.java @@ -8,14 +8,8 @@ import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.system.common.constance.AppConstance; -import com.matrix.system.shopXcx.bean.ShopCoupon; -import com.matrix.system.shopXcx.bean.ShopCouponRecord; -import com.matrix.system.shopXcx.bean.ShopProductAttrRef; -import com.matrix.system.shopXcx.bean.ShopShoppingCart; -import com.matrix.system.shopXcx.dao.ShopCouponDao; -import com.matrix.system.shopXcx.dao.ShopCouponRecordDao; -import com.matrix.system.shopXcx.dao.ShopProductAttrRefDao; -import com.matrix.system.shopXcx.dao.ShopReceiveAddressDao; +import com.matrix.system.shopXcx.bean.*; +import com.matrix.system.shopXcx.dao.*; import com.matrix.system.shopXcx.api.service.WxShopCouponService; import com.matrix.system.shopXcx.api.tools.WxShopCouponUtil; import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil; @@ -51,13 +45,16 @@ @Autowired private WxShopCouponUtil wxShopCouponUtil; + @Autowired + private ShopProductDao productDao; + /** * 根据购物车选中的产品,计算合适的优惠券 * * @return */ - public List<CouponReceiveInfoVO> getCartVoCouponList(Long shopId,List<ShopShoppingCart> shopShoppingCarts) { + public List<CouponReceiveInfoVO> getCartVoCouponList(Long companyId,List<ShopShoppingCart> shopShoppingCarts) { //可用优惠券列表 List<CouponReceiveInfoVO> shopCoupons = new ArrayList<>(); @@ -65,7 +62,7 @@ BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); //1.找到用户所有的优惠券 - List<CouponReceiveInfoVO> userAllCoupon = shopCouponRecordDao.selectMyCouponByStatus(shopId, bizUser.getOpenId(), AppConstance.MY_COUPON_NOT_USE, + List<CouponReceiveInfoVO> userAllCoupon = shopCouponRecordDao.selectMyCouponByStatus(companyId, bizUser.getOpenId(), AppConstance.MY_COUPON_NOT_USE, null); if (CollectionUtils.isNotEmpty(userAllCoupon)) { //根据优惠力度排序,优惠力度大的先参与计算 @@ -215,20 +212,20 @@ * 根据订单状态查询优惠券列表 * * - * @param shopId + * @param companyId * @param status 1=已使用;2=未使用;3=过期 * @return */ @Override - public AjaxResult getMyCouponInfoByStatus(Long shopId, Integer status, PaginationVO pageVo) { + public AjaxResult getMyCouponInfoByStatus(Long companyId, Integer status, PaginationVO pageVo) { BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); // 如果查询使用或未使用状态的优惠券列表 if (AppConstance.MY_COUPON_USE.equals(status) || AppConstance.MY_COUPON_NOT_USE.equals(status)) { - List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyCouponByStatus(shopId,bizUser.getOpenId(), status, + List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyCouponByStatus(companyId,bizUser.getOpenId(), status, pageVo); return new AjaxResult(AjaxResult.STATUS_SUCCESS, list); } - List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyPastCoupon(shopId,bizUser.getOpenId(), pageVo); + List<CouponReceiveInfoVO> list = shopCouponRecordDao.selectMyPastCoupon(companyId,bizUser.getOpenId(), pageVo); return new AjaxResult(AjaxResult.STATUS_SUCCESS, list); } @@ -290,7 +287,8 @@ attrIds.addAll(ids); } } - List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds); + ShopProduct shopProduct = productDao.selectById(productId); + List<ShopCoupon> list = shopCouponDao.selectHdListByProductId(productId, attrIds,shopProduct.getCompanyId()); return list; } @@ -305,10 +303,10 @@ * @return */ @Override - public AjaxResult getCouponListByTag(String tag, Long shopId) { + public AjaxResult getCouponListByTag(String tag, Long companyId) { BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); boolean newPeople = wxShopCouponUtil.verifyIsNewPeople(bizUser.getOpenId()); - List<ShopCoupon> couponList = shopCouponDao.selectCouponListByTag(newPeople, bizUser.getOpenId(), tag,shopId); + List<ShopCoupon> couponList = shopCouponDao.selectCouponListByTag(newPeople, bizUser.getOpenId(), tag,companyId); AjaxResult res = new AjaxResult(AjaxResult.STATUS_SUCCESS, couponList); res.putInMap("isNewPeople", newPeople); return res; diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java index c5c1514..92cf088 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/api/service/impl/WxShopLogisticsQueryServiceImpl.java @@ -1,20 +1,18 @@ package com.matrix.system.shopXcx.api.service.impl; import com.alibaba.fastjson.JSON; -import com.matrix.core.constance.SystemErrorCode; +import com.matrix.component.tools.HttpCurlUtil; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.LogUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.constance.AppConstance; +import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; +import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo; import com.matrix.system.shopXcx.bean.ShopDeliveryInfo; import com.matrix.system.shopXcx.bean.ShopLogisticsInfo; import com.matrix.system.shopXcx.dao.ShopDeliveryInfoDao; import com.matrix.system.shopXcx.dao.ShopLogisticsInfoDao; -import com.matrix.component.tools.HttpCurlUtil; -import com.matrix.system.shopXcx.api.service.WxShopLogisticsQueryService; -import com.matrix.system.shopXcx.api.vo.LogisticsInfoVo; -import com.matrix.system.shopXcx.api.vo.SfLogisticsInfoVo; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -145,12 +143,11 @@ } } } else { - throw new GlobleException(SystemErrorCode.REQUEST_INVALID, logisticsInfoVo.getReason()); + throw new GlobleException(logisticsInfoVo.getReason()); } } catch (Exception e) { - LogUtil.error("物流信息查询失败", e); - throw new GlobleException(SystemErrorCode.REQUEST_INVALID); + throw new GlobleException("物流信息查询失败"); } List<ShopLogisticsInfo> shopLogisticsInfos = shopLogisticsInfoDao.selectByDelieryId(shopDeliveryInfo.getId()); result.setStatus(AjaxResult.STATUS_SUCCESS); diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java index 084115a..589f88f 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponDao.java @@ -45,7 +45,7 @@ @Param("productId") Integer productId, @Param("attrIds") List<String> attrIds); List<ShopCoupon> selectCouponListByTag(@Param("isNewPeople") boolean isNewPeople, @Param("userId") String userId, - @Param("tag") String tag,@Param("shopId") Long shopId); + @Param("tag") String tag,@Param("companyId") Long companyId); public int updateStateByStateAndIds(@Param("list") List<String> list, @Param("state") int state); @@ -55,7 +55,7 @@ ShopCoupon selectByIdAndUserId(@Param("id") Integer id, @Param("userId") String userId); - public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds); + public List<ShopCoupon> selectHdListByProductId(@Param("productId") Integer productId, @Param("attrIds") List<String> attrIds, @Param("companyId")Long companyId); ShopCoupon getCouponByTitle(@Param("title")String title, @Param("companyId")Long companyId); } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java index 6d46836..55c2850 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/dao/ShopCouponRecordDao.java @@ -43,9 +43,9 @@ CouponReceiveInfoVO selectMyCouponByReceiveId(@Param("receiveId") Integer receiveId); - List<CouponReceiveInfoVO> selectMyCouponByStatus(@Param("shopId") Long shopId, @Param("userId") String userId, @Param("status") Integer status, + List<CouponReceiveInfoVO> selectMyCouponByStatus(@Param("companyId") Long shopId, @Param("userId") String userId, @Param("status") Integer status, @Param("pageVo") PaginationVO pageVo); - List<CouponReceiveInfoVO> selectMyPastCoupon(@Param("shopId")Long shopId, @Param("userId") String userId, @Param("pageVo") PaginationVO pageVo); + List<CouponReceiveInfoVO> selectMyPastCoupon(@Param("companyId")Long shopId, @Param("userId") String userId, @Param("pageVo") PaginationVO pageVo); } \ No newline at end of file diff --git a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java index 88aab2e..2c9ff6d 100644 --- a/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java +++ b/zq-erp/src/main/java/com/matrix/system/shopXcx/mqTask/OrderTask.java @@ -26,7 +26,6 @@ import org.springframework.transaction.annotation.Transactional; import java.io.IOException; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -82,134 +81,146 @@ @Transactional(rollbackFor = Exception.class) public void createOrder(ShopOrder orderDto) { - BizUser bizUser = bizUserService.findByOpenId(orderDto.getUserId()); - SysOrder order = new SysOrder(); - SysVipInfo vipInfo = vipDao.selectByPhone(bizUser.getPhoneNumber()); - if(SysVipInfo.UNDEAL_VIP==vipInfo.getIsDeal()){ - //非成交客户下单更新客户为成交客户 - vipInfo.setIsDeal(SysVipInfo.DEAL_VIP); - vipDao.update(vipInfo); - } - - //获取订单归属门店 - order.setCompanyId(vipInfo.getCompanyId()); - order.setShopId(Long.parseLong(orderDto.getStoreId()+"")); - //同步的订单订单编号保持一致 - order.setOrderNo(orderDto.getOrderNo()); - order.setVipId(vipInfo.getId()); - order.setOrderTime(new Date()); - order.setRemark(AppConstance.WX_ORDER_FLAG); - order.setStaffId(vipInfo.getStaffId()); - order.setIsCross(2 + ""); - order.setStatu(Dictionary.ORDER_STATU_YFK); - order.setCardPay(0.00); - order.setCashPay(orderDto.getOrderMoney().doubleValue()); - order.setTotal(orderDto.getOrderMoney().doubleValue()); - order.setZkTotal(orderDto.getOrderMoney().doubleValue()); - order.setPayTime(new Date()); - order.setArrears(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("不存在需要同步的产品"); + } + } @@ -219,14 +230,14 @@ @Override public void handle(String consumerTag, Delivery message) throws IOException { - String orderId = new String(message.getBody(), "UTF-8"); - LogUtil.debug("收到创建订单任务orderId={}", orderId); - //获取订单信息 - ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); - //获取订单详情 - List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId)); - order.setDetails(orderDetails); - createOrder(order); + String orderId = new String(message.getBody(), "UTF-8"); + LogUtil.debug("收到创建订单任务orderId={}", orderId); + //获取订单信息 + ShopOrder order = shopOrderDao.selectById(Integer.valueOf(orderId)); + //获取订单详情 + List<ShopOrderDetails> orderDetails = shopOrderDetailsDao.selectByOrderId(Integer.valueOf(orderId)); + order.setDetails(orderDetails); + createOrder(order); } } diff --git a/zq-erp/src/main/resources/config/application.properties b/zq-erp/src/main/resources/config/application.properties index 258e194..0c7163b 100644 --- a/zq-erp/src/main/resources/config/application.properties +++ b/zq-erp/src/main/resources/config/application.properties @@ -4,13 +4,10 @@ #线上测试环境 -#spring.datasource.username=ct_test -#spring.datasource.password=123456 -#spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 +spring.datasource.username=ct_test +spring.datasource.password=123456 +spring.datasource.url=jdbc:mysql://120.27.238.55:3306/hive_test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL&allowMultiQueries=true&transformedBitIsBoolean=true&serverTimezone=GMT%2B8 -spring.datasource.username=chuhuan -spring.datasource.password=chuhuan -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 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml index 62b8923..4e833dc 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponDao.xml @@ -526,6 +526,7 @@ <result property="tag" column="tag"/> <result property="isUsing" column="is_using"/> <result property="kind" column="kind"/> + <result property="companyId" column="company_id"/> </resultMap> <select id="selectUsableCouponByProductInfo" resultMap="WxShopCouponMap"> @@ -561,7 +562,8 @@ select * from shop_coupon where - kind=2 and now() >= begin_time and end_time >= now() + company_id=#{companyId} + and kind=2 and now() >= begin_time and end_time >= now() and is_open = 1 and (is_all = 1 or ( @@ -584,7 +586,7 @@ ifnull(scr.is_using, 0) is_using from shop_coupon sc left join shop_coupon_record scr on sc.id = scr.c_id and user_id = #{userId} - where sc.shop_id=#{shopId} and sc.kind=1 and now() >= begin_time and end_time >= now() and is_open = 1 + where sc.company_id=#{companyId} and sc.kind=1 and now() >= begin_time and end_time >= now() and is_open = 1 <!--<if test="!isNewPeople">--> <!--and get_limit = 1--> <!--</if>--> diff --git a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml index 808f1a7..cbb939b 100644 --- a/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml +++ b/zq-erp/src/main/resources/mybatis/mapper/xcxShop/ShopCouponRecordDao.xml @@ -270,7 +270,7 @@ sc.min_amount minAmount, sc.offset_amount offsetAmount, sc.is_all isAll, sc.product_ids productIds, sc.attr_ids attrIds, scr.is_using isUsing from shop_coupon sc, shop_coupon_record scr - where sc.shop_id=#{shopId} and sc.id = scr.c_id and scr.user_id = #{userId} and is_using = #{status} + where sc.company_id=#{companyId} and sc.id = scr.c_id and scr.user_id = #{userId} and is_using = #{status} and is_open = 1 <if test="status == 2"> and now() >= begin_time and end_time >= now() @@ -296,7 +296,7 @@ sc.min_amount minAmount, sc.offset_amount offsetAmount, sc.is_all isAll, sc.product_ids productIds, sc.attr_ids attrIds, scr.is_using isUsing from shop_coupon sc, shop_coupon_record scr - where sc.shop_id=#{shopId} and sc.id = scr.c_id and scr.user_id = #{userId} + where sc.company_id=#{companyId} and sc.id = scr.c_id and scr.user_id = #{userId} and (isnull(order_id) or order_id = 0) and now() > end_time and is_open = 1 <if test="pageVo != null"><!-- 判断pageVo对象是否为空 --> diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html index d410873..7c83e1e 100644 --- a/zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html +++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopCoupon-form.html @@ -143,9 +143,14 @@ <!--<span class="text-danger">*</span>--> </label> <div class="col-sm-4"> - <input autocomplete="off" type="text" class="form-control" name="tag" - ignore="ignore" - th:value="${obj.tag}"nullmsg="优惠券名称不能为空"> + <select class="form-control" dataType="*" nullmsg="请选择" name="tag"> + <!-- <option value=''>请选择</option>--> + <option value='zqyhq' th:if="${obj.tag == 'zqyhq'}" selected>专区券</option> + <option value='zqyhq' th:unless="${obj.tag == 'zqyhq'}">专区券</option> + <option value='gmyhq' th:if="${obj.tag == 'gmyhq'}" selected>全场券</option> + <option value='gmyhq' th:unless="${obj.tag == 'gmyhq'}">全场券</option> + </select> + </div> </div> diff --git a/zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html b/zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html index 6f8ee2c..6001df2 100644 --- a/zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html +++ b/zq-erp/src/main/resources/templates/views/admin/shop/shopDeliveryInfo-list.html @@ -60,7 +60,7 @@ <div class="form-group mr-20 ml-20"> <span class="serch-title">物流公司:</span> <select class="form-control autoFull" style="width: 190px" - th:data-url="@{/wxapi/dataDictionary/getListByParentCode/kdgs}" data-value="typeCode" + th:data-url="@{/admin/customerDictionary/getListByParentCode/kdgs}" data-value="typeCode" data-filed="typeName" name="logisticsCompanyCode"> <option value=''>--请选择物流公司--</option> </select> -- Gitblit v1.9.1