修改自动退款

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)
public interface RefundOrderService {
@PostMapping("/refund/order/checkOut")
@PostMapping("/refund/order/orderCheckOut")
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()));
}
Map<String, Object> map =new HashMap<>();
map.put("source",xhpcChargeOrder.getSource());
map.put("tenantId",xhpcChargeOrder.getTerminalId());
if(!UserTypeUtil.INTERNET_TYPE.equals(source)){
xhpcHistoryOrder.setUserNameEvcs(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());
if(i==0){
//扣钱失败
xhpcChargeOrder.setStatus(2);
xhpcChargeOrder.setErroRemark("扣钱失败");
logger.info("<<<<<<<<<<<<<<<<扣钱失败>>>>>>>>>>>>>>>>>");
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return R.fail();
}else{
//添加流水
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) {
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,
avatar as avatar,
status,
weixin_open_id as weixinlogin,
alipay_open_id as alipayLogin,
weixin_login as weixinOpenId,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
del_flag delFlag,
concat(0) as userType,
@ -50,9 +50,9 @@
surplus_money as balance,
avatar as avatar,
status,
weixin_open_id as weixinlogin,
alipay_open_id as alipayLogin,
weixin_login as weixinOpenId,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
tenant_id tenantId,
del_flag delFlag,
@ -87,9 +87,9 @@
surplus_money as balance,
avatar as avatar,
status,
weixin_open_id as weixinlogin,
alipay_open_id as alipayLogin,
weixin_login as weixinOpenId,
weixin_open_id as weixinOpenId,
alipay_open_id as alipayOpenId,
weixin_login as weixinLogin,
alipay_login as alipayLogin,
del_flag delFlag,
tenant_id tenantId,