|
@@ -9,9 +9,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.huifu.bspay.sdk.opps.core.utils.DateTools;
|
|
import com.huifu.bspay.sdk.opps.core.utils.DateTools;
|
|
import com.szwl.constant.HuifuConstant;
|
|
import com.szwl.constant.HuifuConstant;
|
|
|
|
+import com.szwl.constant.JoinpayConstant;
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
import com.szwl.feign.bean.PayFeign;
|
|
import com.szwl.feign.bean.PayFeign;
|
|
-import com.szwl.constant.JoinpayConstant;
|
|
|
|
import com.szwl.model.bo.R;
|
|
import com.szwl.model.bo.R;
|
|
import com.szwl.model.bo.ResponseModel;
|
|
import com.szwl.model.bo.ResponseModel;
|
|
import com.szwl.model.entity.*;
|
|
import com.szwl.model.entity.*;
|
|
@@ -19,6 +19,7 @@ import com.szwl.service.*;
|
|
import com.szwl.service.es.EsTOrderService;
|
|
import com.szwl.service.es.EsTOrderService;
|
|
import com.szwl.util.IDGenerator;
|
|
import com.szwl.util.IDGenerator;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
@@ -39,6 +40,7 @@ import java.util.*;
|
|
*/
|
|
*/
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/tOrder")
|
|
@RequestMapping("/tOrder")
|
|
|
|
+@Slf4j
|
|
public class TOrderController {
|
|
public class TOrderController {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -84,6 +86,8 @@ public class TOrderController {
|
|
Integer refundNumber = torder.getProductNumber();
|
|
Integer refundNumber = torder.getProductNumber();
|
|
// 退款明细:note
|
|
// 退款明细:note
|
|
String note = torder.getNote();
|
|
String note = torder.getNote();
|
|
|
|
+ // 操作员类型:type
|
|
|
|
+ Integer type = torder.getType();
|
|
String[] refundDetails = note.split(",");
|
|
String[] refundDetails = note.split(",");
|
|
Map<String, Integer> refundMap = new HashMap<>();
|
|
Map<String, Integer> refundMap = new HashMap<>();
|
|
for (String refundDetail : refundDetails) {
|
|
for (String refundDetail : refundDetails) {
|
|
@@ -105,6 +109,10 @@ public class TOrderController {
|
|
}
|
|
}
|
|
List<TOrderDetails> orderDetails = R.getDataIfSuccess(payFeign.getOrderDetailsBySn(order.getSn()));
|
|
List<TOrderDetails> orderDetails = R.getDataIfSuccess(payFeign.getOrderDetailsBySn(order.getSn()));
|
|
TEquipment equipment = tEquipmentService.getById(order.getEquipmentId());
|
|
TEquipment equipment = tEquipmentService.getById(order.getEquipmentId());
|
|
|
|
+ String name = equipment.getName();
|
|
|
|
+ if (StringUtils.isEmpty(name)) {
|
|
|
|
+ name = equipment.getClientId().substring(equipment.getClientId().length() - 6);
|
|
|
|
+ }
|
|
Long equipmentId = equipment.getId();
|
|
Long equipmentId = equipment.getId();
|
|
if (order.getProductName().equals("280充值")) {
|
|
if (order.getProductName().equals("280充值")) {
|
|
return R.fail(ResponseCodesEnum.A0002,"订单不退款");
|
|
return R.fail(ResponseCodesEnum.A0002,"订单不退款");
|
|
@@ -113,10 +121,6 @@ public class TOrderController {
|
|
return R.fail(ResponseCodesEnum.A0002,"订单非支付状态");
|
|
return R.fail(ResponseCodesEnum.A0002,"订单非支付状态");
|
|
}
|
|
}
|
|
//判断是不是直连微信退款
|
|
//判断是不是直连微信退款
|
|
-// if(StringUtils.isNotEmpty(order.getPayPlatform())&&order.getPayPlatform().equals("3")){
|
|
|
|
-// String ifSuccess = R.getDataIfSuccess(payFeign.refund(order.getSn(),refusePrice));
|
|
|
|
-// return R.ok(ifSuccess);
|
|
|
|
-// }
|
|
|
|
|
|
|
|
String notifyUrl = JoinpayConstant.Notify_Refund_Url;
|
|
String notifyUrl = JoinpayConstant.Notify_Refund_Url;
|
|
|
|
|
|
@@ -135,7 +139,6 @@ public class TOrderController {
|
|
sumPrice = sumPrice.add(order.getPrice()).setScale(2, RoundingMode.HALF_DOWN);
|
|
sumPrice = sumPrice.add(order.getPrice()).setScale(2, RoundingMode.HALF_DOWN);
|
|
}
|
|
}
|
|
|
|
|
|
-// BigDecimal pri = new BigDecimal(order.getPrice().toString()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
BigDecimal p8_MarketRefAmount = BigDecimal.ZERO;
|
|
BigDecimal p8_MarketRefAmount = BigDecimal.ZERO;
|
|
//获取分销 关联设备
|
|
//获取分销 关联设备
|
|
LambdaQueryWrapper<TProportion> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<TProportion> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -220,7 +223,6 @@ public class TOrderController {
|
|
payFeign.updateOrder(order);
|
|
payFeign.updateOrder(order);
|
|
// 修改订单明细
|
|
// 修改订单明细
|
|
for (TOrderDetails orderDetail : orderDetails) {
|
|
for (TOrderDetails orderDetail : orderDetails) {
|
|
-// String productNo = orderDetail.getProductNo();
|
|
|
|
String orderDetailId = orderDetail.getId();
|
|
String orderDetailId = orderDetail.getId();
|
|
Integer productNumber = refundMap.get(orderDetailId);
|
|
Integer productNumber = refundMap.get(orderDetailId);
|
|
if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
@@ -233,6 +235,17 @@ public class TOrderController {
|
|
payFeign.updateOrderDetails(orderDetail);
|
|
payFeign.updateOrderDetails(orderDetail);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 如果是公司人员操作退款,需要发送短信提醒客户
|
|
|
|
+ if (type != null && type < 2) {
|
|
|
|
+ TAdmin admin = tAdminService.getById(order.getAdminId());
|
|
|
|
+ // 获取客户手机号
|
|
|
|
+ String phone = admin.getPhone();
|
|
|
|
+ if (StringUtils.isNotEmpty(phone)) {
|
|
|
|
+ String result = orderService.sendRefundSms(order, phone, name);
|
|
|
|
+ log.info("退款短信发送结果:{}", result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
return R.ok("申请退款成功");
|
|
return R.ok("申请退款成功");
|
|
}else {
|
|
}else {
|
|
return R.fail(refundData);
|
|
return R.fail(refundData);
|
|
@@ -256,7 +269,6 @@ public class TOrderController {
|
|
}
|
|
}
|
|
// 修改订单明细
|
|
// 修改订单明细
|
|
for (TOrderDetails orderDetail : orderDetails) {
|
|
for (TOrderDetails orderDetail : orderDetails) {
|
|
-// String productNo = orderDetail.getProductNo();
|
|
|
|
String orderDetailId = orderDetail.getId();
|
|
String orderDetailId = orderDetail.getId();
|
|
Integer productNumber = refundMap.get(orderDetailId);
|
|
Integer productNumber = refundMap.get(orderDetailId);
|
|
if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
if(productNumber != null && orderDetail.getAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
@@ -269,6 +281,15 @@ public class TOrderController {
|
|
payFeign.updateOrderDetails(orderDetail);
|
|
payFeign.updateOrderDetails(orderDetail);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (type != null && type < 2) {
|
|
|
|
+ TAdmin admin = tAdminService.getById(order.getAdminId());
|
|
|
|
+ // 获取客户手机号
|
|
|
|
+ String phone = admin.getPhone();
|
|
|
|
+ if (StringUtils.isNotEmpty(phone)) {
|
|
|
|
+ String sendResult = orderService.sendRefundSms(order, phone, name);
|
|
|
|
+ log.info("退款短信发送结果:{}", sendResult);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
order.setRefundTrxNo(String.valueOf(refusePrice));
|
|
order.setRefundTrxNo(String.valueOf(refusePrice));
|
|
payFeign.updateOrder(order);
|
|
payFeign.updateOrder(order);
|
|
return R.ok("申请退款已成功");
|
|
return R.ok("申请退款已成功");
|