套娃生成待补单,退款待补单

This commit is contained in:
曹磊 2024-06-21 14:47:16 +08:00
parent 2346d8e735
commit 000d901f00
1 changed files with 290 additions and 265 deletions

View File

@ -1662,149 +1662,162 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
private Result cancelSupplementMassageOrders(Long userId, Orders orders, Integer isAuto, Integer type) { private Result cancelSupplementMassageOrders(Long userId, Orders orders, Integer isAuto, Integer type) {
if(type == 1){ if(type == 1){
//退车费或扣车费成为待补单 if(orders.getTaxiMoney().compareTo(BigDecimal.ZERO) != 0){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //退车费或扣车费成为待补单
String time = simpleDateFormat.format(new Date()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//退款金额 String time = simpleDateFormat.format(new Date());
BigDecimal userMoney = BigDecimal.ZERO; //退款金额
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); BigDecimal userMoney = BigDecimal.ZERO;
if(isAuto == 0){ UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
//退款车费 if(isAuto == 0){
userMoney = orders.getTaxiMoney(); //退款车费
if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) { userMoney = orders.getTaxiMoney();
boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), userMoney, orders.getPayWay()); if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) {
if (!refund) { boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), userMoney, orders.getPayWay());
return Result.error("退款失败,请联系客服!"); if (!refund) {
} return Result.error("退款失败,请联系客服!");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else if (orders.getPayWay() == 6) {
String data = aliPayController.alipayRefund(orders.getOrdersNo(), userMoney);
if (StringUtils.isNotBlank(data)) {
log.error(data);
JSONObject jsonObject = JSON.parseObject(data);
JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
String code1 = alipay_trade_refund_response.getString("code");
if (!"10000".equals(code1)) {
return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg"));
} }
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else if (orders.getPayWay() == 6) {
String data = aliPayController.alipayRefund(orders.getOrdersNo(), userMoney);
if (StringUtils.isNotBlank(data)) {
log.error(data);
JSONObject jsonObject = JSON.parseObject(data);
JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
String code1 = alipay_trade_refund_response.getString("code");
if (!"10000".equals(code1)) {
return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg"));
}
} else {
return Result.error("退款失败!");
}
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else { } else {
return Result.error("退款失败!"); userMoneyService.updateMoney(1, orders.getUserId(), userMoney.doubleValue());
//查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney.getMoney());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setBlFlag(1);
} }
userMoneyDetails.setManipulateType(1); userMoneyDetails.setMoney(userMoney);
userMoneyDetails.setBlFlag(2); userMoneyDetails.setUserId(orders.getUserId());
} else { userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",车费已原路退款!");
userMoneyService.updateMoney(1, orders.getUserId(), userMoney.doubleValue()); userMoneyDetails.setTitle("订单退款");
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(time);
userMoneyDetails.setArtificerId(orders.getArtificerId());
userMoneyDetails.setBlRole(1);
userMoneyDetailsService.save(userMoneyDetails);
Artificer artificer2 = artificerService.getById(orders.getArtificerId());
if (userId != null && artificer2.getUserId().equals(userId)) {
BigDecimal newCreditScore = BigDecimal.ZERO;
MessageInfo messageInfo = new MessageInfo();
messageInfo.setState("8");
messageInfo.setUserId(String.valueOf(artificer2.getUserId()));
messageInfo.setTitle("转待补单订单:" + orders.getOrdersNo());
String value1 = commonInfoService.findOne(384).getValue();
BigDecimal creditScore = new BigDecimal(value1);
newCreditScore = artificer2.getCreditScore().subtract(creditScore);
messageInfo.setContent("扣除信誉分:" + creditScore);
artificer2.setCreditScore(newCreditScore);
String value2 = commonInfoService.findOne(385).getValue();
BigDecimal minScore = new BigDecimal(value2);
if (artificer2.getCreditScore().doubleValue() < minScore.doubleValue()) {
artificer2.setStatus(2);
}
artificerService.updateById(artificer2);
messageService.saveBody(messageInfo);
}
UserEntity userEntity = userService.selectUserById(orders.getUserId());
//超过十个字 则截取
String content = "订单:"+orders.getOrdersNo()+",转为待补单";
//消息推送
if (StringUtils.isNotEmpty(userEntity.getOpenId())) {
CommonInfo one = commonInfoService.findOne(248);
List<String> msgList = new ArrayList<>();
msgList.add(orders.getOrdersNo());
msgList.add(content);
msgList.add("车费已原路退还!");
SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2);
}
if (StringUtils.isNotEmpty(userEntity.getClientid())) {
userService.pushToSingle("订单通知", "订单已转为,车费已原路退还!", userEntity.getClientid());
}
if (StringUtils.isNotBlank(userEntity.getWxOpenId())) {
String apkey = commonInfoService.findOne(313).getValue();
LinkedHashMap<String, TemplateMessageItem> data = new LinkedHashMap<>();
data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345"));
data.put("thing17", new TemplateMessageItem(content, "#d71345"));
data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345"));
userService.sendWxMessage(apkey, data, userEntity.getWxOpenId());
}
}
if(isAuto == 1){
//按照比例 将扣除的车费钱
BigDecimal taxiMoney = orders.getTaxiMoney();
BigDecimal sumMoney = orders.getTaxiMoney();//总扣费
Artificer artificer = artificerService.getById(orders.getArtificerId());
BigDecimal artificerTaxiMoney = orders.getTaxiMoney();//扣车费
BigDecimal pingTaxiMoney = BigDecimal.ZERO;
String taxi = commonInfoService.findOne(394).getValue();
if ("".equals(taxi)) {
artificerTaxiMoney = taxiMoney.multiply(artificer.getRate());
pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney);
}
UserEntity artificerUser = userService.selectUserById(artificer.getUserId());
orders.setShopMoney(BigDecimal.ZERO);
orders.setArtificerMoney(BigDecimal.ZERO);
orders.setSumArtificerMoney(sumMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setOneUserMoney(BigDecimal.ZERO);
orders.setOneArtificerMoney(BigDecimal.ZERO);
orders.setPingMoney(BigDecimal.ZERO);
orders.setArtificerTaxiMoney(artificerTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setPingTaxiMoney(pingTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
userMoneyService.updateMoney(1, artificerUser.getUserId(), orders.getSumArtificerMoney().doubleValue());
userMoneyDetails = new UserMoneyDetails();
//查询用户当前余额 //查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(artificerUser.getUserId());
//插入余额 //插入余额
userMoneyDetails.setBalance(userNowMoney.getMoney()); userMoneyDetails.setBalance(userNowMoney1.getMoney());
//插入操作类型为已操作用户余额 //插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2); userMoneyDetails.setManipulateType(2);
userMoneyDetails.setMoney(orders.getSumArtificerMoney());
userMoneyDetails.setUserId(artificerUser.getUserId());
userMoneyDetails.setTitle("订单号:" + orders.getOrdersNo() + ",订单超时转为待补单!");
userMoneyDetails.setContent("用户订单超时转为待补单,总扣除:" + sumMoney + ",到账总金额:" + orders.getSumArtificerMoney());
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1); userMoneyDetails.setBlFlag(1);
} userMoneyDetailsService.save(userMoneyDetails);
userMoneyDetails.setMoney(userMoney);
userMoneyDetails.setUserId(orders.getUserId());
userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",车费已原路退款!");
userMoneyDetails.setTitle("订单退款");
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(time);
userMoneyDetails.setArtificerId(orders.getArtificerId());
userMoneyDetails.setBlRole(1);
userMoneyDetailsService.save(userMoneyDetails);
Artificer artificer2 = artificerService.getById(orders.getArtificerId());
if (userId != null && artificer2.getUserId().equals(userId)) {
BigDecimal newCreditScore = BigDecimal.ZERO;
MessageInfo messageInfo = new MessageInfo();
messageInfo.setState("8");
messageInfo.setUserId(String.valueOf(artificer2.getUserId()));
messageInfo.setTitle("转待补单订单:" + orders.getOrdersNo());
String value1 = commonInfoService.findOne(384).getValue();
BigDecimal creditScore = new BigDecimal(value1);
newCreditScore = artificer2.getCreditScore().subtract(creditScore);
messageInfo.setContent("扣除信誉分:" + creditScore);
artificer2.setCreditScore(newCreditScore);
String value2 = commonInfoService.findOne(385).getValue();
BigDecimal minScore = new BigDecimal(value2);
if (artificer2.getCreditScore().doubleValue() < minScore.doubleValue()) {
artificer2.setStatus(2);
}
artificerService.updateById(artificer2);
messageService.saveBody(messageInfo);
}
UserEntity userEntity = userService.selectUserById(orders.getUserId());
//超过十个字 则截取
String content = "订单:"+orders.getOrdersNo()+",转为待补单";
//消息推送
if (StringUtils.isNotEmpty(userEntity.getOpenId())) {
CommonInfo one = commonInfoService.findOne(248);
List<String> msgList = new ArrayList<>();
msgList.add(orders.getOrdersNo());
msgList.add(content);
msgList.add("车费已原路退还!");
SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2);
}
if (StringUtils.isNotEmpty(userEntity.getClientid())) {
userService.pushToSingle("订单通知", "订单已转为,车费已原路退还!", userEntity.getClientid());
}
if (StringUtils.isNotBlank(userEntity.getWxOpenId())) {
String apkey = commonInfoService.findOne(313).getValue();
LinkedHashMap<String, TemplateMessageItem> data = new LinkedHashMap<>();
data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345"));
data.put("thing17", new TemplateMessageItem(content, "#d71345"));
data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345"));
userService.sendWxMessage(apkey, data, userEntity.getWxOpenId());
} }
} }
if(isAuto == 1){ if(orders.getOldOrdersId() !=null){
//按照比例 将扣除的车费钱 //此笔单子退车费并改为取消再将原单改成待补单
BigDecimal taxiMoney = orders.getTaxiMoney(); orders.setRefusalContent("");
BigDecimal sumMoney = orders.getTaxiMoney();//总扣费 orders.setTaxiMoney(BigDecimal.ZERO);
Artificer artificer = artificerService.getById(orders.getArtificerId()); orders.setStatus(4);
BigDecimal artificerTaxiMoney = orders.getTaxiMoney();//扣车费 baseMapper.updateById(orders);
BigDecimal pingTaxiMoney = BigDecimal.ZERO; cancelSupplementOrders(userId, orders.getOldOrdersId(), isAuto, 1);//退原单原单的车费已被退/所以只退项目
}else{
String taxi = commonInfoService.findOne(394).getValue(); orders.setRefusalContent("");
if ("".equals(taxi)) { orders.setTaxiMoney(BigDecimal.ZERO);
artificerTaxiMoney = taxiMoney.multiply(artificer.getRate()); orders.setStatus(10);
pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney); baseMapper.updateById(orders);
}
UserEntity artificerUser = userService.selectUserById(artificer.getUserId());
orders.setShopMoney(BigDecimal.ZERO);
orders.setArtificerMoney(BigDecimal.ZERO);
orders.setSumArtificerMoney(sumMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setOneUserMoney(BigDecimal.ZERO);
orders.setOneArtificerMoney(BigDecimal.ZERO);
orders.setPingMoney(BigDecimal.ZERO);
orders.setArtificerTaxiMoney(artificerTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setPingTaxiMoney(pingTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
userMoneyService.updateMoney(1, artificerUser.getUserId(), orders.getSumArtificerMoney().doubleValue());
userMoneyDetails = new UserMoneyDetails();
//查询用户当前余额
UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(artificerUser.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney1.getMoney());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setMoney(orders.getSumArtificerMoney());
userMoneyDetails.setUserId(artificerUser.getUserId());
userMoneyDetails.setTitle("订单号:" + orders.getOrdersNo() + ",订单超时转为待补单!");
userMoneyDetails.setContent("用户订单超时转为待补单,总扣除:" + sumMoney + ",到账总金额:" + orders.getSumArtificerMoney());
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userMoneyDetailsService.save(userMoneyDetails);
} }
orders.setRefusalContent("");
orders.setStatus(10);
baseMapper.updateById(orders);
} }
if(type == 2){ if(type == 2){
//退项目费 //退项目费
@ -2034,7 +2047,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
} }
if(orders.getOldOrdersId()!=null){ if(orders.getOldOrdersId()!=null){
cancelSupplementOrders(userId, orders.getOldOrdersId(), 0, 2);//退原单原单的车费已被退/所以只退项目 cancelSupplementOrders(userId, orders.getOldOrdersId(), isAuto, 2);//退原单原单的车费已被退/所以只退项目
} }
} }
return Result.success(); return Result.success();
@ -2042,149 +2055,161 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements
private Result cancelSupplementPackageOrders(Long userId, Orders orders, Integer isAuto, Integer type) { private Result cancelSupplementPackageOrders(Long userId, Orders orders, Integer isAuto, Integer type) {
if(type == 1){ if(type == 1){
//退车费或扣车费成为待补单 if(orders.getTaxiMoney().compareTo(BigDecimal.ZERO) != 0) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //退车费或扣车费成为待补单
String time = simpleDateFormat.format(new Date()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//退款金额 String time = simpleDateFormat.format(new Date());
BigDecimal userMoney = BigDecimal.ZERO; //退款金额
UserMoneyDetails userMoneyDetails = new UserMoneyDetails(); BigDecimal userMoney = BigDecimal.ZERO;
if(isAuto == 0){ UserMoneyDetails userMoneyDetails = new UserMoneyDetails();
//退款车费 if (isAuto == 0) {
userMoney = orders.getTaxiMoney(); //退款车费
if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) { userMoney = orders.getTaxiMoney();
boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), userMoney, orders.getPayWay()); if (orders.getPayWay() == 1 || orders.getPayWay() == 2 || orders.getPayWay() == 3 || orders.getPayWay() == 4) {
if (!refund) { boolean refund = wxService.refund(orders.getOrdersNo(), orders.getPayMoney(), userMoney, orders.getPayWay());
return Result.error("退款失败,请联系客服!"); if (!refund) {
} return Result.error("退款失败,请联系客服!");
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else if (orders.getPayWay() == 6) {
String data = aliPayController.alipayRefund(orders.getOrdersNo(), userMoney);
if (StringUtils.isNotBlank(data)) {
log.error(data);
JSONObject jsonObject = JSON.parseObject(data);
JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
String code1 = alipay_trade_refund_response.getString("code");
if (!"10000".equals(code1)) {
return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg"));
} }
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else if (orders.getPayWay() == 6) {
String data = aliPayController.alipayRefund(orders.getOrdersNo(), userMoney);
if (StringUtils.isNotBlank(data)) {
log.error(data);
JSONObject jsonObject = JSON.parseObject(data);
JSONObject alipay_trade_refund_response = jsonObject.getJSONObject("alipay_trade_refund_response");
String code1 = alipay_trade_refund_response.getString("code");
if (!"10000".equals(code1)) {
return Result.error("退款失败!" + alipay_trade_refund_response.getString("sub_msg"));
}
} else {
return Result.error("退款失败!");
}
userMoneyDetails.setManipulateType(1);
userMoneyDetails.setBlFlag(2);
} else { } else {
return Result.error("退款失败!"); userMoneyService.updateMoney(1, orders.getUserId(), userMoney.doubleValue());
//查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney.getMoney());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setBlFlag(1);
} }
userMoneyDetails.setManipulateType(1); userMoneyDetails.setMoney(userMoney);
userMoneyDetails.setBlFlag(2); userMoneyDetails.setUserId(orders.getUserId());
} else { userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",车费已原路退款!");
userMoneyService.updateMoney(1, orders.getUserId(), userMoney.doubleValue()); userMoneyDetails.setTitle("订单退款");
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(time);
userMoneyDetails.setArtificerId(orders.getArtificerId());
userMoneyDetails.setBlRole(1);
userMoneyDetailsService.save(userMoneyDetails);
Artificer artificer2 = artificerService.getById(orders.getArtificerId());
if (userId != null && artificer2.getUserId().equals(userId)) {
BigDecimal newCreditScore = BigDecimal.ZERO;
MessageInfo messageInfo = new MessageInfo();
messageInfo.setState("8");
messageInfo.setUserId(String.valueOf(artificer2.getUserId()));
messageInfo.setTitle("转待补单订单:" + orders.getOrdersNo());
String value1 = commonInfoService.findOne(384).getValue();
BigDecimal creditScore = new BigDecimal(value1);
newCreditScore = artificer2.getCreditScore().subtract(creditScore);
messageInfo.setContent("扣除信誉分:" + creditScore);
artificer2.setCreditScore(newCreditScore);
String value2 = commonInfoService.findOne(385).getValue();
BigDecimal minScore = new BigDecimal(value2);
if (artificer2.getCreditScore().doubleValue() < minScore.doubleValue()) {
artificer2.setStatus(2);
}
artificerService.updateById(artificer2);
messageService.saveBody(messageInfo);
}
UserEntity userEntity = userService.selectUserById(orders.getUserId());
//超过十个字 则截取
String content = "订单:" + orders.getOrdersNo() + ",转为待补单";
//消息推送
if (StringUtils.isNotEmpty(userEntity.getOpenId())) {
CommonInfo one = commonInfoService.findOne(248);
List<String> msgList = new ArrayList<>();
msgList.add(orders.getOrdersNo());
msgList.add(content);
msgList.add("车费已原路退还!");
SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2);
}
if (StringUtils.isNotEmpty(userEntity.getClientid())) {
userService.pushToSingle("订单通知", "订单已转为,车费已原路退还!", userEntity.getClientid());
}
if (StringUtils.isNotBlank(userEntity.getWxOpenId())) {
String apkey = commonInfoService.findOne(313).getValue();
LinkedHashMap<String, TemplateMessageItem> data = new LinkedHashMap<>();
data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345"));
data.put("thing17", new TemplateMessageItem(content, "#d71345"));
data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345"));
userService.sendWxMessage(apkey, data, userEntity.getWxOpenId());
}
}
if (isAuto == 1) {
//按照比例 将扣除的车费钱
BigDecimal taxiMoney = orders.getTaxiMoney();
BigDecimal sumMoney = orders.getTaxiMoney();//总扣费
Artificer artificer = artificerService.getById(orders.getArtificerId());
BigDecimal artificerTaxiMoney = orders.getTaxiMoney();//扣车费
BigDecimal pingTaxiMoney = BigDecimal.ZERO;
String taxi = commonInfoService.findOne(394).getValue();
if ("".equals(taxi)) {
artificerTaxiMoney = taxiMoney.multiply(artificer.getRate());
pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney);
}
UserEntity artificerUser = userService.selectUserById(artificer.getUserId());
orders.setShopMoney(BigDecimal.ZERO);
orders.setArtificerMoney(BigDecimal.ZERO);
orders.setSumArtificerMoney(sumMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setOneUserMoney(BigDecimal.ZERO);
orders.setOneArtificerMoney(BigDecimal.ZERO);
orders.setPingMoney(BigDecimal.ZERO);
orders.setArtificerTaxiMoney(artificerTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setPingTaxiMoney(pingTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
userMoneyService.updateMoney(1, artificerUser.getUserId(), orders.getSumArtificerMoney().doubleValue());
userMoneyDetails = new UserMoneyDetails();
//查询用户当前余额 //查询用户当前余额
UserMoney userNowMoney = userMoneyService.selectUserMoneyByUserId(orders.getUserId()); UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(artificerUser.getUserId());
//插入余额 //插入余额
userMoneyDetails.setBalance(userNowMoney.getMoney()); userMoneyDetails.setBalance(userNowMoney1.getMoney());
//插入操作类型为已操作用户余额 //插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2); userMoneyDetails.setManipulateType(2);
userMoneyDetails.setMoney(orders.getSumArtificerMoney());
userMoneyDetails.setUserId(artificerUser.getUserId());
userMoneyDetails.setTitle("订单号:" + orders.getOrdersNo() + ",订单超时转为待补单!");
userMoneyDetails.setContent("用户订单超时转为待补单,总扣除:" + sumMoney + ",到账总金额:" + orders.getSumArtificerMoney());
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1); userMoneyDetails.setBlFlag(1);
} userMoneyDetailsService.save(userMoneyDetails);
userMoneyDetails.setMoney(userMoney);
userMoneyDetails.setUserId(orders.getUserId());
userMoneyDetails.setContent("订单号:" + orders.getOrdersNo() + ",车费已原路退款!");
userMoneyDetails.setTitle("订单退款");
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(time);
userMoneyDetails.setArtificerId(orders.getArtificerId());
userMoneyDetails.setBlRole(1);
userMoneyDetailsService.save(userMoneyDetails);
Artificer artificer2 = artificerService.getById(orders.getArtificerId());
if (userId != null && artificer2.getUserId().equals(userId)) {
BigDecimal newCreditScore = BigDecimal.ZERO;
MessageInfo messageInfo = new MessageInfo();
messageInfo.setState("8");
messageInfo.setUserId(String.valueOf(artificer2.getUserId()));
messageInfo.setTitle("转待补单订单:" + orders.getOrdersNo());
String value1 = commonInfoService.findOne(384).getValue();
BigDecimal creditScore = new BigDecimal(value1);
newCreditScore = artificer2.getCreditScore().subtract(creditScore);
messageInfo.setContent("扣除信誉分:" + creditScore);
artificer2.setCreditScore(newCreditScore);
String value2 = commonInfoService.findOne(385).getValue();
BigDecimal minScore = new BigDecimal(value2);
if (artificer2.getCreditScore().doubleValue() < minScore.doubleValue()) {
artificer2.setStatus(2);
}
artificerService.updateById(artificer2);
messageService.saveBody(messageInfo);
}
UserEntity userEntity = userService.selectUserById(orders.getUserId());
//超过十个字 则截取
String content = "订单:"+orders.getOrdersNo()+",转为待补单";
//消息推送
if (StringUtils.isNotEmpty(userEntity.getOpenId())) {
CommonInfo one = commonInfoService.findOne(248);
List<String> msgList = new ArrayList<>();
msgList.add(orders.getOrdersNo());
msgList.add(content);
msgList.add("车费已原路退还!");
SenInfoCheckUtil.sendMsg(userEntity.getOpenId(), one.getValue(), msgList, 2);
}
if (StringUtils.isNotEmpty(userEntity.getClientid())) {
userService.pushToSingle("订单通知", "订单已转为,车费已原路退还!", userEntity.getClientid());
}
if (StringUtils.isNotBlank(userEntity.getWxOpenId())) {
String apkey = commonInfoService.findOne(313).getValue();
LinkedHashMap<String, TemplateMessageItem> data = new LinkedHashMap<>();
data.put("character_string12", new TemplateMessageItem(orders.getOrdersNo(), "#d71345"));
data.put("thing17", new TemplateMessageItem(content, "#d71345"));
data.put("time14", new TemplateMessageItem(DateUtils.format(new Date()), "#d71345"));
userService.sendWxMessage(apkey, data, userEntity.getWxOpenId());
} }
} }
if(isAuto == 1){ if(orders.getOldOrdersId() !=null){
//按照比例 将扣除的车费钱 //此笔单子退车费并改为取消再将原单改成待补单
BigDecimal taxiMoney = orders.getTaxiMoney(); orders.setRefusalContent("");
BigDecimal sumMoney = orders.getTaxiMoney();//总扣费 orders.setTaxiMoney(BigDecimal.ZERO);
Artificer artificer = artificerService.getById(orders.getArtificerId()); orders.setStatus(4);
BigDecimal artificerTaxiMoney = orders.getTaxiMoney();//扣车费 baseMapper.updateById(orders);
BigDecimal pingTaxiMoney = BigDecimal.ZERO; cancelSupplementOrders(userId, orders.getOldOrdersId(), isAuto, 1);//退原单原单的车费已被退/所以只退项目
}else{
String taxi = commonInfoService.findOne(394).getValue(); orders.setRefusalContent("");
if ("".equals(taxi)) { orders.setTaxiMoney(BigDecimal.ZERO);
artificerTaxiMoney = taxiMoney.multiply(artificer.getRate()); orders.setStatus(10);
pingTaxiMoney = taxiMoney.subtract(artificerTaxiMoney); baseMapper.updateById(orders);
}
UserEntity artificerUser = userService.selectUserById(artificer.getUserId());
orders.setShopMoney(BigDecimal.ZERO);
orders.setArtificerMoney(BigDecimal.ZERO);
orders.setSumArtificerMoney(sumMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setOneUserMoney(BigDecimal.ZERO);
orders.setOneArtificerMoney(BigDecimal.ZERO);
orders.setPingMoney(BigDecimal.ZERO);
orders.setArtificerTaxiMoney(artificerTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
orders.setPingTaxiMoney(pingTaxiMoney.setScale(2, BigDecimal.ROUND_DOWN));
userMoneyService.updateMoney(1, artificerUser.getUserId(), orders.getSumArtificerMoney().doubleValue());
userMoneyDetails = new UserMoneyDetails();
//查询用户当前余额
UserMoney userNowMoney1 = userMoneyService.selectUserMoneyByUserId(artificerUser.getUserId());
//插入余额
userMoneyDetails.setBalance(userNowMoney1.getMoney());
//插入操作类型为已操作用户余额
userMoneyDetails.setManipulateType(2);
userMoneyDetails.setMoney(orders.getSumArtificerMoney());
userMoneyDetails.setUserId(artificerUser.getUserId());
userMoneyDetails.setTitle("订单号:" + orders.getOrdersNo() + ",订单超时转为待补单!");
userMoneyDetails.setContent("用户订单超时转为待补单,总扣除:" + sumMoney + ",到账总金额:" + orders.getSumArtificerMoney());
userMoneyDetails.setType(1);
userMoneyDetails.setCreateTime(simpleDateFormat.format(new Date()));
userMoneyDetails.setBlRole(2);
userMoneyDetails.setBlFlag(1);
userMoneyDetailsService.save(userMoneyDetails);
} }
orders.setRefusalContent("");
orders.setStatus(10);
baseMapper.updateById(orders);
} }
if(type == 2){ if(type == 2){
//退项目费 //退项目费