|
@@ -43,6 +43,7 @@ import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.szwl.constant.ResponseCodesEnum.A0002;
|
|
|
import static com.szwl.model.utils.DateUtils.PATTERN_yyyy_MM_dd_HH_mm_ss;
|
|
|
|
|
|
/**
|
|
@@ -327,7 +328,7 @@ public class TOrderController {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (personageMch == null) {
|
|
|
+ if (selfMch == null) {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
@@ -733,7 +734,7 @@ public class TOrderController {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (personageMch == null) {
|
|
|
+ if (selfMch == null) {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
@@ -1131,7 +1132,7 @@ public class TOrderController {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (personageMch == null) {
|
|
|
+ if (selfMch == null) {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
@@ -1444,7 +1445,7 @@ public class TOrderController {
|
|
|
note.append(productNamea).append(num).append(":");
|
|
|
productName1.append(productNamea).append(num);
|
|
|
//确定价格,然后叠加R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName));
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productName.toString()));
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
if (product == null) {
|
|
|
return JsonMessage.error("找不到商品");
|
|
|
}
|
|
@@ -1484,7 +1485,7 @@ public class TOrderController {
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productName.toString()));
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
BigDecimal productPrice = product.getRmbPrice();
|
|
|
productName.append(productNamea).append(num);
|
|
|
productName1.append(productNamea).append(num);
|
|
@@ -1535,10 +1536,10 @@ public class TOrderController {
|
|
|
|
|
|
Long equipmentId = equipment.getId();
|
|
|
//查找商品
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName.toString()));
|
|
|
- if (product == null) {
|
|
|
- return JsonMessage.error("找不到商品");
|
|
|
- }
|
|
|
+// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName.toString()));
|
|
|
+// if (product == null) {
|
|
|
+// return JsonMessage.error("找不到商品");
|
|
|
+// }
|
|
|
|
|
|
if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
return JsonMessage.error("商品价格异常");
|
|
@@ -1665,7 +1666,7 @@ public class TOrderController {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (personageMch == null) {
|
|
|
+ if (selfMch == null) {
|
|
|
return JsonMessage.error("设备商家未注册提现账户");
|
|
|
}
|
|
|
|
|
@@ -1745,8 +1746,8 @@ public class TOrderController {
|
|
|
order.setModifyDate(new Date());
|
|
|
order.setAdminId(admin.getId());
|
|
|
order.setSn(sn1);
|
|
|
- order.setProductId(product.getId());
|
|
|
- order.setProductNo(product.getNo());
|
|
|
+// order.setProductId(product.getId());
|
|
|
+// order.setProductNo(product.getNo());
|
|
|
order.setProductName(productName.toString());
|
|
|
order.setPrice(price);
|
|
|
order.setClientId(equipment.getClientId());
|
|
@@ -1788,8 +1789,8 @@ public class TOrderController {
|
|
|
order2.setModifyDate(new Date());
|
|
|
order2.setAdminId(admin.getId());
|
|
|
order2.setSn(sn2);
|
|
|
- order2.setProductId(product.getId());
|
|
|
- order2.setProductNo(product.getNo());
|
|
|
+// order2.setProductId(product.getId());
|
|
|
+// order2.setProductNo(product.getNo());
|
|
|
order2.setProductName(productName.toString());
|
|
|
order2.setPrice(price);
|
|
|
order2.setClientId(equipment.getClientId());
|
|
@@ -1898,9 +1899,9 @@ public class TOrderController {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
- @ApiOperation(value = "购物车 微信支付")
|
|
|
+ @ApiOperation(value = "购物车 微信小程序支付")
|
|
|
@PostMapping("/carsPayXCX")
|
|
|
- public Object carsPayXCX(String clientId,String id, @RequestBody Map<String,String> productNameMap) {
|
|
|
+ public Object carsPayXCX(String clientId,String id,String coupons, @RequestBody Map<String,String> productNameMap) {
|
|
|
|
|
|
if(productNameMap==null){
|
|
|
return JsonMessage.error("数据出错");
|
|
@@ -1912,8 +1913,9 @@ public class TOrderController {
|
|
|
if(equipment==null||equipment.getId()==null){
|
|
|
return JsonMessage.error("找不到设备");
|
|
|
}
|
|
|
- List<TPromoCode> promoCodeAll = new ArrayList<>();
|
|
|
BigDecimal price = new BigDecimal("0.00");
|
|
|
+ List<TPromoCode> promoCodeAll = new ArrayList<>();
|
|
|
+
|
|
|
TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
//1,type=0,原始设定,没有第二件半价
|
|
@@ -1926,7 +1928,11 @@ public class TOrderController {
|
|
|
for(String code:value){
|
|
|
if(!code.equals("0")){
|
|
|
TPromoCode promoCode = new TPromoCode();
|
|
|
- TPromoCode tPromoCode = R.getDataIfSuccess(szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString()));
|
|
|
+// ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
+// TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
+// TPromoCode tPromoCode = R.getDataIfSuccess(szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString()));
|
|
|
+ ResponseModel<TPromoCode> promoCode1 = szwlFeign.getPromoCode(code + "-" + equipment.getAdminId().toString());
|
|
|
+ TPromoCode tPromoCode = promoCode1.getData();
|
|
|
promoCode = tPromoCode;
|
|
|
if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
//不存在
|
|
@@ -1976,7 +1982,7 @@ public class TOrderController {
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea.toString()));
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
if (product == null) {
|
|
|
return JsonMessage.error("找不到商品");
|
|
|
}
|
|
@@ -2035,7 +2041,7 @@ public class TOrderController {
|
|
|
String[] productNum = key.split("-");
|
|
|
String productNamea = productNum[0];
|
|
|
String num = productNum[1];
|
|
|
- TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea.toString()));
|
|
|
+ TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipment.getId()), productNamea));
|
|
|
BigDecimal productPrice = product.getRmbPrice();
|
|
|
productName.append(productNamea).append(num);
|
|
|
productName1.append(productNamea).append(num);
|
|
@@ -2100,7 +2106,7 @@ public class TOrderController {
|
|
|
TProportion proportion = R.getDataIfSuccess(szwlFeign.getProportion(String.valueOf(equipmentId)));
|
|
|
|
|
|
if (proportion == null&&proportion.getId()==null) {
|
|
|
- return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ return JsonMessage.error("设备未完成分销设置");
|
|
|
}
|
|
|
TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
if (admin == null) {
|
|
@@ -2119,7 +2125,7 @@ public class TOrderController {
|
|
|
String orderType = null;
|
|
|
|
|
|
if (type == null) {
|
|
|
- return JsonMessage.error("设备商家未完成分销设置");
|
|
|
+ return JsonMessage.error("设备未完成分销设置");
|
|
|
}
|
|
|
|
|
|
BigDecimal agencyAmount = null;
|
|
@@ -2148,7 +2154,7 @@ public class TOrderController {
|
|
|
agencyMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
|
|
|
|
|
|
if (agencyMch == null ) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ return JsonMessage.error("1商家未注册提现账户");
|
|
|
}
|
|
|
agencyProportion = proportion.getProportion();
|
|
|
adminProportion = proportion.getAdminProportion();
|
|
@@ -2167,11 +2173,11 @@ public class TOrderController {
|
|
|
// agencyMch = mchService.getUniqueness(admin.getAgencyId());
|
|
|
selfMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
|
|
|
|
|
|
- if (agencyMch == null ) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ if (agencyMch == null && proportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))>0) {
|
|
|
+ return JsonMessage.error("1备商家未注册提现账户");
|
|
|
}
|
|
|
if (selfMch == null ) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ return JsonMessage.error("商家未注册提现账户");
|
|
|
}
|
|
|
agencyProportion = proportion.getAgencyProportion();
|
|
|
adminProportion = proportion.getAdminProportion();
|
|
@@ -2208,23 +2214,23 @@ public class TOrderController {
|
|
|
|
|
|
selfMch = R.getDataIfSuccess(szwlFeign.getMch(String.valueOf(proportion.getAdminId())));
|
|
|
|
|
|
- if (agencyMch == null ) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ if (agencyMch == null && proportion.getAgencyProportion().compareTo(new BigDecimal("0.00"))>0) {
|
|
|
+ return JsonMessage.error("1商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (merchantMch == null ) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ if (merchantMch == null && proportion.getMerchantProportion().compareTo(new BigDecimal("0.00"))>0) {
|
|
|
+ return JsonMessage.error("2商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
- if (personageMch == null) {
|
|
|
- return JsonMessage.error("设备商家未注册提现账户");
|
|
|
+ if (selfMch == null) {
|
|
|
+ return JsonMessage.error("商家未注册提现账户");
|
|
|
}
|
|
|
|
|
|
agencyProportion = proportion.getAgencyProportion();
|
|
|
adminProportion = proportion.getAdminProportion();
|
|
|
merchantProportion = proportion.getMerchantProportion();
|
|
|
personageProportion = proportion.getPersonageProportion();
|
|
|
-
|
|
|
+ selfProportion = proportion.getProportion();
|
|
|
orderType = "3";
|
|
|
BigDecimal refuseAmount1 = new BigDecimal(0.00);
|
|
|
if(agencyProportion.compareTo(refuseAmount1) == 0||agencyProportion==null){
|
|
@@ -2265,14 +2271,8 @@ public class TOrderController {
|
|
|
merchantJson.put("isGuar", "12");
|
|
|
altInfo.add(merchantJson);
|
|
|
break;
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
String orderNo1 = sn1;
|
|
|
-// String orderNo2 = sn2;
|
|
|
- BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
String productDesc = "";
|
|
|
String commonParameter = "";
|
|
|
String returnUrl = null;
|
|
@@ -2288,10 +2288,54 @@ public class TOrderController {
|
|
|
String isAlt = "1";
|
|
|
String altType = "11";
|
|
|
String altUrl = null;
|
|
|
+ BigDecimal priceTemp = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ List<TPromoCode> yhjList = new ArrayList<>();
|
|
|
+ if(StringUtils.isNotEmpty(coupons)){
|
|
|
+ String[] cous = coupons.split(",");
|
|
|
+ if(cous.length>0){
|
|
|
+ for(int i = 0 ;i<cous.length ; i++){
|
|
|
+ if(StringUtils.isNotEmpty(cous[i])){
|
|
|
+ TPromoCode yhj = R.getDataIfSuccess(szwlFeign.getYHJ(cous[i]));
|
|
|
+ if(yhj!=null&&yhj.getId()!=null){
|
|
|
+ String isUse = yhj.getIsUse();
|
|
|
+ if(isUse.equals("1")){
|
|
|
+ return R.ok(yhj.getCode(),"优惠券已使用");
|
|
|
+ }
|
|
|
+ Date lastUseDate = yhj.getLastUseDate();
|
|
|
+ Date date = new Date();
|
|
|
+ if(date.getTime()>lastUseDate.getTime()){
|
|
|
+ return R.ok(yhj.getCode(),"优惠券已过期");
|
|
|
+ }
|
|
|
+ yhjList.add(yhj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> couponList = new ArrayList<>();
|
|
|
+ //营销金额
|
|
|
BigDecimal marketingAmount = null;
|
|
|
+ if(yhjList.size()>0){
|
|
|
+ for(TPromoCode yhj:yhjList){
|
|
|
+ if(yhj!=null&&yhj.getId()!=null){
|
|
|
+ if(marketingAmount==null){
|
|
|
+ marketingAmount = new BigDecimal("0.00");
|
|
|
+ }
|
|
|
+ marketingAmount =marketingAmount.add(new BigDecimal(yhj.getDiscount()).setScale(2, RoundingMode.HALF_DOWN));
|
|
|
+ couponList.add(String.valueOf(yhj.getCode()));
|
|
|
+ if(marketingAmount.compareTo(price)>=0){
|
|
|
+ marketingAmount = priceTemp.subtract(new BigDecimal("0.01"));
|
|
|
+ price = new BigDecimal("0.01").setScale(2, RoundingMode.HALF_DOWN);
|
|
|
+ break;
|
|
|
+ }else {
|
|
|
+ price = price.subtract(marketingAmount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
String frpCode1 = "WEIXIN_XCX";
|
|
|
// String frpCode2 = "ALIPAY_NATIVE";
|
|
|
-
|
|
|
+ BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
TOrder order = new TOrder();
|
|
|
order.setCreateDate(new Date());
|
|
|
order.setModifyDate(new Date());
|
|
@@ -2309,6 +2353,9 @@ public class TOrderController {
|
|
|
order.setAltInfo(altInfo.toString());
|
|
|
order.setStatus(0);
|
|
|
order.setType(type);
|
|
|
+ if(couponList.size()>0){
|
|
|
+ order.setCoupons(couponList.toString());
|
|
|
+ }
|
|
|
if(type==0){
|
|
|
order.setAdminProportion(adminProportion);
|
|
|
order.setAgencyProportion(agencyProportion);
|
|
@@ -2470,7 +2517,10 @@ public class TOrderController {
|
|
|
TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
// String gtClientId = byClientId.getGtClientId();
|
|
|
if(order.getFrpCode().equals("WEIXIN_XCX")){
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("cardPayXCX", order.getProductDesc()).toString());
|
|
|
+ JSONObject kindData1 = new JSONObject();
|
|
|
+ kindData1.put("sn", order.getSn());
|
|
|
+ kindData1.put("productDesc", order.getProductDesc());
|
|
|
+ equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("cardPayXCX", kindData1.toString()).toString());
|
|
|
TSzsmWx szsmWx = szsmWxService.getById(order.getWxId());
|
|
|
BigDecimal integral = szsmWx.getIntegral();
|
|
|
if(integral!=null){
|
|
@@ -2480,6 +2530,16 @@ public class TOrderController {
|
|
|
}
|
|
|
szsmWx.setIntegral(integral);
|
|
|
szsmWxService.updateById(szsmWx);
|
|
|
+ if(StringUtils.isNotEmpty(order.getCoupons())){
|
|
|
+ String coupons = order.getCoupons();
|
|
|
+ coupons= coupons.substring(1,coupons.length()-1);
|
|
|
+ List<String> list1 = Arrays.asList(coupons);
|
|
|
+ if(list1.size()>0){
|
|
|
+ for(String code:list1){
|
|
|
+ szwlFeign.useYHJ(code, String.valueOf(order.getAdminId()),order.getClientId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}else {
|
|
|
equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
}
|
|
@@ -2854,7 +2914,17 @@ public class TOrderController {
|
|
|
order.setRefundAmount(new BigDecimal(request.getParameter("r4_RefundAmount_str")));
|
|
|
}
|
|
|
order.setStatus(1);
|
|
|
- order.setPrice(price.divide(r4_refundAmount));
|
|
|
+ order.setPrice(price.subtract(r4_refundAmount));
|
|
|
+ }
|
|
|
+ if(r4_refundAmount.compareTo(price)==0){
|
|
|
+ BigDecimal refundAmount = order.getRefundAmount();
|
|
|
+ if(refundAmount!=null){
|
|
|
+ order.setRefundAmount(refundAmount.add(r4_refundAmount));
|
|
|
+ order.setPrice(order.getPrice().add(r4_refundAmount));
|
|
|
+ }else {
|
|
|
+ // 退款金额
|
|
|
+ order.setRefundAmount(new BigDecimal(request.getParameter("r4_RefundAmount_str")));
|
|
|
+ }
|
|
|
}
|
|
|
// 退款金额
|
|
|
order.setRefundAmount(new BigDecimal(request.getParameter("r4_RefundAmount_str")));
|