修改自动退款

This commit is contained in:
yuyang 2022-01-28 09:36:13 +08:00
parent 5e4c675bb4
commit 3677a32f5a
4 changed files with 75 additions and 12 deletions

View File

@ -16,6 +16,6 @@ import java.util.Map;
@FeignClient(contextId = "refundOrderService",value = ServiceNameConstants.XHPC_PAYMENT,fallbackFactory = RefundOrderFallbackFactory.class) @FeignClient(contextId = "refundOrderService",value = ServiceNameConstants.XHPC_PAYMENT,fallbackFactory = RefundOrderFallbackFactory.class)
public interface RefundOrderService { public interface RefundOrderService {
@PostMapping("/refund/order/checkOut") @PostMapping("/refund/order/orderCheckOut")
R sendNotice(@RequestBody Map<String, Object> map); R sendNotice(@RequestBody Map<String, Object> map);
} }

View File

@ -564,6 +564,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower())); xhpcHistoryOrder.setConnectorPowerEvcs(Double.parseDouble(xhpcChargeOrder.getPower()));
} }
Map<String, Object> map =new HashMap<>(); Map<String, Object> map =new HashMap<>();
map.put("source",xhpcChargeOrder.getSource());
map.put("tenantId",xhpcChargeOrder.getTerminalId());
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){ if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString()); xhpcHistoryOrder.setUserNameEvcs(userMessage.get("phone").toString());
xhpcHistoryOrder.setPhone(userMessage.get("phone").toString()); xhpcHistoryOrder.setPhone(userMessage.get("phone").toString());
@ -578,8 +580,9 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId()); int i = xhpcChargeOrderService.updateUserBalance(userId, subtract,xhpcChargeOrder.getSource(),xhpcChargeOrder.getTenantId());
if(i==0){ if(i==0){
//扣钱失败 //扣钱失败
xhpcChargeOrder.setStatus(2); logger.info("<<<<<<<<<<<<<<<<扣钱失败>>>>>>>>>>>>>>>>>");
xhpcChargeOrder.setErroRemark("扣钱失败"); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return R.fail();
}else{ }else{
//添加流水 //添加流水
xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,xhpcChargeOrder.getSource()); xhpcChargeOrderService.addUserAccountStatement(userId, actPrice.negate(), subtract, xhpcChargeOrder.getChargeOrderId(), 3, date,xhpcChargeOrder.getSource());

View File

@ -163,4 +163,64 @@ public class XhpcRefundOrderController extends BaseController {
public AjaxResult sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type) { public AjaxResult sumMoney(String phone, String refundOrderNumber, String status, String createTimeStart, String createTimeEnd,Integer type) {
return AjaxResult.success(iXhpcRefundOrderService.sumMoney(phone, refundOrderNumber, status, createTimeStart, createTimeEnd,type)); return AjaxResult.success(iXhpcRefundOrderService.sumMoney(phone, refundOrderNumber, status, createTimeStart, createTimeEnd,type));
} }
/**
* 自动申请退款
*/
@NoRepeatSubmit
@PostMapping("/orderCheckOut")
@ApiOperation(value = "订单自动退款")
public AjaxResult orderCheckOut(@RequestBody Map<String, Object> map) {
Long userid = Long.valueOf(map.get("userId").toString());
Integer userType = Integer.valueOf(map.get("source").toString());
String tenantId = map.get("tenantId").toString();
if (UserTypeUtil.CUSTOMERS_TYPE.equals(userType)) {
return AjaxResult.error(HttpStatus.ERROR_STATUS, "大客户不支持退款");
}
String amount = StringUtils.valueOf(map.get("amount"));
if (StringUtils.isEmpty(amount)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能为空");
} else {
if (new BigDecimal(1).compareTo(new BigDecimal(amount)) == 1) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款金额不能少于1元");
}
}
//用户信息id
String userId = StringUtils.valueOf(map.get("userId"));
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空");
}
//openid
String openid = StringUtils.valueOf(map.get("openid"));
if (StringUtils.isEmpty(userId)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "用户信息不能为空");
}
String type = StringUtils.valueOf(map.get("type"));
if (StringUtils.isEmpty(type)) {
return AjaxResult.error(HttpStatus.NOT_NULL, "退款渠道不能为空");
}
//是否有实时数据
int i = iXhpcRefundOrderService.countXhpcRealTimeOrder(userid, userType, tenantId);
if (i > 0) {
return AjaxResult.error(1103, "车辆正在充电,不能退款");
}
// 是否有异常订单
int j = iXhpcRefundOrderService.countXhpcChargeOrder(userid, userType, tenantId);
if (j > 0) {
return AjaxResult.error(1103, "你有异常订单未解决,请拨打客服电话进行解决");
}
//生成退款订单
String orderOutNumber = StringUtils.numFormat(userid, Integer.parseInt(type),
StatusConstants.FLOWING_WATER_REFUND_TYPE);
String remark = StringUtils.valueOf(map.get("remark"));
return iXhpcRefundOrderService.addRefundOrder("" + userid, BigDecimal.valueOf(Double.parseDouble(amount)), type,
orderOutNumber, openid, remark, userType, tenantId);
}
} }

View File

@ -16,9 +16,9 @@
balance as balance, balance as balance,
avatar as avatar, avatar as avatar,
status, status,
weixin_open_id as weixinlogin, weixin_open_id as weixinOpenId,
alipay_open_id as alipayLogin, alipay_open_id as alipayOpenId,
weixin_login as weixinOpenId, weixin_login as weixinLogin,
alipay_login as alipayLogin, alipay_login as alipayLogin,
del_flag delFlag, del_flag delFlag,
concat(0) as userType, concat(0) as userType,
@ -50,9 +50,9 @@
surplus_money as balance, surplus_money as balance,
avatar as avatar, avatar as avatar,
status, status,
weixin_open_id as weixinlogin, weixin_open_id as weixinOpenId,
alipay_open_id as alipayLogin, alipay_open_id as alipayOpenId,
weixin_login as weixinOpenId, weixin_login as weixinLogin,
alipay_login as alipayLogin, alipay_login as alipayLogin,
tenant_id tenantId, tenant_id tenantId,
del_flag delFlag, del_flag delFlag,
@ -87,9 +87,9 @@
surplus_money as balance, surplus_money as balance,
avatar as avatar, avatar as avatar,
status, status,
weixin_open_id as weixinlogin, weixin_open_id as weixinOpenId,
alipay_open_id as alipayLogin, alipay_open_id as alipayOpenId,
weixin_login as weixinOpenId, weixin_login as weixinLogin,
alipay_login as alipayLogin, alipay_login as alipayLogin,
del_flag delFlag, del_flag delFlag,
tenant_id tenantId, tenant_id tenantId,