| | |
| | | import com.github.binarywang.wxpay.service.WxPayService; |
| | | import com.ruoyi.common.utils.OrderUtil; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.dto.AddBuyerCompanyInfoDto; |
| | | import com.ruoyi.system.mapper.TbOrderMapper; |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.MyOrderListQuery; |
| | | import com.ruoyi.system.service.TbOrderService; |
| | | import com.ruoyi.system.service.TbSystemConfigService; |
| | | import com.ruoyi.system.service.TbUserService; |
| | | import com.ruoyi.system.service.*; |
| | | 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 java.net.InetAddress; |
| | | import java.net.MalformedURLException; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | |
| | |
| | | @Autowired |
| | | private TbUserService userService; |
| | | |
| | | @Autowired |
| | | private TbCompanyService companyService; |
| | | |
| | | @Autowired |
| | | private TbMessageService messageService; |
| | | |
| | | |
| | | @Override |
| | | public Page<MyPushCompanyListVo> getMyOrderList(MyOrderListQuery query, Long userId) { |
| | |
| | | tbOrder.setOrderNo( OrderUtil.getOrderNoForPrefix("ZSX")); |
| | | tbOrder.setStatus(2); |
| | | tbOrder.setPrice(company.getSaleMoney()); |
| | | |
| | | // 生成记录 看是否分佣 金额 |
| | | TbUser user = userService.getById(company.getUserId()); |
| | | TbSystemConfig config = configService.getOne(new LambdaQueryWrapper<TbSystemConfig>().eq(TbSystemConfig::getType, 3)); |
| | | |
| | | if(config!=null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(config.getContent()); |
| | | BigDecimal platformCommission = new BigDecimal(jsonObject.get("platform").toString()); |
| | | BigDecimal userCommission = new BigDecimal(jsonObject.get("user").toString()); |
| | | BigDecimal price = tbOrder.getPrice(); |
| | | BigDecimal divide = platformCommission.divide(new BigDecimal("100")); |
| | | BigDecimal platformCommissionMoney = divide.multiply(price).setScale(2, RoundingMode.HALF_UP); |
| | | if(StringUtils.isNotEmpty(user.getInviteId()) && user.getInviteNum()>0){ |
| | | BigDecimal divide1 = userCommission.divide(new BigDecimal("100")); |
| | | BigDecimal userCommissionMoney = divide1.multiply(price).setScale(2, RoundingMode.HALF_UP); |
| | | tbOrder.setCommissionPrice(userCommissionMoney); |
| | | } |
| | | tbOrder.setShare_user_id(user.getInviteId()); |
| | | tbOrder.setCommissionPlatform(platformCommissionMoney); |
| | | } |
| | | tbOrder.insert(); |
| | | |
| | | |
| | | // 生成记录 |
| | | TbAccountDetail tbAccountDetail = new TbAccountDetail(); |
| | | tbAccountDetail.setUserId(company.getUserId()); |
| | | tbAccountDetail.setType(1); |
| | | tbAccountDetail.setCategory(2); |
| | | tbAccountDetail.setStatus(1); |
| | | BigDecimal subtract = tbOrder.getPrice().subtract(tbOrder.getCommissionPrice()).subtract(tbOrder.getCommissionPlatform()); |
| | | tbAccountDetail.setMoney(subtract); |
| | | tbAccountDetail.setOrderId(tbOrder.getId()); |
| | | tbAccountDetail.insert(); |
| | | |
| | | company.setStatus(4); |
| | | company.updateById(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (order!=null) { |
| | | order.setStatus(4); |
| | | order.setPayTime(new Date()); |
| | | order.setOutTradeNo(notifyResult.getTransactionId()); |
| | | TbCompany company = companyService.getById(order.getCompanyId()); |
| | | // 生成记录 看是否分佣 金额 |
| | | TbUser user = userService.getById(company.getUserId()); |
| | | TbSystemConfig config = configService.getOne(new LambdaQueryWrapper<TbSystemConfig>().eq(TbSystemConfig::getType, 3)); |
| | | if(config!=null){ |
| | | JSONObject jsonObject = JSONObject.parseObject(config.getContent()); |
| | | BigDecimal platformCommission = new BigDecimal(jsonObject.get("platform").toString()); |
| | | BigDecimal userCommission = new BigDecimal(jsonObject.get("user").toString()); |
| | | BigDecimal price = order.getPrice(); |
| | | BigDecimal divide = platformCommission.divide(new BigDecimal("100")); |
| | | BigDecimal platformCommissionMoney = divide.multiply(price).setScale(2, RoundingMode.HALF_UP); |
| | | if(StringUtils.isNotEmpty(user.getInviteId()) && user.getInviteNum()>0){ |
| | | BigDecimal divide1 = userCommission.divide(new BigDecimal("100")); |
| | | BigDecimal userCommissionMoney = divide1.multiply(price).setScale(2, RoundingMode.HALF_UP); |
| | | order.setCommissionPrice(userCommissionMoney); |
| | | } |
| | | order.setShare_user_id(user.getInviteId()); |
| | | order.setCommissionPlatform(platformCommissionMoney); |
| | | } |
| | | order.updateById(); |
| | | |
| | | // 生成记录 |
| | | TbAccountDetail tbAccountDetail = new TbAccountDetail(); |
| | | tbAccountDetail.setUserId(company.getUserId()); |
| | | tbAccountDetail.setType(1); |
| | | tbAccountDetail.setCategory(2); |
| | | tbAccountDetail.setStatus(1); |
| | | BigDecimal subtract = order.getPrice().subtract(order.getCommissionPrice()).subtract(order.getCommissionPlatform()); |
| | | tbAccountDetail.setMoney(subtract); |
| | | tbAccountDetail.setOrderId(order.getId()); |
| | | tbAccountDetail.insert(); |
| | | |
| | | // 生成记录 |
| | | TbAccountDetail tbAccountDetail1 = new TbAccountDetail(); |
| | | tbAccountDetail1.setUserId(order.getUserId()); |
| | | tbAccountDetail1.setType(2); |
| | | tbAccountDetail1.setCategory(5); |
| | | tbAccountDetail1.setStatus(2); |
| | | tbAccountDetail1.setMoney(order.getPrice()); |
| | | tbAccountDetail1.setOrderId(order.getId()); |
| | | tbAccountDetail1.insert(); |
| | | |
| | | |
| | | 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>"; |
| | | } |
| | | |
| | |
| | | BigDecimal add = shareUser.getBalance().add(order.getCommissionPrice()); |
| | | shareUser.setBalance(add); |
| | | shareUser.updateById(); |
| | | |
| | | |
| | | TbAccountDetail accountDetail = new TbAccountDetail(); |
| | | accountDetail.setUserId(shareUserId); |
| | |
| | | user.updateById(); |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
| | | public void lastPayOrderData(TbOrder tbOrder, AddBuyerCompanyInfoDto dto, Long userId,TbCompany company) { |
| | | TbBuyerCompanyInfo tbBuyerCompanyInfo = new TbBuyerCompanyInfo(); |
| | | BeanUtils.copyProperties(dto,tbBuyerCompanyInfo); |
| | | tbBuyerCompanyInfo.setOrderId(tbOrder.getId()); |
| | | List<TbShareholder> shareholders = dto.getShareholders(); |
| | | |
| | | BigDecimal addMoney=BigDecimal.ZERO; |
| | | int addDay=0; |
| | | // 判断是否需要支付改名费 迁区费 |
| | | if(dto.getNeedRename()==1){ |
| | | addMoney = company.getRenameMoney(); |
| | | addDay=company.getRenameDay(); |
| | | } |
| | | if(dto.getNewDistrict()==1){ |
| | | addMoney = addMoney.add(company.getRelocationAreaMoney()); |
| | | addDay = addDay+company.getRelocationAreaDay(); |
| | | } |
| | | // 更新订单金额 |
| | | if(addMoney.compareTo(BigDecimal.ZERO)>0){ |
| | | BigDecimal add = tbOrder.getPrice().add(addMoney); |
| | | tbOrder.setPrice(add); |
| | | tbOrder.updateById(); |
| | | } |
| | | if(addDay>0){ |
| | | tbBuyerCompanyInfo.setAddDay(addDay); |
| | | } |
| | | tbBuyerCompanyInfo.insert(); |
| | | for (TbShareholder shareholder : shareholders) { |
| | | shareholder.setOrderId(tbOrder.getId()); |
| | | shareholder.insert(); |
| | | } |
| | | } |
| | | |
| | | |