退租和取消退租接口优化

This commit is contained in:
geng.tang@qq.com
2024-01-30 09:04:46 +08:00
parent 7754978cbd
commit 5a5e4b7499
5 changed files with 42 additions and 25 deletions

View File

@@ -14,6 +14,7 @@ import com.gxwebsoft.apps.result.*;
import com.gxwebsoft.apps.service.HualalaFoodService;
import com.gxwebsoft.apps.service.HualalaService;
import com.gxwebsoft.apps.service.HualalaShopService;
import com.gxwebsoft.common.core.constants.OrderConstants;
import com.gxwebsoft.common.core.utils.CacheClient;
import com.gxwebsoft.common.core.utils.JSONUtil;
import com.gxwebsoft.common.core.web.ApiResult;
@@ -97,7 +98,7 @@ public class HualalaCart extends BaseController {
order.setUserId(loginUser.getUserId());
}
order.setMerchantCode(order.getShopId().toString());
order.setPayMethod("通联支付");
order.setPayMethod(OrderConstants.PAY_METHOD_OTHER);
if (orderService.save(order)) {
// 添加订单商品
List<Object> hValues = cacheClient.hValues(key);

View File

@@ -18,10 +18,10 @@ public class OrderConstants {
public static final Integer DELIVERY_STATUS_ACCEPT = 40; // 已绑定
// 收货状态
public static final Integer RECEIPT_STATUS_NO = 10; // 未收货
public static final Integer RECEIPT_STATUS_YES = 20; // 已收货
public static final Integer RECEIPT_STATUS_APPLY = 21; // 申请退租
public static final Integer RECEIPT_STATUS_RETURN = 30; // 已退货
public static final int RECEIPT_STATUS_NO = 10; // 未收货
public static final int RECEIPT_STATUS_YES = 20; // 已收货
public static final int RECEIPT_STATUS_APPLY = 21; // 申请退租
public static final int RECEIPT_STATUS_RETURN = 30; // 已退货
// 订单状态
public static final Integer ORDER_STATUS_DOING = 10; // 待付款

View File

@@ -267,11 +267,6 @@ public class OpenEquipmentController extends BaseController {
order.setExpirationTime(DateUtil.nextMonth());
order.setEquipmentId(one.getEquipmentId());
if(order.getOrderSource() == 10) {
order.setOrderStatus(ORDER_STATUS_OVER);
}
orderService.updateById(order);
JSONObject param = new JSONObject();
param.put("userId", loginUser.getUserId());
param.put("userName", loginUser.getNickname());
@@ -285,6 +280,11 @@ public class OpenEquipmentController extends BaseController {
log.error(e.getMessage(), e);
}
if(order.getOrderSource() == 10) {
order.setOrderStatus(ORDER_STATUS_OVER);
}
orderService.updateById(order);
orderPayService.lambdaUpdate().set(OrderPay::getEquipmentId, one.getEquipmentId()).update();
return success("绑定成功");
}
@@ -471,22 +471,26 @@ public class OpenEquipmentController extends BaseController {
OrderRefund refund = orderRefundService.getOne(new LambdaQueryWrapper<OrderRefund>()
.eq(OrderRefund::getOrderId, order.getOrderId()).last("limit 1"));
// 已有记录 取消退租
Integer isRefund = order.getIsRefund();
if (refund != null) {
if(isRefund == 1){
return fail("已申请退租!");
}
Integer auditStatus = refund.getAuditStatus();
if(auditStatus == 10){
if(auditStatus != 10){
return fail("未申请退租!");
}
orderRefundService.removeById(refund.getOrderRefundId());
// Order updateOrder = new Order();
// updateOrder.setReceiptStatus(RECEIPT_STATUS_YES);
// updateOrder.setOrderId(order.getOrderId());
// orderService.updateById(updateOrder);
order.setReceiptStatus(RECEIPT_STATUS_YES);
orderService.updateById(order);
return success("已申请退租");
}
if (auditStatus != 30) {
return fail("申请成功,请等待客服人员审核");
}
return success("取消退租成功");
} else {
if(isRefund == 2){
return fail("找不到申请退租记录!");
}
refund = new OrderRefund();
refund.setOrderId(order.getOrderId());
refund.setOrderNo(order.getOrderNo());

View File

@@ -374,6 +374,9 @@ public class PaymentController extends BaseController {
order.setOrderNo(outTradeNo);
Order parentOrder = orderService.getById(order.getRentOrderId());
if(StrUtil.isBlank(parentOrder.getPayMethod())){
parentOrder.setPayMethod(PAY_METHOD_ALIPAY);
}
parentOrder.setCurrPeriods(parentOrder.getCurrPeriods() + 1);
parentOrder.setPayStatus(PAY_STATUS_SUCCESS);
// 更新过期时间延长一个月
@@ -461,6 +464,10 @@ public class PaymentController extends BaseController {
// 处理主订单
Order parentOrder = orderService.getById(order.getRentOrderId());
if(StrUtil.isBlank(parentOrder.getPayMethod())){
parentOrder.setPayMethod(PAY_METHOD_BALANCE);
}
parentOrder.setCurrPeriods(parentOrder.getCurrPeriods() + 1);
order.setCurrPeriods(parentOrder.getCurrPeriods());
order.setBatteryRent(parentOrder.getBatteryRent());
@@ -545,6 +552,10 @@ public class PaymentController extends BaseController {
// 主订单
Order parentOrder = orderService.getById(d.getRentOrderId());
// 更新过期时间延长一个月
if(StrUtil.isBlank(parentOrder.getPayMethod())){
parentOrder.setPayMethod(PAY_METHOD_BALANCE);
}
Date expirationTime = parentOrder.getExpirationTime();
DateTime nextMonthTime = DateUtil.offsetMonth(expirationTime, 1);
parentOrder.setExpirationTime(nextMonthTime);
@@ -598,14 +609,11 @@ public class PaymentController extends BaseController {
@ApiModelProperty("测试")
@GetMapping("/mp-alipay/test")
public String test() {
System.out.println("开始>>>>>");
Order order = orderService.getByOutTradeNo("2023213225911618");
System.out.println("order = " + order);
order.setPayPrice(new BigDecimal("0.11"));
order.setTotalPrice(new BigDecimal("0.11"));
order.setPayStatus(PAY_STATUS_SUCCESS);
final boolean b = orderService.updateByIdRel(order);
System.out.println("b = " + b);
// params.put("gmt_create", "2022-12-16 21:32:33");
// params.put("charset", "UTF-8");

View File

@@ -328,6 +328,10 @@ public class Order implements Serializable {
@TableField(exist = false)
private Date insuranceExpireDate;
@ApiModelProperty(value = "是否申请退租1为申请2为取消")
@TableField(exist = false)
private Integer isRefund;
public Integer getRestDay() {
if(null != orderStatus){
switch(orderStatus){