| | |
| | | package com.matrix.system.shopXcx.api.action; |
| | | |
| | | import com.matrix.biz.bean.BizUser; |
| | | import com.matrix.component.asyncmessage.AsyncMessageManager; |
| | | import com.matrix.component.redis.RedisUserLoginUtils; |
| | | import com.matrix.component.tools.WxUtils; |
| | | import com.matrix.component.wechat.externalInterface.protocol.paramProtocol.BrandWCPayRequestData; |
| | | import com.matrix.component.wechat.externalInterface.weixinUtil.WeixinServiceUtil; |
| | | import com.matrix.core.constance.SystemErrorCode; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.LogUtil; |
| | | 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.bean.MoneyCardUse; |
| | | import com.matrix.system.hive.bean.MoneyCardUseFlow; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.MoneyCardUseDao; |
| | | import com.matrix.system.hive.dao.MoneyCardUseFlowDao; |
| | | import com.matrix.system.hive.dao.ShoppingGoodsDao; |
| | | import com.matrix.system.shopXcx.api.pojo.AddShopOrderPOJO; |
| | | import com.matrix.system.shopXcx.api.pojo.CreateOrderDto; |
| | | import com.matrix.system.hive.dao.SysVipInfoDao; |
| | | import com.matrix.system.score.dao.ScoreVipDetailDao; |
| | | import com.matrix.system.shopXcx.api.pojo.OrderInfoQueryPOJO; |
| | | import com.matrix.system.shopXcx.api.pojo.ShopOrderDto; |
| | | import com.matrix.system.shopXcx.api.service.OrderCouponGroupService; |
| | | 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.api.vo.ShopCartVo; |
| | | import com.matrix.system.shopXcx.bean.*; |
| | | import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoin; |
| | | import com.matrix.system.shopXcx.bean.ShopActivitiesGroupJoinUser; |
| | | import com.matrix.system.shopXcx.bean.ShopOrder; |
| | | import com.matrix.system.shopXcx.bean.ShopPayLog; |
| | | import com.matrix.system.shopXcx.dao.*; |
| | | import com.matrix.system.shopXcx.dto.DiscountExplain; |
| | | import org.apache.commons.collections.CollectionUtils; |
| | | import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | WxShopCouponService wxShopCouponService; |
| | | |
| | | @Autowired |
| | | private ShopReceiveAddressDao shopReceiveAddressDao; |
| | | |
| | | @Autowired |
| | | ShoppingCartService shoppingCartService; |
| | | |
| | | @Autowired |
| | | private ShopCouponDao shopCouponDao; |
| | | @Autowired |
| | | private WxShopCouponUtil wxShopCouponUtil; |
| | | |
| | | @Autowired |
| | | private RedisUserLoginUtils redisUserLoginUtils; |
| | |
| | | |
| | | @Autowired |
| | | ShopProductDao shopProductDao; |
| | | @Autowired |
| | | private WxShopOrderUtil wxShopOrderUtil; |
| | | |
| | | @Autowired |
| | | private ShopOrderDetailsDao shopOrderDetailsDao; |
| | | OrderCouponGroupService orderCouponGroupService; |
| | | |
| | | @Autowired |
| | | private ShopPayLogDao shopPayLogDao; |
| | | |
| | | @Autowired |
| | | ShopOrderDao shopOrderDao; |
| | | |
| | | @Autowired |
| | | SysVipInfoDao sysVipInfoDao; |
| | | |
| | | @Autowired |
| | | private ShopActivitiesGroupJoinUserDao shopActivitiesGroupJoinUserDao; |
| | | |
| | | @Autowired |
| | | private ShopActivitiesGroupJoinDao shopActivitiesGroupJoinDao; |
| | | |
| | | @Autowired |
| | | private AsyncMessageManager asyncMessageManager; |
| | | |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | |
| | | @Autowired |
| | | MoneyCardUseFlowDao moneyCardUseFlowDao; |
| | | |
| | | @Autowired |
| | | MoneyCardUseDao moneyCardUseDao; |
| | | |
| | | @Value("${evn}") |
| | | private String evn; |
| | | |
| | | /** |
| | | * 计算购物车订单价格 |
| | | * |
| | | * @param addShopOrderPOJO |
| | | * @param shopOrderDto |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @PostMapping(value = "/calculationCartOrder") |
| | | public |
| | | @ResponseBody |
| | | AjaxResult calculationCartOrder(@RequestBody AddShopOrderPOJO addShopOrderPOJO) throws Exception { |
| | | BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); //计算购物车中物品的优惠信息 |
| | | |
| | | List<ShopCartVo> cartList = shoppingCartService.findUserCartList(addShopOrderPOJO.getShopId()); |
| | | |
| | | |
| | | //取出购物车中选中的产品 |
| | | List<ShopShoppingCart> buyCart = new ArrayList<>(); |
| | | |
| | | //取出购物车中没有参加店铺活动的产品,和参加了店铺活动但是活动没有达到标准的产品,用来计算是否可以使用优惠券 |
| | | List<ShopShoppingCart> notCouponuyCart = new ArrayList<>(); |
| | | for (ShopCartVo shopCartVo : cartList) { |
| | | for (ShopShoppingCart shopShoppingCart : shopCartVo.getCartList()) { |
| | | if (shopShoppingCart.getIsSelected() == 1) { |
| | | buyCart.add(shopShoppingCart); |
| | | if (shopCartVo.getCoupon() == null || !shopCartVo.isSatisfactionCoupon()) { |
| | | notCouponuyCart.add(shopShoppingCart); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //获取当前购物车产品可用的优惠券 |
| | | List<CouponReceiveInfoVO> usefulCoupon = wxShopCouponService.getCartVoCouponList(addShopOrderPOJO.getShopId(),notCouponuyCart); |
| | | |
| | | //获取用户使用的优惠券 |
| | | CouponReceiveInfoVO shopCoupon = new CouponReceiveInfoVO(); |
| | | if (addShopOrderPOJO.getCouponReceiveId() == null) { |
| | | //如果用户没有选择优惠券则默认选优惠金额最高的 |
| | | //计算使用优惠券后的价格 |
| | | if (CollectionUtils.isNotEmpty(usefulCoupon)) { |
| | | //根据优惠券ID用户ID查询优惠券信息 |
| | | shopCoupon = usefulCoupon.get(0); |
| | | } |
| | | } else if (addShopOrderPOJO.getCouponReceiveId() != 1) { |
| | | //用户选择了优惠券 |
| | | shopCoupon = shopCouponRecordDao.selectMyCouponByReceiveId(addShopOrderPOJO.getCouponReceiveId()); |
| | | } else { |
| | | //用户不使用优惠券 |
| | | } |
| | | |
| | | |
| | | //计算收货地址: |
| | | |
| | | ShopReceiveAddress shopReceiveAddress = null; |
| | | if (addShopOrderPOJO.getReceiveAddrId() == null) { |
| | | //如果没有传收货地址则默认收货地址 |
| | | shopReceiveAddress = shopReceiveAddressDao.selectDefaultAddress(bizUser.getOpenId()); |
| | | if (shopReceiveAddress != null) { |
| | | addShopOrderPOJO.setReceiveAddrId(shopReceiveAddress.getAddrId()); |
| | | } |
| | | } else { |
| | | shopReceiveAddress = shopReceiveAddressDao.selectById(addShopOrderPOJO.getReceiveAddrId()); |
| | | addShopOrderPOJO.setReceiveAddrId(shopReceiveAddress.getAddrId()); |
| | | |
| | | } |
| | | |
| | | Integer addrId = null; |
| | | if (shopReceiveAddress != null) { |
| | | addrId = shopReceiveAddress.getAddrId(); |
| | | } |
| | | |
| | | //得到订单计价说明 |
| | | DiscountExplain discountExplain = shopOrderService.buildDiscountExplain(cartList, shopCoupon.getReceiveId(), addrId); |
| | | |
| | | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, buyCart, buyCart.size()); |
| | | //结算金额信息 |
| | | result.putInMap("discountExplain", discountExplain); |
| | | |
| | | |
| | | //用户优惠券 |
| | | result.putInMap("usefulCoupon", usefulCoupon); |
| | | //用户选中的优惠券 |
| | | result.putInMap("shopCoupon", shopCoupon); |
| | | |
| | | |
| | | //默认地址 |
| | | String deliverySelect = "立即配送"; |
| | | if (shopReceiveAddress != null) { |
| | | if (StringUtils.isNotBlank(shopReceiveAddress.getSchool())) { |
| | | deliverySelect = "立即配送"; |
| | | } else { |
| | | deliverySelect = "物流配送"; |
| | | } |
| | | } |
| | | result.putInMap("defaultAddress", shopReceiveAddress); |
| | | //配送方式 |
| | | result.putInMap("deliverySelect", deliverySelect); |
| | | |
| | | |
| | | result.setRows(buyCart); |
| | | return result; |
| | | AjaxResult calculationCartOrder(@RequestBody ShopOrderDto shopOrderDto) throws Exception { |
| | | return shopOrderService.buildDiscountExplain(shopOrderDto); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | private ScoreVipDetailDao scoreVipDetailDao; |
| | | |
| | | /** |
| | | * 新增订单 |
| | | * 新增微信支付订单 |
| | | * |
| | | * @param addShopOrderPOJO |
| | | * @param shopOrderDto |
| | | * @return |
| | | */ |
| | | @PostMapping(value = "/addShopOrder") |
| | | public |
| | | @ResponseBody |
| | | AjaxResult addShopOrder(@RequestBody AddShopOrderPOJO addShopOrderPOJO) throws Exception { |
| | | return shopOrderService.createShopOrder(addShopOrderPOJO); |
| | | } |
| | | AjaxResult addShopOrder(@RequestBody @Validated ShopOrderDto shopOrderDto) throws Exception { |
| | | |
| | | |
| | | /** |
| | | * 新增订单 |
| | | * 本方法抛弃,不再使用,本方法是单单个产品购买 |
| | | * 在多产品的时候不适合 |
| | | * @return |
| | | */ |
| | | @Deprecated |
| | | @PostMapping(value = "/addShopOrder2") |
| | | public |
| | | @ResponseBody |
| | | AjaxResult addShopOrder2(@RequestBody CreateOrderDto createOrderDto) throws Exception { |
| | | |
| | | |
| | | //校验收货地址 |
| | | ShopReceiveAddress shopReceiveAddress = shopReceiveAddressDao.selectById(createOrderDto.getReceiveAddrId()); |
| | | if (shopReceiveAddress == null) { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "请选择正确的收获地址"); |
| | | } |
| | | |
| | | |
| | | BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); |
| | | ShopSku shopSku = shopSkuDao.selectById(createOrderDto.getSkuId()); |
| | | ShopProduct shopProduct = shopProductDao.selectById(createOrderDto.getProductId()); |
| | | String stokCode = shopSku.getStockCode(); |
| | | |
| | | ShopOrder shopOrder = new ShopOrder(); |
| | | //查询绑定的产品是否为家居产品 |
| | | if (StringUtils.isNotBlank(stokCode)) { |
| | | ShoppingGoods shoppingGoods = shoppingGoodsDao.selectById(Long.parseLong(stokCode)); |
| | | if (shoppingGoods != null) { |
| | | //根据购买的产品设置订单类型 |
| | | if (Dictionary.SHOPPING_GOODS_TYPE_JJCP.equals(shoppingGoods.getGoodType())) { |
| | | shopOrder.setOrderType(ShopOrder.ORDER_TYPE_GOODS); |
| | | } else { |
| | | shopOrder.setOrderType(ShopOrder.ORDER_TYPE_SERVICE); |
| | | } |
| | | } else { |
| | | shopOrder.setOrderType(ShopOrder.ORDER_TYPE_GOODS); |
| | | } |
| | | } |
| | | |
| | | List<ShopOrderDetails> details = new ArrayList<>(); |
| | | Integer cartCount = 0; |
| | | ShopOrderDetails shopOrderDetails = new ShopOrderDetails(); |
| | | shopOrderDetails.setCreateBy(AppConstance.SYSTEM_USER); |
| | | shopOrderDetails.setUpdateBy(AppConstance.SYSTEM_USER); |
| | | shopOrderDetails.setpId(createOrderDto.getProductId()); |
| | | shopOrderDetails.setsId(createOrderDto.getSkuId()); |
| | | shopOrderDetails.setPrice(shopSku.getPrice()); |
| | | shopOrderDetails.setCount(createOrderDto.getNumber()); |
| | | shopOrderDetails.setsTitle(shopProduct.getTitle() + shopSku.getName()); |
| | | shopOrderDetails.setDiscountAmount(BigDecimal.ZERO); |
| | | shopOrderDetails.setTotalPrice(shopOrderDetails.getPrice().multiply(BigDecimal.valueOf(shopOrderDetails.getCount()))); |
| | | details.add(shopOrderDetails); |
| | | cartCount += shopOrderDetails.getCount(); |
| | | |
| | | |
| | | //TODO 更新库存和销量[考虑和erp库存联动] |
| | | wxShopOrderUtil.updateProductAndSkuInfo(details); |
| | | |
| | | //用户openId |
| | | shopOrder.setUserId(bizUser.getOpenId()); |
| | | shopOrder.setCreateBy("微信小程序生成"); |
| | | shopOrder.setUpdateBy("微信小程序生成"); |
| | | shopOrder.setCommodityPrice(shopOrderDetails.getTotalPrice()); |
| | | shopOrder.setPurchaseQuantity(cartCount); |
| | | //购买方式 |
| | | shopOrder.setShippingMethod("物流配送"); |
| | | //生成订单号 |
| | | shopOrder.setOrderNo(WxUtils.getOrderNum()); |
| | | //设置支付状态 |
| | | shopOrder.setPayStatus(ShopOrder.ORDER_STATUS_WAIT_PAY); |
| | | //设置订单状态 |
| | | shopOrder.setOrderStatus(ShopOrder.ORDER_STATUS_WAIT_SEND); |
| | | |
| | | //设置退款费用(注:下次优化从数据字典表获取) |
| | | shopOrder.setRefundCharge(BigDecimal.ZERO); |
| | | //客户电话 |
| | | shopOrder.setUserTel(shopReceiveAddress.getAddrTelephone()); |
| | | //客户姓名 |
| | | shopOrder.setUserName(shopReceiveAddress.getAddrLiaisonman()); |
| | | //备注 |
| | | shopOrder.setRemarks(createOrderDto.getRemarks()); |
| | | //删除标识 |
| | | shopOrder.setDelFlag(AppConstance.DATA_USEABLE); |
| | | //微信订单号 |
| | | shopOrder.setWxOrderNo(""); |
| | | //微信支付结果 |
| | | shopOrder.setPayResult(ShopOrder.ORDER_WX_STATUS_WAIT_PAY); |
| | | //如果没有提交购买方式或配送方式不是物流 |
| | | //获取邮费 |
| | | shopOrder.setOrderMoney(shopOrderDetails.getTotalPrice()); |
| | | shopOrder.setStoreId(createOrderDto.getShopId()); |
| | | |
| | | shopOrderDao.insert(shopOrder); |
| | | |
| | | wxShopOrderUtil.insertSendPackageInfo(shopOrder, "物流配送", shopReceiveAddress); |
| | | |
| | | //给订单详情表添加订单ID |
| | | shopOrderDetails.setOrderId(shopOrder.getId()); |
| | | |
| | | shopOrderDetailsDao.insert(shopOrderDetails); |
| | | |
| | | |
| | | BrandWCPayRequestData payData = startPayment(shopOrder); |
| | | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, Arrays.asList(payData)); |
| | | ShopOrder shopOrder = shopOrderService.createShopOrder(shopOrderDto); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance("订单创建成功"); |
| | | result.putInMap("orderId", shopOrder.getId()); |
| | | |
| | | if (shopOrderDto.getPayMethod().equals(ShopOrder.SHOP_ORDER_PAY_METHOD_WX)) { |
| | | BrandWCPayRequestData payData = shopOrderService.startPayment(shopOrder); |
| | | result.setRows(Arrays.asList(payData)); |
| | | } |
| | | return result; |
| | | |
| | | |
| | | } |
| | | |
| | | @Value("${wx_pay_debug_onoff}") |
| | | private boolean isDebug; |
| | | @Autowired |
| | | private WeixinServiceUtil weixinServiceUtil; |
| | | |
| | | |
| | | /** |
| | | * 开始付款 |
| | | * 余额支付确认 |
| | | * |
| | | * @param shopOrder |
| | | * @param orderId |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public BrandWCPayRequestData startPayment(ShopOrder shopOrder) throws Exception { |
| | | BigDecimal unit = new BigDecimal("100"); |
| | | BigDecimal money = new BigDecimal(shopOrder.getOrderMoney().toString()); |
| | | BrandWCPayRequestData payData; |
| | | String productNames = wxShopOrderUtil.getProductNames(shopOrder.getUserId(), shopOrder.getId()); |
| | | if (isDebug) { |
| | | payData = weixinServiceUtil.createOrder("[测试]" + productNames, shopOrder.getOrderNo(), |
| | | 1, shopOrder.getUserId(), String.valueOf(shopOrder.getId())); |
| | | @GetMapping(value = "/moneyCardPay/{orderId}") |
| | | @ResponseBody |
| | | @Transactional |
| | | public AjaxResult moneyCardPay(@PathVariable Integer orderId) throws Exception { |
| | | |
| | | ShopOrder order = shopOrderDao.selectById(orderId); |
| | | if (order != null |
| | | && ShopOrder.SHOP_ORDER_PAY_METHOD_VIPCARD == order.getPayMethod() |
| | | && ShopOrder.ORDER_PAY_STATUS_WAIT == order.getPayStatus()) { |
| | | |
| | | MoneyCardUse moneyCardUse = moneyCardUseDao.selectVipCard(order.getUserId()); |
| | | Double balance=moneyCardUse.getGiftMoney() + moneyCardUse.getRealMoney(); |
| | | if(balance>=order.getOrderMoney().doubleValue()){ |
| | | //扣减会员卡余额 |
| | | if(moneyCardUse.getRealMoney()>=order.getOrderMoney().doubleValue()){ |
| | | moneyCardUse.setRealMoney(moneyCardUse.getRealMoney()-order.getOrderMoney().doubleValue()); |
| | | }else{ |
| | | moneyCardUse.setGiftMoney(moneyCardUse.getGiftMoney()-(order.getOrderMoney().doubleValue()- moneyCardUse.getRealMoney() )); |
| | | moneyCardUse.setRealMoney(0D); |
| | | } |
| | | moneyCardUseDao.update(moneyCardUse); |
| | | //插入扣减记录 |
| | | MoneyCardUseFlow moneyCardUseFlow=new MoneyCardUseFlow(); |
| | | moneyCardUseFlow.setTotal(order.getOrderMoney().doubleValue()); |
| | | moneyCardUseFlow.setCarUseId(moneyCardUse.getId()); |
| | | moneyCardUseFlow.setVipId(order.getUserId()); |
| | | moneyCardUseFlow.setType(MoneyCardUseFlow.USE_TYPE_CONSUMER); |
| | | moneyCardUseFlow.setOrderNo(order.getOrderNo()); |
| | | moneyCardUseFlow.setCreateTime(new Date()); |
| | | moneyCardUseFlow.setBalance(moneyCardUse.getGiftMoney()+moneyCardUse.getRealMoney()); |
| | | moneyCardUseFlow.setCardName(moneyCardUse.getCardName()); |
| | | moneyCardUseFlowDao.insert(moneyCardUseFlow); |
| | | |
| | | //构建需要修改订单信息Map |
| | | Map<String, Object> modifyMap = new HashMap<>(); |
| | | modifyMap.put("id", order.getId()); |
| | | //设置微信支付状态为已支付 |
| | | modifyMap.put("payResult", ShopOrder.ORDER_WX_STATUS_PAY_SUCCESS); |
| | | //设置支付状态为支付成功 |
| | | modifyMap.put("payStatus", ShopOrder.ORDER_PAY_STATUS_SUCCESS); |
| | | //如果是商品订单则进入待发货 |
| | | modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_WAIT_SEND); |
| | | shopOrderDao.updateByMap(modifyMap); |
| | | |
| | | // 判断该订单是否为拼团产生的订单 |
| | | ShopActivitiesGroupJoinUser joinUser = shopActivitiesGroupJoinUserDao.selectGroupJoinUserByOrderId(order.getId().longValue()); |
| | | if (joinUser != null) { |
| | | joinUser.setIsHasPay(ShopActivitiesGroupJoinUser.IS_HAS_PAY_Y); |
| | | shopActivitiesGroupJoinUserDao.updateByModel(joinUser); |
| | | |
| | | ShopActivitiesGroupJoin groupJoin = shopActivitiesGroupJoinDao.selectGroupAndPriceById(joinUser.getGjId()); |
| | | List<ShopActivitiesGroupJoinUser> joinUserList = shopActivitiesGroupJoinUserDao.selectGroupJoinUserListByGjId(joinUser.getGjId()); |
| | | LogUtil.info("#当前已支付完成:{}#", joinUserList.size()); |
| | | // 若拼团中已支付的数量等于几人团预设值,则更新拼团状态为拼团成功 |
| | | if (groupJoin.getGroupPrice().getGpCount() == joinUserList.size()) { |
| | | groupJoin.setGjStatus(ShopActivitiesGroupJoin.ACTIVITIES_JOIN_SUCCESS); |
| | | } else { |
| | | if (joinUser.getUserId().equals(groupJoin.getGjHeadId())) { |
| | | groupJoin.setGjStatus(ShopActivitiesGroupJoin.ACTIVITIES_JOIN_ING); |
| | | } |
| | | } |
| | | shopActivitiesGroupJoinDao.updateByModel(groupJoin); |
| | | |
| | | SysVipInfo sysVipInfo = sysVipInfoDao.selectByPhone(order.getUserTel(),order.getCompanyId()); |
| | | if (sysVipInfo != null) { |
| | | sysVipInfo.setIsDeal(SysVipInfo.DEAL_VIP); |
| | | sysVipInfoDao.update(sysVipInfo); |
| | | } |
| | | } |
| | | |
| | | // 根据订单类型创建不同的处理任务 |
| | | asyncMessageManager.sendMsg(AsyncMessageRouting.CREATE_ORDER ,"orderId=%s",orderId); |
| | | |
| | | //支付记录 |
| | | recordPayLog(Integer.valueOf(orderId), 1, order.getOrderNo(), order.getOrderMoney(), "会员卡余额支付成功", ShopOrder.ORDER_PAY_STATUS_SUCCESS); |
| | | |
| | | return AjaxResult.buildSuccessInstance("支付成功"); |
| | | |
| | | }else{ |
| | | return AjaxResult.buildFailInstance("会员卡余额不足"); |
| | | } |
| | | |
| | | } else { |
| | | payData = weixinServiceUtil.createOrder(productNames, shopOrder.getOrderNo(), |
| | | unit.multiply(money).intValue(), shopOrder.getUserId(), String.valueOf(shopOrder.getId())); |
| | | LogUtil.info("订单状态不为待付款,order status=", order.getOrderStatus()); |
| | | return AjaxResult.buildFailInstance("订单不支持本次结算"); |
| | | } |
| | | ShopOrder updateParam = new ShopOrder(); |
| | | updateParam.setId(shopOrder.getId()); |
| | | updateParam.setWxOrderNo(payData.getPrepay_id()); |
| | | shopOrderDao.updateByModel(updateParam); |
| | | return payData; |
| | | |
| | | } |
| | | |
| | | |
| | | private void recordPayLog(Integer orderId, Integer type, String orderNo, BigDecimal payMoney, String payRemark, int payStatus) { |
| | | //设置支付类型为收款 |
| | | ShopPayLog payLog = new ShopPayLog(); |
| | | payLog.setPayType(type); |
| | | payLog.setJoinId(orderId); |
| | | payLog.setPayMoney(payMoney); |
| | | payLog.setPayOrderNo(orderNo); |
| | | payLog.setPayRemark(payRemark); |
| | | payLog.setPayStatus(payStatus); |
| | | payLog.setCreateBy(AppConstance.SYSTEM_USER); |
| | | payLog.setUpdateBy(AppConstance.SYSTEM_USER); |
| | | shopPayLogDao.insert(payLog); |
| | | } |
| | | |
| | | |
| | |
| | | @GetMapping(value = "/getOrderStatusCount") |
| | | @ResponseBody |
| | | public AjaxResult getOrderStatusCount() { |
| | | BizUser bizUser = redisUserLoginUtils.getLoginUser(BizUser.class); |
| | | SysVipInfo sysVipInfo = redisUserLoginUtils.getLoginUser(SysVipInfo.class); |
| | | AjaxResult result = AjaxResult.buildSuccessInstance( |
| | | shopOrderDao.selectOrderStatusCount(bizUser.getOpenId())); |
| | | shopOrderDao.selectOrderStatusCount(sysVipInfo.getId())); |
| | | return result; |
| | | } |
| | | |