|
@@ -13,21 +13,24 @@ import com.alipay.api.request.AlipayTradePrecreateRequest;
|
|
|
import com.alipay.api.response.AlipayTradePrecreateResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.gson.Gson;
|
|
|
-import com.szwl.constant.*;
|
|
|
+import com.szwl.constant.HuifuConstant;
|
|
|
+import com.szwl.constant.JoinpayConstant;
|
|
|
+import com.szwl.constant.ResponseCodesEnum;
|
|
|
+import com.szwl.constant.ShouQianBaConstant;
|
|
|
import com.szwl.feign.bean.OrderFeign;
|
|
|
import com.szwl.feign.bean.SzwlFeign;
|
|
|
+import com.szwl.mapper.TOrderMapper;
|
|
|
import com.szwl.model.bean.WeChatTemplateMsg;
|
|
|
import com.szwl.model.bo.JsonMessage;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
|
import com.szwl.model.entity.*;
|
|
|
-import com.szwl.mapper.TOrderMapper;
|
|
|
import com.szwl.model.utils.HttpClientUtils;
|
|
|
import com.szwl.model.utils.PushUtils;
|
|
|
import com.szwl.model.utils.RSAUtil;
|
|
|
import com.szwl.service.*;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.szwl.service.es.EsTOrderService;
|
|
|
import com.szwl.utils.HuifuUtils;
|
|
|
import com.szwl.utils.IDGenerator;
|
|
@@ -44,9 +47,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.http.HttpStatus;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
-import org.jetbrains.annotations.Nullable;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -55,22 +56,19 @@ import org.springframework.web.client.RestTemplate;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.*;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.net.URL;
|
|
|
-import java.net.URLConnection;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
-import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import static com.szwl.service.impl.TJoinpayMchServiceImpl.createHmacSign;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wuhs
|
|
@@ -134,7 +132,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
public String wechatPay(String sn, BigDecimal amount, String productName, Long id, String notifyUrl, String clientId, HttpServletRequest request) {
|
|
|
TWechatPayConfig wechatPayConfig = wechatPayConfigService.getById(id);
|
|
|
Config config = wechatPayConfigService.getWechatConfig(id);
|
|
|
- if(config==null){
|
|
|
+ if (config == null) {
|
|
|
wechatPayConfigService.initConfig(id);
|
|
|
config = wechatPayConfigService.getWechatConfig(id);
|
|
|
}
|
|
@@ -161,8 +159,10 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
PrepayResponse response = service.prepay(payRequest);
|
|
|
return response.getCodeUrl();
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 处理退款回调通知
|
|
|
+ *
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return
|
|
@@ -176,7 +176,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 处理退款通知参数
|
|
|
String body = HttpUtils.readData(request);
|
|
|
Map<String, Object> bodyMap = gson.fromJson(body, HashMap.class);
|
|
|
- String eventType = (String)bodyMap.get("event_type");
|
|
|
+ String eventType = (String) bodyMap.get("event_type");
|
|
|
if (eventType.equals("REFUND.SUCCESS")) {
|
|
|
// 处理退款单
|
|
|
processRefund(bodyMap);
|
|
@@ -198,7 +198,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Override
|
|
|
public Refund weixinRefundApi(CreateRequest createRequest, Long id) {
|
|
|
Config config = wechatPayConfigService.getWechatConfig(id);
|
|
|
- if(config==null){
|
|
|
+ if (config == null) {
|
|
|
wechatPayConfigService.initConfig(id);
|
|
|
config = wechatPayConfigService.getWechatConfig(id);
|
|
|
}
|
|
@@ -210,6 +210,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
/**
|
|
|
* 汇聚查询退款状态
|
|
|
+ *
|
|
|
* @param refundTrxNo
|
|
|
* @return
|
|
|
*/
|
|
@@ -245,12 +246,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String sn = request.getParameter("r2_OrderNo");
|
|
|
// 退款订单号
|
|
|
|
|
|
- if(StringUtils.isEmpty(sn)){
|
|
|
- return "error";
|
|
|
+ if (StringUtils.isEmpty(sn)) {
|
|
|
+ return "error";
|
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TOrder::getSn,sn);
|
|
|
+ query.eq(TOrder::getSn, sn);
|
|
|
TOrder order = orderService.getOne(query);
|
|
|
|
|
|
if (order == null) {
|
|
@@ -261,7 +262,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
// 订单商品数量
|
|
|
if (JoinpayConstant.r6_Status_100.equals(r6_Status)) {
|
|
|
- if(order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
+ if (order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
order.setStatus(1);
|
|
|
} else {
|
|
|
order.setStatus(3);
|
|
@@ -275,7 +276,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
for (TOrderDetails tOrderDetail : tOrderDetails) {
|
|
|
Integer refundQuantity = tOrderDetail.getRefundQuantity();
|
|
|
Integer productNumber = tOrderDetail.getProductNumber();
|
|
|
- if(refundQuantity < productNumber) {
|
|
|
+ if (refundQuantity < productNumber) {
|
|
|
// 部分退款
|
|
|
tOrderDetail.setRefundStatus("2");
|
|
|
orderDetailsService.updateById(tOrderDetail);
|
|
@@ -287,18 +288,18 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
// r4_refundAmount: 退款金额
|
|
|
BigDecimal r4_refundAmount = new BigDecimal(request.getParameter("r4_RefundAmount_str"));
|
|
|
- if(order.getRefundMarketingAmount()!=null){
|
|
|
- r4_refundAmount =r4_refundAmount.add(order.getRefundMarketingAmount());
|
|
|
+ if (order.getRefundMarketingAmount() != null) {
|
|
|
+ r4_refundAmount = r4_refundAmount.add(order.getRefundMarketingAmount());
|
|
|
}
|
|
|
// price: 订单金额, refundAmount:已退款的金额
|
|
|
BigDecimal price = order.getPrice();
|
|
|
BigDecimal refundAmount = order.getRefundAmount();
|
|
|
TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(order.getEquipmentId())));
|
|
|
- if(order.getRefundAmount() != null) {
|
|
|
- BigDecimal newRefundAmount = refundAmount.add(r4_refundAmount);
|
|
|
+ if (order.getRefundAmount() != null) {
|
|
|
+ BigDecimal newRefundAmount = refundAmount.add(r4_refundAmount);
|
|
|
order.setRefundAmount(refundAmount.add(r4_refundAmount));
|
|
|
// 如果小于订单金额
|
|
|
- if(newRefundAmount.compareTo(price) < 0) {
|
|
|
+ if (newRefundAmount.compareTo(price) < 0) {
|
|
|
JSONArray altInfo = getAltInfo(proportion, price.subtract(newRefundAmount));
|
|
|
order.setAltInfo(altInfo.toString());
|
|
|
} else {
|
|
@@ -307,7 +308,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
} else {
|
|
|
order.setRefundAmount(r4_refundAmount);
|
|
|
- if(r4_refundAmount.compareTo(price) < 0) {
|
|
|
+ if (r4_refundAmount.compareTo(price) < 0) {
|
|
|
JSONArray altInfo = getAltInfo(proportion, price.subtract(r4_refundAmount));
|
|
|
order.setAltInfo(altInfo.toString());
|
|
|
}
|
|
@@ -319,13 +320,13 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
order.setRefundDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
String orderStatus = order.getOrderStatus();
|
|
|
- if(StringUtils.isNotEmpty(orderStatus)&&orderStatus.equals("0")){
|
|
|
- if(order.getStatus().toString().equals("3")){
|
|
|
+ if (StringUtils.isNotEmpty(orderStatus) && orderStatus.equals("0")) {
|
|
|
+ if (order.getStatus().toString().equals("3")) {
|
|
|
TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
JSONObject kindData = new JSONObject();
|
|
|
String s = order.getId().toString();
|
|
|
- if(s.length()>6){
|
|
|
- s = s.substring(s.length()-6,s.length());
|
|
|
+ if (s.length() > 6) {
|
|
|
+ s = s.substring(s.length() - 6, s.length());
|
|
|
}
|
|
|
kindData.put("mealCode", s);
|
|
|
equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("refuse_success", kindData.toString()).toString());
|
|
@@ -334,9 +335,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
try {
|
|
|
esTOrderService.updateDataById(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
orderService.updateById(order);
|
|
|
}
|
|
|
return "success";
|
|
@@ -361,19 +362,19 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String transStat = data.getString("trans_stat");
|
|
|
// 订单号
|
|
|
String sn = data.getString("org_req_seq_id");
|
|
|
- if(StrUtil.hasEmpty(sn)) {
|
|
|
+ if (StrUtil.hasEmpty(sn)) {
|
|
|
log.info("返回参数订单编号为空");
|
|
|
return "订单号为空!";
|
|
|
}
|
|
|
LambdaQueryWrapper<TOrder> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(TOrder::getSn,sn);
|
|
|
+ wrapper.eq(TOrder::getSn, sn);
|
|
|
TOrder order = orderService.getOne(wrapper);
|
|
|
- if(order == null) {
|
|
|
+ if (order == null) {
|
|
|
log.info("找不到订单");
|
|
|
return "订单不存在";
|
|
|
}
|
|
|
- if(HuifuConstant.TRANS_STAT_S.equals(transStat)) {
|
|
|
- if(order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
+ if (HuifuConstant.TRANS_STAT_S.equals(transStat)) {
|
|
|
+ if (order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
order.setStatus(1);
|
|
|
} else {
|
|
|
order.setStatus(3);
|
|
@@ -393,7 +394,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
for (TOrderDetails tOrderDetail : tOrderDetails) {
|
|
|
Integer refundQuantity = tOrderDetail.getRefundQuantity();
|
|
|
Integer productNumber = tOrderDetail.getProductNumber();
|
|
|
- if(refundQuantity < productNumber) {
|
|
|
+ if (refundQuantity < productNumber) {
|
|
|
// 部分退款
|
|
|
tOrderDetail.setRefundStatus("2");
|
|
|
orderDetailsService.updateById(tOrderDetail);
|
|
@@ -406,38 +407,38 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String acctSplitBunch = "";
|
|
|
// 部分退款或全部退款
|
|
|
TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(order.getEquipmentId())));
|
|
|
- if(order.getRefundAmount() != null) {
|
|
|
+ if (order.getRefundAmount() != null) {
|
|
|
// 退款总额
|
|
|
BigDecimal newRefundAmount = order.getRefundAmount().add(new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP));
|
|
|
order.setRefundAmount(newRefundAmount);
|
|
|
// 如果小于订单金额
|
|
|
- if(newRefundAmount.compareTo(order.getPrice()) < 0) {
|
|
|
- acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice().subtract(newRefundAmount), order.getCompanyType()).toString();
|
|
|
+ if (newRefundAmount.compareTo(order.getPrice()) < 0) {
|
|
|
+ acctSplitBunch = getAcctSplitBunch(proportion, order.getPrice().subtract(newRefundAmount), order.getCompanyType()).toString();
|
|
|
order.setAcctSplitBunch(acctSplitBunch);
|
|
|
} else {
|
|
|
- acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice(), order.getCompanyType()).toString();
|
|
|
+ acctSplitBunch = getAcctSplitBunch(proportion, order.getPrice(), order.getCompanyType()).toString();
|
|
|
order.setAcctSplitBunch(acctSplitBunch);
|
|
|
}
|
|
|
} else {
|
|
|
- order.setRefundAmount(new BigDecimal(ordAmt).setScale(2,RoundingMode.HALF_UP));
|
|
|
- if(new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP).compareTo(order.getPrice()) < 0) {
|
|
|
+ order.setRefundAmount(new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP));
|
|
|
+ if (new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP).compareTo(order.getPrice()) < 0) {
|
|
|
// 重新设置分销
|
|
|
- acctSplitBunch = getAcctSplitBunch(proportion,order.getPrice()
|
|
|
- .subtract(new BigDecimal(ordAmt).setScale(2,RoundingMode.HALF_UP)), order.getCompanyType()).toString();
|
|
|
+ acctSplitBunch = getAcctSplitBunch(proportion, order.getPrice()
|
|
|
+ .subtract(new BigDecimal(ordAmt).setScale(2, RoundingMode.HALF_UP)), order.getCompanyType()).toString();
|
|
|
order.setAcctSplitBunch(acctSplitBunch);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
esTOrderService.updateDataById(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
orderService.updateById(order);
|
|
|
}
|
|
|
return "RECV_ORD_ID_" + refundOrderNo;
|
|
|
}
|
|
|
- } catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
log.info("异步回调开始,参数,request={}", respData, e);
|
|
|
}
|
|
|
return "";
|
|
@@ -483,7 +484,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
@Override
|
|
|
public void processAlipayOrder(Map<String, String> params, TOrder order) {
|
|
|
log.info("处理订单");
|
|
|
- if(order.getStatus() != 0) {
|
|
|
+ if (order.getStatus() != 0) {
|
|
|
return;
|
|
|
}
|
|
|
order.setStatus(1);
|
|
@@ -520,10 +521,10 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 推送微信订单
|
|
|
TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(order.getAdminId())));
|
|
|
// 判断是否开启订单推送功能
|
|
|
- if(admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
+ if (admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
String openId = R.getDataIfSuccess(szwlFeign.getOpenId(order.getAdminId()));
|
|
|
// 获取openId
|
|
|
- if(StringUtils.isNotEmpty(openId)) {
|
|
|
+ if (StringUtils.isNotEmpty(openId)) {
|
|
|
orderService.sendWechatMessage(openId, equipment, order, admin.getCompanyType());
|
|
|
}
|
|
|
}
|
|
@@ -531,11 +532,11 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
orderService.updateById(order);
|
|
|
try {
|
|
|
// 保存订单信息到ES
|
|
|
- if(order.getProductNumber()==null||order.getProductNumber()==0){
|
|
|
+ if (order.getProductNumber() == null || order.getProductNumber() == 0) {
|
|
|
order.setProductNumber(1);
|
|
|
}
|
|
|
orderFeign.saveToEs(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
@@ -544,7 +545,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
public void sendWechatMessage(String openId, TEquipment equipment, TOrder order, String companyType) {
|
|
|
String accessToken = "";
|
|
|
try {
|
|
|
- if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+ if (StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin("2738"));
|
|
|
accessToken = admin.getApiKey();
|
|
|
log.info("申泽的accessToken:{}", accessToken);
|
|
@@ -563,8 +564,8 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String payTime = format.format(order.getPayDate());
|
|
|
// 模版参数
|
|
|
- if(StringUtils.isNotEmpty(equipment.getName())) {
|
|
|
- if(equipment.getName().length() > 20) {
|
|
|
+ if (StringUtils.isNotEmpty(equipment.getName())) {
|
|
|
+ if (equipment.getName().length() > 20) {
|
|
|
sendMag.put("thing15", new WeChatTemplateMsg(equipment.getName().substring(0, 15) + "..."));
|
|
|
} else {
|
|
|
sendMag.put("thing15", new WeChatTemplateMsg(equipment.getName()));
|
|
@@ -573,7 +574,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String clientId = equipment.getClientId();
|
|
|
sendMag.put("thing15", new WeChatTemplateMsg(clientId.substring(clientId.length() - 6)));
|
|
|
}
|
|
|
- if(order.getProductName().length() > 20) {
|
|
|
+ if (order.getProductName().length() > 20) {
|
|
|
sendMag.put("thing37", new WeChatTemplateMsg(order.getProductName().substring(0, 15) + "..."));
|
|
|
} else {
|
|
|
sendMag.put("thing37", new WeChatTemplateMsg(order.getProductName()));
|
|
@@ -586,7 +587,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
sendBody.put("touser", openId);
|
|
|
sendBody.put("topcolor", "#FF0000");
|
|
|
sendBody.put("data", sendMag);
|
|
|
- if(StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
+ if (StringUtils.isEmpty(companyType) || companyType.equals("0")) {
|
|
|
sendBody.put("template_id", HuifuConstant.SZ_TEMPLATE_ID);
|
|
|
} else {
|
|
|
sendBody.put("template_id", HuifuConstant.SC_TEMPLATE_ID);
|
|
@@ -617,7 +618,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
log.info("查询结果:{}", query);
|
|
|
JSONObject queryJsonObject = JSON.parseObject(query);
|
|
|
orderStatus = queryJsonObject.getJSONObject("biz_response").getJSONObject("data")
|
|
|
- .getString("order_status");
|
|
|
+ .getString("order_status");
|
|
|
if (orderStatus.equals(ShouQianBaConstant.PAID)) {
|
|
|
log.info("订单支付成功:{}", orderNo);
|
|
|
JSONObject bizResponse = queryJsonObject.getJSONObject("biz_response");
|
|
@@ -660,10 +661,10 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 推送微信订单
|
|
|
TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(order.getAdminId())));
|
|
|
// 判断是否开启订单推送功能
|
|
|
- if(admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
+ if (admin != null && StringUtils.isNotEmpty(admin.getOrderNotice()) && admin.getOrderNotice().equals("1")) {
|
|
|
String openId = R.getDataIfSuccess(szwlFeign.getOpenId(order.getAdminId()));
|
|
|
// 获取openId
|
|
|
- if(StringUtils.isNotEmpty(openId)) {
|
|
|
+ if (StringUtils.isNotEmpty(openId)) {
|
|
|
orderService.sendWechatMessage(openId, equipment, order, admin.getCompanyType());
|
|
|
}
|
|
|
}
|
|
@@ -671,11 +672,11 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
orderService.updateById(order);
|
|
|
try {
|
|
|
// 保存订单信息到ES
|
|
|
- if(order.getProductNumber()==null||order.getProductNumber()==0){
|
|
|
+ if (order.getProductNumber() == null || order.getProductNumber() == 0) {
|
|
|
order.setProductNumber(1);
|
|
|
}
|
|
|
orderFeign.saveToEs(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
@@ -698,9 +699,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
@Override
|
|
|
public JsonMessage sqbCardPay(String authCode, String frpCode, String clientId, String ip, Map<String, String> productNameMap, HttpServletRequest request) {
|
|
|
- if(productNameMap==null){
|
|
|
+ if (productNameMap == null) {
|
|
|
return JsonMessage.error("数据出错");
|
|
|
}
|
|
|
+ if (StringUtils.isEmpty(ip)) {
|
|
|
+ return JsonMessage.error("ip不能为空");
|
|
|
+ }
|
|
|
StringBuilder note = new StringBuilder();
|
|
|
StringBuilder productName = new StringBuilder();
|
|
|
String productNo = "";
|
|
@@ -708,25 +712,25 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
int productNumber = 0;
|
|
|
|
|
|
TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
- if(equipment==null||equipment.getId()==null){
|
|
|
+ if (equipment == null || equipment.getId() == null) {
|
|
|
return JsonMessage.error("找不到设备");
|
|
|
}
|
|
|
BigDecimal price = new BigDecimal("0.00");
|
|
|
TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
- if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
+ if (equipmentDesc == null || equipmentDesc.getEquipmentId() == null || equipmentDesc.getPayType() == null || equipmentDesc.getPayType().equals("0")) {
|
|
|
for (String key : productNameMap.keySet()) {
|
|
|
String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
List<TPromoCode> promoCodeList = new ArrayList<>();
|
|
|
//1,校验优惠码
|
|
|
- if(value.size()>0){
|
|
|
- for(String code:value){
|
|
|
- if(!code.equals("0")){
|
|
|
+ if (value.size() > 0) {
|
|
|
+ for (String code : value) {
|
|
|
+ if (!code.equals("0")) {
|
|
|
TPromoCode promoCode = new TPromoCode();
|
|
|
ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
promoCode = tPromoCode;
|
|
|
- if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
+ if (tPromoCode == null || tPromoCode.getId() == null) {
|
|
|
//不存在
|
|
|
return JsonMessage.success("1");
|
|
|
}
|
|
@@ -737,7 +741,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
promoCode.setIsUse("2");
|
|
|
- szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
+ szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()), "2");
|
|
|
//过期
|
|
|
return JsonMessage.success("4");
|
|
|
}
|
|
@@ -749,7 +753,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
//被使用
|
|
|
return JsonMessage.success("2");
|
|
|
}
|
|
|
- if(!promoCode.getAdminId().equals("1")){
|
|
|
+ if (!promoCode.getAdminId().equals("1")) {
|
|
|
if (!String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
return JsonMessage.success("3");
|
|
|
}
|
|
@@ -769,7 +773,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- productMap.put(productNamea,Integer.valueOf(num));
|
|
|
+ productMap.put(productNamea, Integer.valueOf(num));
|
|
|
productNumber += Integer.parseInt(num);
|
|
|
productName.append(productNamea).append("x").append(num).append(",");
|
|
|
TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
@@ -779,37 +783,37 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
note.append(productNamea).append("-").append(product.getNo()).append(":");
|
|
|
BigDecimal productPrice = product.getRmbPrice();
|
|
|
productNo = product.getNo();
|
|
|
- if(promoCodeList.size()>0){
|
|
|
+ if (promoCodeList.size() > 0) {
|
|
|
//有优惠码
|
|
|
BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
int i;
|
|
|
- for( i = 0;i<promoCodeList.size();i++){
|
|
|
+ for (i = 0; i < promoCodeList.size(); i++) {
|
|
|
BigDecimal discount = BigDecimal.valueOf(promoCodeList.get(i).getDiscount()).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
BigDecimal price1 = productPrice.multiply(discount).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
price = price.add(price1);
|
|
|
onePrice = onePrice.add(price1);
|
|
|
}
|
|
|
- if(i<Integer.parseInt(num)){
|
|
|
- int a = Integer.parseInt(num)-i;
|
|
|
+ if (i < Integer.parseInt(num)) {
|
|
|
+ int a = Integer.parseInt(num) - i;
|
|
|
BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
- price =price.add(price2);
|
|
|
+ price = price.add(price2);
|
|
|
onePrice = onePrice.add(price2);
|
|
|
}
|
|
|
note.append(onePrice).append("-").append(num).append(",");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
//1,type=0,原始设定,没有第二件半价
|
|
|
int a = Integer.parseInt(num);
|
|
|
BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
- price =price.add(price2);
|
|
|
+ price = price.add(price2);
|
|
|
note.append(price2).append("-").append(num).append(",");
|
|
|
}
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
for (String key : productNameMap.keySet()) {
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- productMap.put(productNamea,Integer.valueOf(num));
|
|
|
+ productMap.put(productNamea, Integer.valueOf(num));
|
|
|
TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
productNo = product.getNo();
|
|
|
BigDecimal productPrice = product.getRmbPrice();
|
|
@@ -818,37 +822,37 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
switch (num) {
|
|
|
case "1":
|
|
|
//1个 0个半价
|
|
|
- price =price.add(productPrice);
|
|
|
+ price = price.add(productPrice);
|
|
|
note.append(price).append("-").append(num).append(",");
|
|
|
break;
|
|
|
case "2":
|
|
|
//2个 1个半价
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
note.append(price).append("-").append(num).append(",");
|
|
|
break;
|
|
|
case "3":
|
|
|
//3个 1个半价
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
- price =price.add(productPrice);
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
note.append(price).append("-").append(num).append(",");
|
|
|
break;
|
|
|
case "4":
|
|
|
//4个 2个半价
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
note.append(price).append("-").append(num).append(",");
|
|
|
break;
|
|
|
case "5":
|
|
|
//5个 2个半价
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
- price =price.add(productPrice);
|
|
|
- price =price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
- price =price.add(productPrice);
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
+ price = price.add(productPrice.multiply(new BigDecimal(5)).divide(new BigDecimal(10)).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ price = price.add(productPrice);
|
|
|
note.append(price).append("-").append(num).append(",");
|
|
|
break;
|
|
|
}
|
|
@@ -880,20 +884,20 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
String newTerminalKey = terminal.getString("terminal_key");
|
|
|
sqbConfig.setNewTerminalKey(newTerminalKey);
|
|
|
+ sqbConfig.setCheckin("1");
|
|
|
sqbConfigService.updateById(sqbConfig);
|
|
|
}
|
|
|
|
|
|
String companyType = admin.getCompanyType();
|
|
|
BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
amount = amount.multiply(new BigDecimal(100)).setScale(0);
|
|
|
- String appid = "";
|
|
|
TOrder order = new TOrder();
|
|
|
order.setId(IDGenerator.orderID());
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
|
order.setSn(sn);
|
|
|
- if(productNumber == 1) {
|
|
|
+ if (productNumber == 1) {
|
|
|
productName.delete(productName.length() - 3, productName.length());
|
|
|
} else {
|
|
|
productName.deleteCharAt(productName.length() - 1);
|
|
@@ -935,7 +939,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
orderService.save(order);
|
|
|
String productName1 = "";
|
|
|
- if(productNumber > 1) {
|
|
|
+ if (productNumber > 1) {
|
|
|
productName1 = "棉花糖";
|
|
|
} else {
|
|
|
productName1 = productName.toString();
|
|
@@ -943,7 +947,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String result;
|
|
|
try {
|
|
|
result = sqCardPay(
|
|
|
- sn, amount, productName1,authCode, sqbConfig, admin.getUsername(), ip
|
|
|
+ sn, amount, productName1, authCode, sqbConfig, admin.getUsername(), ip
|
|
|
);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -970,34 +974,34 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String[] refundDetails = note.split(",");
|
|
|
Map<String, Integer> refundMap = new HashMap<>();
|
|
|
for (String refundDetail : refundDetails) {
|
|
|
- String[] keyValue = refundDetail.split("-");
|
|
|
+ String[] keyValue = refundDetail.split("-");
|
|
|
String key = keyValue[0];
|
|
|
String value = keyValue[1];
|
|
|
refundMap.put(key, Integer.valueOf(value));
|
|
|
}
|
|
|
|
|
|
- if(refusePrice.compareTo(new BigDecimal("0.00"))<=0){
|
|
|
- return R.fail(ResponseCodesEnum.A0001,"退款金额非法");
|
|
|
+ if (refusePrice.compareTo(new BigDecimal("0.00")) <= 0) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "退款金额非法");
|
|
|
}
|
|
|
|
|
|
|
|
|
TOrder order = orderService.getById(torder.getId());
|
|
|
- if(order.getRefundQuantity() != null && order.getRefundQuantity()>0) {
|
|
|
+ if (order.getRefundQuantity() != null && order.getRefundQuantity() > 0) {
|
|
|
order.setRefundQuantity(refundNumber + order.getRefundQuantity());
|
|
|
} else {
|
|
|
order.setRefundQuantity(refundNumber);
|
|
|
}
|
|
|
|
|
|
- if(refusePrice.compareTo(order.getPrice()) > 0) {
|
|
|
- return R.fail(ResponseCodesEnum.A0001,"退款金额非法");
|
|
|
+ if (refusePrice.compareTo(order.getPrice()) > 0) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "退款金额非法");
|
|
|
}
|
|
|
|
|
|
- if(order.getRefundAmount() != null && order.getRefundAmount().add(refusePrice).compareTo(order.getPrice()) > 0) {
|
|
|
- return R.fail(ResponseCodesEnum.A0001,"退款金额非法");
|
|
|
+ if (order.getRefundAmount() != null && order.getRefundAmount().add(refusePrice).compareTo(order.getPrice()) > 0) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "退款金额非法");
|
|
|
}
|
|
|
|
|
|
if (order.getStatus().equals("0")) {
|
|
|
- return R.fail(ResponseCodesEnum.A0002,"订单非支付状态");
|
|
|
+ return R.fail(ResponseCodesEnum.A0002, "订单非支付状态");
|
|
|
}
|
|
|
|
|
|
// 获取收钱吧配置
|
|
@@ -1005,7 +1009,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
sqbConfigQuery.eq(TSqbConfig::getAdminId, order.getAdminId());
|
|
|
TSqbConfig sqbConfig = sqbConfigService.getOne(sqbConfigQuery);
|
|
|
if (sqbConfig == null) {
|
|
|
- return R.fail(ResponseCodesEnum.A0002,"商户未配置");
|
|
|
+ return R.fail(ResponseCodesEnum.A0002, "商户未配置");
|
|
|
}
|
|
|
|
|
|
LambdaQueryWrapper<TOrderDetails> wrapper = new LambdaQueryWrapper<>();
|
|
@@ -1030,7 +1034,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
String refundRequestNo = jsonObject.getJSONObject("biz_response").getJSONObject("data").getString("refund_request_no");
|
|
|
// 退款成功
|
|
|
// 已退款
|
|
|
- if(order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
+ if (order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
order.setStatus(1);
|
|
|
} else {
|
|
|
order.setStatus(3);
|
|
@@ -1040,11 +1044,11 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
for (TOrderDetails orderDetail : orderDetails) {
|
|
|
String orderDetailId = orderDetail.getId();
|
|
|
Integer productNumber = refundMap.get(orderDetailId);
|
|
|
- if(productNumber != null) {
|
|
|
+ if (productNumber != null) {
|
|
|
// 退款数量
|
|
|
orderDetail.setRefundQuantity(productNumber);
|
|
|
// 退款状态
|
|
|
- if(productNumber < orderDetail.getProductNumber()) {
|
|
|
+ if (productNumber < orderDetail.getProductNumber()) {
|
|
|
// 部分退款
|
|
|
orderDetail.setRefundStatus("2");
|
|
|
} else {
|
|
@@ -1059,7 +1063,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
// 已退款金额
|
|
|
BigDecimal refundAmount = order.getRefundAmount();
|
|
|
BigDecimal price = order.getPrice();
|
|
|
- if(refundAmount != null) {
|
|
|
+ if (refundAmount != null) {
|
|
|
if (price.compareTo(refundAmount) == 0) {
|
|
|
order.setRefundAmount(refundAmount);
|
|
|
} else {
|
|
@@ -1074,9 +1078,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
order.setRefundTrxNo(refundRequestNo);
|
|
|
try {
|
|
|
orderFeign.saveToEs(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
orderService.updateById(order);
|
|
|
}
|
|
|
return R.ok("申请退款已成功");
|
|
@@ -1086,11 +1090,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return R.fail(ResponseCodesEnum.B0001,"申请退款失败,请联系管理员");
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "申请退款失败,请联系管理员");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 发送微信消息
|
|
|
+ *
|
|
|
* @param accessToken
|
|
|
* @param restTemplate
|
|
|
* @param sendBody
|
|
@@ -1102,26 +1107,26 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
JSONObject jsonObject = JSONObject.parseObject(forEntity.getBody());
|
|
|
String messageCode = jsonObject.getString("errcode");
|
|
|
String msgId = jsonObject.getString("msgid");
|
|
|
- System.out.println("messageCode : " + messageCode + ", msgId: " +msgId);
|
|
|
- log.info("微信推送结果:{}","messageCode : " + messageCode + ", msgId: " +msgId);
|
|
|
+ System.out.println("messageCode : " + messageCode + ", msgId: " + msgId);
|
|
|
+ log.info("微信推送结果:{}", "messageCode : " + messageCode + ", msgId: " + msgId);
|
|
|
return messageCode;
|
|
|
}
|
|
|
|
|
|
public void processRefund(Map<String, Object> bodyMap) {
|
|
|
String decrypt = wechatPayConfigService.decryptFromResource(bodyMap);
|
|
|
Gson gson = new Gson();
|
|
|
- Map<String,Object> map = gson.fromJson(decrypt, HashMap.class);
|
|
|
+ Map<String, Object> map = gson.fromJson(decrypt, HashMap.class);
|
|
|
String sn = map.get("out_trade_no").toString();
|
|
|
String refundNo = map.get("out_refund_no").toString();
|
|
|
- String amount =map.get("amount").toString();
|
|
|
- Map<String,Object> amountMap = gson.fromJson(amount, HashMap.class);
|
|
|
+ String amount = map.get("amount").toString();
|
|
|
+ Map<String, Object> amountMap = gson.fromJson(amount, HashMap.class);
|
|
|
String refundPrice = amountMap.get("refund").toString();
|
|
|
- if(StringUtils.isNotEmpty(sn)){
|
|
|
+ if (StringUtils.isNotEmpty(sn)) {
|
|
|
LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
- query.eq(TOrder::getSn,sn);
|
|
|
+ query.eq(TOrder::getSn, sn);
|
|
|
TOrder order = getOne(query);
|
|
|
// 已退款
|
|
|
- if(order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
+ if (order.getRefundQuantity() < order.getProductNumber()) {
|
|
|
order.setStatus(1);
|
|
|
} else {
|
|
|
order.setStatus(3);
|
|
@@ -1135,7 +1140,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
for (TOrderDetails tOrderDetail : tOrderDetails) {
|
|
|
Integer refundQuantity = tOrderDetail.getRefundQuantity();
|
|
|
Integer productNumber = tOrderDetail.getProductNumber();
|
|
|
- if(refundQuantity < productNumber) {
|
|
|
+ if (refundQuantity < productNumber) {
|
|
|
// 部分退款
|
|
|
tOrderDetail.setRefundStatus("2");
|
|
|
orderDetailsService.updateById(tOrderDetail);
|
|
@@ -1146,13 +1151,13 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
}
|
|
|
}
|
|
|
//退款金额要除以100
|
|
|
- BigDecimal r4_refundAmount = new BigDecimal(refundPrice).divide(new BigDecimal(100),2,BigDecimal.ROUND_HALF_UP).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ BigDecimal r4_refundAmount = new BigDecimal(refundPrice).divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
// if(order.getRefundMarketingAmount()!=null){
|
|
|
// r4_refundAmount =r4_refundAmount.add(order.getRefundMarketingAmount());
|
|
|
// }
|
|
|
BigDecimal refundAmount = order.getRefundAmount();
|
|
|
BigDecimal price = order.getPrice();
|
|
|
- if(refundAmount != null) {
|
|
|
+ if (refundAmount != null) {
|
|
|
if (price.compareTo(refundAmount) == 0) {
|
|
|
order.setRefundAmount(refundAmount);
|
|
|
} else {
|
|
@@ -1166,9 +1171,9 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
order.setRefundTrxNo(refundNo);
|
|
|
try {
|
|
|
orderFeign.saveToEs(order);
|
|
|
- }catch (Exception e) {
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- }finally {
|
|
|
+ } finally {
|
|
|
updateById(order);
|
|
|
}
|
|
|
|
|
@@ -1178,6 +1183,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
/**
|
|
|
* 汇聚分销明细
|
|
|
+ *
|
|
|
* @param proportion
|
|
|
* @param price
|
|
|
* @return
|
|
@@ -1240,7 +1246,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (selfMch == null || agencyMch == null) {
|
|
|
return altInfo;
|
|
|
}
|
|
|
- if(!(agencyProportion.compareTo(refuseAmount) == 0||agencyProportion==null)){
|
|
|
+ if (!(agencyProportion.compareTo(refuseAmount) == 0 || agencyProportion == null)) {
|
|
|
// 一级分销获得利润
|
|
|
agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
agencyJson = new JSONObject();
|
|
@@ -1277,7 +1283,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
if (selfMch == null || agencyMch == null || merchantMch == null) {
|
|
|
return altInfo;
|
|
|
}
|
|
|
- if(!(agencyProportion.compareTo(refuseAmount) == 0||agencyProportion==null)){
|
|
|
+ if (!(agencyProportion.compareTo(refuseAmount) == 0 || agencyProportion == null)) {
|
|
|
// 代理分销获得利润
|
|
|
agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
agencyJson = new JSONObject();
|
|
@@ -1287,7 +1293,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
altInfo.add(agencyJson);
|
|
|
|
|
|
}
|
|
|
- if(!(merchantProportion.compareTo(refuseAmount) == 0||merchantProportion==null)){
|
|
|
+ if (!(merchantProportion.compareTo(refuseAmount) == 0 || merchantProportion == null)) {
|
|
|
// 经销商分销获得利润
|
|
|
merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
merchantJson = new JSONObject();
|
|
@@ -1317,6 +1323,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
|
|
|
/**
|
|
|
* 汇付分销明细
|
|
|
+ *
|
|
|
* @param proportion
|
|
|
* @param price
|
|
|
* @return
|
|
@@ -1372,7 +1379,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
adminJson = new JSONObject();
|
|
|
adminJson.put("div_amt", adminAmount.toString());
|
|
|
// 判断为申泽还是七云
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -1406,7 +1413,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
adminJson = new JSONObject();
|
|
|
adminJson.put("div_amt", adminAmount.toString());
|
|
|
// 判断为申泽还是七云
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -1417,7 +1424,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
selfJson.put("div_amt", selfAmount.toString());
|
|
|
selfJson.put("huifu_id", selfHuifu.getHuifuId());
|
|
|
acctInfos.add(selfJson);
|
|
|
- if(!(agencyProportion.compareTo(refuseAmount) == 0||agencyProportion==null)){
|
|
|
+ if (!(agencyProportion.compareTo(refuseAmount) == 0 || agencyProportion == null)) {
|
|
|
// 一级分销获得利润
|
|
|
agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
agencyJson = new JSONObject();
|
|
@@ -1450,7 +1457,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
adminJson = new JSONObject();
|
|
|
adminJson.put("div_amt", adminAmount.toString());
|
|
|
// 判断为申泽还是七云
|
|
|
- if(StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
+ if (StrUtil.isNotEmpty(companyType) && companyType.equals("1")) {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SC_DIV_HUIFU_ID);
|
|
|
} else {
|
|
|
adminJson.put("huifu_id", HuifuConstant.SZ_DIV_HUIFU_ID);
|
|
@@ -1461,7 +1468,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
selfJson.put("div_amt", selfAmount.toString());
|
|
|
selfJson.put("huifu_id", selfHuifu.getHuifuId());
|
|
|
acctInfos.add(selfJson);
|
|
|
- if(!(agencyProportion.compareTo(refuseAmount) == 0||agencyProportion==null)){
|
|
|
+ if (!(agencyProportion.compareTo(refuseAmount) == 0 || agencyProportion == null)) {
|
|
|
// 一级分销获得利润
|
|
|
agencyAmount = cutPrice.multiply(agencyProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
agencyJson = new JSONObject();
|
|
@@ -1469,7 +1476,7 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
|
|
|
agencyJson.put("huifu_id", agencyHuifu.getHuifuId());
|
|
|
acctInfos.add(agencyJson);
|
|
|
}
|
|
|
- if(!(merchantProportion.compareTo(refuseAmount) == 0||merchantProportion==null)){
|
|
|
+ if (!(merchantProportion.compareTo(refuseAmount) == 0 || merchantProportion == null)) {
|
|
|
// 二级分销获得利润
|
|
|
merchantAmount = cutPrice.multiply(merchantProportion.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
merchantJson = new JSONObject();
|