| | |
| | | import com.ruoyi.system.utils.wx.WxProperties; |
| | | import com.ruoyi.system.vo.MyPushCompanyListVo; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.core.annotation.OrderUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Propagation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.InetAddress; |
| | | import java.net.MalformedURLException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Resource |
| | | private WxPayService wxPayService; |
| | | |
| | | |
| | | @Autowired |
| | | private TbSystemConfigService configService; |
| | | |
| | |
| | | @Autowired |
| | | private TbMessageService messageService; |
| | | |
| | | @Autowired |
| | | private TbShareholderService shareholderService; |
| | | |
| | | |
| | | @Override |
| | | public Page<MyPushCompanyListVo> getMyOrderList(MyOrderListQuery query, Long userId) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | public HashMap<String, Object> getMyOrderListNum(Long userId, HashMap<String, Object> map) { |
| | | List<MyPushCompanyListVo> list = this.baseMapper.getMyOrderListNum(userId); |
| | | map.put("toBeConfirmed", list.stream().filter(e -> e.getStatus() == 2).count()); |
| | | map.put("pendingPayment", list.stream().filter(e -> e.getStatus() == 3).count()); |
| | | map.put("processing", list.stream().filter(e -> e.getStatus() == 4).count()); |
| | | map.put("completed", list.stream().filter(e -> e.getStatus() == 6).count()); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public WxPayMpOrderResult payOrder(TbOrder tbOrder, Long userId) { |
| | | WxPayMpOrderResult result = this.createWxOrderToWxService(tbOrder.getUserId(),tbOrder.getOrderNo(),tbOrder.getPrice(),"购买商品", ""); |
| | | TbUser user = userService.getById(userId); |
| | | WxPayMpOrderResult result = this.createWxOrderToWxService(user.getOpenId(),tbOrder.getOrderNo(),tbOrder.getPrice(),"购买商品", ""); |
| | | return result; |
| | | } |
| | | |
| | |
| | | if (order!=null) { |
| | | order.setStatus(4); |
| | | order.setPayTime(new Date()); |
| | | order.setOutTradeNo(notifyResult.getTransactionId()); |
| | | order.setOutTradeNo(notifyResult.getOutTradeNo()); |
| | | order.setTransactionId(notifyResult.getTransactionId()); |
| | | TbCompany company = companyService.getById(order.getCompanyId()); |
| | | // 生成记录 看是否分佣 金额 |
| | | TbUser user = userService.getById(company.getUserId()); |
| | |
| | | BigDecimal userCommissionMoney = divide1.multiply(price).setScale(2, RoundingMode.HALF_UP); |
| | | order.setCommissionPrice(userCommissionMoney); |
| | | } |
| | | order.setShare_user_id(user.getInviteId()); |
| | | order.setShareUserId(user.getInviteId()); |
| | | order.setCommissionPlatform(platformCommissionMoney); |
| | | } |
| | | order.updateById(); |
| | |
| | | |
| | | messageService.addMessage("下单成功,请及时发送快递", order.getUserId(),order.getId()); |
| | | messageService.addMessage("您发布的订单买家已支付,请尽快处理!", company.getUserId(),order.getId()); |
| | | return "<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>"; |
| | | } |
| | | return null; |
| | | |
| | | |
| | | return "<xml> <return_code><![CDATA[SUCCESS]]></return_code> <return_msg><![CDATA[OK]]></return_msg> </xml>"; |
| | | } |
| | | |
| | | @Override |
| | | public void commission(TbOrder order,String userId) { |
| | | String shareUserId = order.getShare_user_id(); |
| | | String shareUserId = order.getShareUserId(); |
| | | if(StringUtils.isNotEmpty(shareUserId)){ |
| | | TbUser shareUser = userService.getById(shareUserId); |
| | | BigDecimal add = shareUser.getBalance().add(order.getCommissionPrice()); |
| | |
| | | user.setBalance(add); |
| | | user.updateById(); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | | public void lastPayOrderData(TbOrder tbOrder, AddBuyerCompanyInfoDto dto, Long userId,TbCompany company) { |
| | | public void lastPayOrderData(TbOrder tbOrder, AddBuyerCompanyInfoDto dto, Long userId,TbCompany company, TbBuyerCompanyInfo one) { |
| | | TbBuyerCompanyInfo tbBuyerCompanyInfo = new TbBuyerCompanyInfo(); |
| | | BeanUtils.copyProperties(dto,tbBuyerCompanyInfo); |
| | | if(one!=null){ |
| | | tbBuyerCompanyInfo.setId(one.getId()); |
| | | } |
| | | tbBuyerCompanyInfo.setOrderId(tbOrder.getId()); |
| | | List<TbShareholder> shareholders = dto.getShareholders(); |
| | | |
| | |
| | | addDay = addDay+company.getRelocationAreaDay(); |
| | | } |
| | | // 更新订单金额 |
| | | if(addMoney.compareTo(BigDecimal.ZERO)>0){ |
| | | BigDecimal add = tbOrder.getPrice().add(addMoney); |
| | | tbOrder.setPrice(add); |
| | | tbOrder.updateById(); |
| | | } |
| | | BigDecimal add = company.getSaleMoney().add(addMoney); |
| | | tbOrder.setPrice(add); |
| | | tbOrder.setOrderNo(OrderUtil.getOrderNoForPrefix("ZSX")); |
| | | tbOrder.updateById(); |
| | | |
| | | if(addDay>0){ |
| | | tbBuyerCompanyInfo.setAddDay(addDay); |
| | | } |
| | | tbBuyerCompanyInfo.insert(); |
| | | tbBuyerCompanyInfo.insertOrUpdate(); |
| | | |
| | | shareholderService.remove(new LambdaQueryWrapper<TbShareholder>().eq(TbShareholder::getOrderId, tbOrder.getId())); |
| | | for (TbShareholder shareholder : shareholders) { |
| | | shareholder.setOrderId(tbOrder.getId()); |
| | | shareholder.insert(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | wxPayUnifiedOrderRequest.setBody("购买商品"); |
| | | wxPayUnifiedOrderRequest.setOutTradeNo(outTradeNo); |
| | | wxPayUnifiedOrderRequest.setTotalFee(amountInFen);// 元转成分 |
| | | wxPayUnifiedOrderRequest.setOpenid(openId); |
| | | wxPayUnifiedOrderRequest.setSpbillCreateIp( |
| | | InetAddress.getLoopbackAddress().getHostAddress()); |
| | | wxPayUnifiedOrderRequest.setTradeType("JSAPI"); |
| | | wxPayUnifiedOrderRequest.setNotifyUrl( |
| | | wxProperties.getNotifyUrl() +"mall-hotel-order/WX/callback"); |
| | | wxProperties.getNotifyUrl()); |
| | | WxPayMpOrderResult result = wxPayService.createOrder(wxPayUnifiedOrderRequest); |
| | | |
| | | return result; |