| | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.component.rabbitmq.RabiitMqTemplate; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.component.tools.WxUtils; |
| | |
| | | import com.matrix.system.common.dao.BusParameterSettingsDao; |
| | | import com.matrix.system.common.dao.CustomerDataDictionaryDao; |
| | | import com.matrix.system.common.interceptor.HostInterceptor; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsDao; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.score.dao.ScoreVipDetailDao; |
| | |
| | | import com.matrix.system.shopXcx.api.service.ShoppingCartService; |
| | | import com.matrix.system.shopXcx.api.service.WXShopOrderService; |
| | | import com.matrix.system.shopXcx.api.service.WxShopCouponService; |
| | | import com.matrix.system.shopXcx.api.tools.WxShopCouponUtil; |
| | | import com.matrix.system.shopXcx.api.tools.WxShopOrderUtil; |
| | | import com.matrix.system.shopXcx.api.vo.CouponReceiveInfoVO; |
| | | import com.matrix.system.shopXcx.bean.*; |
| | |
| | | @Autowired |
| | | private WxShopOrderUtil wxShopOrderUtil; |
| | | @Autowired |
| | | private WxShopCouponUtil wxShopCouponUtil; |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | | @Autowired |
| | | private WeixinServiceUtil weixinServiceUtil; |
| | |
| | | private ShopOrderDao shopOrderDao; |
| | | @Autowired |
| | | private ShopOrderDetailsDao shopOrderDetailsDao; |
| | | @Autowired |
| | | private ShopCouponDao shopCouponDao; |
| | | @Autowired |
| | | private ShopProductDao shopProductDao; |
| | | @Autowired |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public AjaxResult createShopOrder(ShopOrderDto shopOrderDto) throws Exception { |
| | | public ShopOrder createShopOrder(ShopOrderDto shopOrderDto) throws Exception { |
| | | SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | |
| | | |
| | | //校验收货地址 |
| | | |
| | | ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(shopOrderDto.getReceiveAddrId()); |
| | | if (shopReceiveAddress == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "请选择正确的收获地址"); |
| | | } |
| | | |
| | | |
| | | //计算订单优惠信息 |
| | | AjaxResult caculateResult= buildDiscountExplain(shopOrderDto); |
| | | DiscountExplain discountExplain= (DiscountExplain) caculateResult.getMapInfo().get("discountExplain"); |
| | | |
| | | if(discountExplain.getScorePay()!=null){ |
| | | //校验用户积分是否够用 |
| | | int score=scoreVipDetailDao.selectUserTotalScore(sysVipInfo.getId()); |
| | | if(score<discountExplain.getScorePay()){ |
| | | return AjaxResult.buildFailInstance("积分不足"); |
| | | throw new GlobleException("积分不足"); |
| | | } |
| | | } |
| | | |
| | | |
| | | ShopOrder shopOrder = new ShopOrder(); |
| | | shopOrder.setCompanyId(sysVipInfo.getCompanyId()); |
| | |
| | | shopOrder.setUserId(sysVipInfo.getId()); |
| | | shopOrder.setCreateBy("微信小程序生成"); |
| | | shopOrder.setUpdateBy("微信小程序生成"); |
| | | shopOrder.setPayMethod(shopOrderDto.getPayMethod()); |
| | | shopOrder.setCommodityPrice(discountExplain.getBillPrice()); |
| | | shopOrder.setPurchaseQuantity(orderCount); |
| | | shopOrder.setOrderType(ShopOrder.ORDER_TYPE_GOODS); |
| | |
| | | |
| | | |
| | | |
| | | BrandWCPayRequestData payData = startPayment(shopOrder); |
| | | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(payData)); |
| | | result.putInMap("orderId", shopOrder.getId()); |
| | | |
| | | return result; |
| | | return shopOrder; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | |
| | | //计算运费 |
| | | discountExplain.setPostage(calculationPostage(discountExplain.getPayPrice(), HostInterceptor.getCompanyId())); |
| | | |
| | | |
| | | if(ShopOrder.SHIPPING_METHOD_WL==shopOrderDto.getDeliverySelect()){ |
| | | discountExplain.setPostage(calculationPostage(billPrice, HostInterceptor.getCompanyId())); |
| | | }else{ |
| | | discountExplain.setPostage(BigDecimal.ZERO); |
| | | } |
| | | |
| | | //账单总金额 |
| | | discountExplain.setBillPrice(billPrice.add(discountExplain.getPostage())); |
| | |
| | | @Override |
| | | public AjaxResult orderSettlement(int orderId) throws Exception { |
| | | ShopOrder shopOrder = shopOrderDao.selectById(orderId); |
| | | |
| | | if (shopOrder == null) { |
| | | throw new GlobleException("订单不存在!"); |
| | | return AjaxResult.buildFailInstance("订单不存在!"); |
| | | } |
| | | if (ShopOrder.SHOP_ORDER_PAY_METHOD_WX != shopOrder.getPayMethod()) { |
| | | return AjaxResult.buildFailInstance("支付方式错误"); |
| | | } |
| | | if (!shopOrder.getPayResult().equals(ShopOrder.ORDER_PAY_STATUS_WAIT)) { |
| | | throw new GlobleException("该订单不是待支付状态!"); |
| | | return AjaxResult.buildFailInstance("该订单不是待支付状态!"); |
| | | } |
| | | |
| | | if(shopOrder.getScorePay()!=null){ |