| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | List<ShopCartVo> cartList = shoppingCartService.findUserCartList(addShopOrderPOJO.getShopId()); |
| | | List<ShopCartVo> cartList = shoppingCartService.findUserCartList(addShopOrderPOJO.getShopId(),ShopShoppingCart.CAR_TYPE_MICRO); |
| | | //购物车不能为空 |
| | | if (CollectionUtils.isEmpty(cartList)) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "请选择您需要购买的产品"); |
| | |
| | | } |
| | | |
| | | //计算订单优惠信息 |
| | | 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())); |