|
@@ -60,333 +60,333 @@ public class TWeixinPayController {
|
|
TEquipmentService equipmentService;
|
|
TEquipmentService equipmentService;
|
|
|
|
|
|
|
|
|
|
- @ApiOperation(value = "购物车 请求在线支付 ")
|
|
|
|
- @PostMapping("/carsPay")
|
|
|
|
- public Object carsPay(String clientId, @RequestBody Map<String,String> productNameMap) {
|
|
|
|
- if(productNameMap==null){
|
|
|
|
- return JsonMessage.error("数据出错");
|
|
|
|
- }
|
|
|
|
- StringBuffer productName1 = new StringBuffer();
|
|
|
|
- StringBuffer note = new StringBuffer();
|
|
|
|
- StringBuffer productName = new StringBuffer();
|
|
|
|
- TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
|
- if(equipment==null||equipment.getId()==null){
|
|
|
|
- return JsonMessage.error("找不到设备");
|
|
|
|
- }
|
|
|
|
- BigDecimal price = new BigDecimal("0.00");
|
|
|
|
-// JSONObject mapList = JSON.parseObject(productNameMap);
|
|
|
|
- TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
|
- if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
|
- //1,type=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")){
|
|
|
|
- TPromoCode promoCode = new TPromoCode();
|
|
|
|
- ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
|
- TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
|
-// TPromoCode tPromoCode = R.getDataIfSuccess(szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString()));
|
|
|
|
- promoCode = tPromoCode;
|
|
|
|
- if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
|
- //不存在
|
|
|
|
- return JsonMessage.success("1");
|
|
|
|
- }
|
|
|
|
- Date lastUseDate = null;
|
|
|
|
- if (promoCode != null) {
|
|
|
|
- lastUseDate = promoCode.getLastUseDate();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
|
- promoCode.setIsUse("2");
|
|
|
|
- szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
|
- //过期
|
|
|
|
- return JsonMessage.success("4");
|
|
|
|
- }
|
|
|
|
- if (promoCode.getId() == null) {
|
|
|
|
- //不存在
|
|
|
|
- return JsonMessage.success("1");
|
|
|
|
- }
|
|
|
|
- if (promoCode.getIsUse().equals("1")) {
|
|
|
|
- //被使用
|
|
|
|
- return JsonMessage.success("2");
|
|
|
|
- }
|
|
|
|
- if(!promoCode.getAdminId().equals("1")){
|
|
|
|
- if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- //不是本机
|
|
|
|
- return JsonMessage.success("3");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (promoCode.getDiscount() == null) {
|
|
|
|
- //旧优惠码
|
|
|
|
- return JsonMessage.success("0");
|
|
|
|
- }
|
|
|
|
- if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
|
- //0折
|
|
|
|
- return JsonMessage.success("0");
|
|
|
|
- }
|
|
|
|
- promoCodeList.add(promoCode);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- String[] productNum = key.split("-");
|
|
|
|
- String productNamea = productNum[0];
|
|
|
|
- String num = productNum[1];
|
|
|
|
- productName.append(productNamea).append(num);
|
|
|
|
- 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()), productNamea));
|
|
|
|
- if (product == null) {
|
|
|
|
- return JsonMessage.error("找不到商品");
|
|
|
|
- }
|
|
|
|
- BigDecimal productPrice = product.getRmbPrice();
|
|
|
|
- if(promoCodeList.size()>0){
|
|
|
|
- //有优惠码
|
|
|
|
- BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
|
- int 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.valueOf(num)){
|
|
|
|
- int a = Integer.valueOf(num)-i;
|
|
|
|
- BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
- price =price.add(price2);
|
|
|
|
- onePrice = onePrice.add(price2);
|
|
|
|
- }
|
|
|
|
- note.append(onePrice).append(",");
|
|
|
|
- }else {
|
|
|
|
- //1,type=0,原始设定,没有第二件半价
|
|
|
|
- int a = Integer.valueOf(num);
|
|
|
|
- BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
- price =price.add(price2);
|
|
|
|
- note.append(price2).append(",");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }else {
|
|
|
|
- //2,type=1,第二件半价
|
|
|
|
- //2.1 判定是否有第二件,有多少个第二件半价
|
|
|
|
- for (String key : productNameMap.keySet()) {
|
|
|
|
-// System.out.println("key= "+ key + " and value= " + productNameMap.get(key));
|
|
|
|
- String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
|
- List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
|
- String[] productNum = key.split("-");
|
|
|
|
- String productNamea = productNum[0];
|
|
|
|
- String num = productNum[1];
|
|
|
|
- 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);
|
|
|
|
- note.append(productNamea).append(num).append(":");
|
|
|
|
- switch (num) {
|
|
|
|
- case "1":
|
|
|
|
- //1个 0个半价
|
|
|
|
- price =price.add(productPrice);
|
|
|
|
- note.append(price).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));
|
|
|
|
- note.append(price).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);
|
|
|
|
- note.append(price).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));
|
|
|
|
- note.append(price).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);
|
|
|
|
- note.append(price).append(",");
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (equipment == null) {
|
|
|
|
- return JsonMessage.error("找不到设备");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Long equipmentId = equipment.getId();
|
|
|
|
- //查找商品
|
|
|
|
-// TProduct product = R.getDataIfSuccess(szwlFeign.getProduct(String.valueOf(equipmentId), productName.toString()));
|
|
|
|
-// if (product == null) {
|
|
|
|
-// return JsonMessage.error("找不到商品");
|
|
|
|
|
|
+// @ApiOperation(value = "购物车 请求在线支付 ")
|
|
|
|
+// @PostMapping("/carsPay")
|
|
|
|
+// public Object carsPay(String clientId, @RequestBody Map<String,String> productNameMap) {
|
|
|
|
+// if(productNameMap==null){
|
|
|
|
+// return JsonMessage.error("数据出错");
|
|
|
|
+// }
|
|
|
|
+// StringBuffer productName1 = new StringBuffer();
|
|
|
|
+// StringBuffer note = new StringBuffer();
|
|
|
|
+// StringBuffer productName = new StringBuffer();
|
|
|
|
+// TEquipment equipment = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(clientId));
|
|
|
|
+// if(equipment==null||equipment.getId()==null){
|
|
|
|
+// return JsonMessage.error("找不到设备");
|
|
|
|
+// }
|
|
|
|
+// BigDecimal price = new BigDecimal("0.00");
|
|
|
|
+//// JSONObject mapList = JSON.parseObject(productNameMap);
|
|
|
|
+// TEquipmentDesc equipmentDesc = R.getDataIfSuccess(szwlFeign.findEquipmentById(equipment.getId()));
|
|
|
|
+// if(equipmentDesc==null||equipmentDesc.getEquipmentId()==null||equipmentDesc.getPayType()==null||equipmentDesc.getPayType().equals("0")){
|
|
|
|
+// //1,type=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")){
|
|
|
|
+// TPromoCode promoCode = new TPromoCode();
|
|
|
|
+// ResponseModel<TPromoCode> tPromoCodeResponseModel = szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString());
|
|
|
|
+// TPromoCode tPromoCode = tPromoCodeResponseModel.getData();
|
|
|
|
+//// TPromoCode tPromoCode = R.getDataIfSuccess(szwlFeign.selectTPromoCode(code, equipment.getAdminId().toString()));
|
|
|
|
+// promoCode = tPromoCode;
|
|
|
|
+// if (tPromoCode == null||tPromoCode.getId()==null) {
|
|
|
|
+// //不存在
|
|
|
|
+// return JsonMessage.success("1");
|
|
|
|
+// }
|
|
|
|
+// Date lastUseDate = null;
|
|
|
|
+// if (promoCode != null) {
|
|
|
|
+// lastUseDate = promoCode.getLastUseDate();
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (lastUseDate != null && lastUseDate.getTime() < ((new Date()).getTime())) {
|
|
|
|
+// promoCode.setIsUse("2");
|
|
|
|
+// szwlFeign.updatePromoCode(String.valueOf(promoCode.getId()),"2");
|
|
|
|
+// //过期
|
|
|
|
+// return JsonMessage.success("4");
|
|
|
|
+// }
|
|
|
|
+// if (promoCode.getId() == null) {
|
|
|
|
+// //不存在
|
|
|
|
+// return JsonMessage.success("1");
|
|
|
|
+// }
|
|
|
|
+// if (promoCode.getIsUse().equals("1")) {
|
|
|
|
+// //被使用
|
|
|
|
+// return JsonMessage.success("2");
|
|
|
|
+// }
|
|
|
|
+// if(!promoCode.getAdminId().equals("1")){
|
|
|
|
+// if (String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())) {
|
|
|
|
+//
|
|
|
|
+// } else {
|
|
|
|
+// //不是本机
|
|
|
|
+// return JsonMessage.success("3");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// if (promoCode.getDiscount() == null) {
|
|
|
|
+// //旧优惠码
|
|
|
|
+// return JsonMessage.success("0");
|
|
|
|
+// }
|
|
|
|
+// if (promoCode.getDiscount() != null && promoCode.getDiscount() == 0) {
|
|
|
|
+// //0折
|
|
|
|
+// return JsonMessage.success("0");
|
|
|
|
+// }
|
|
|
|
+// promoCodeList.add(promoCode);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// String[] productNum = key.split("-");
|
|
|
|
+// String productNamea = productNum[0];
|
|
|
|
+// String num = productNum[1];
|
|
|
|
+// productName.append(productNamea).append(num);
|
|
|
|
+// 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()), productNamea));
|
|
|
|
+// if (product == null) {
|
|
|
|
+// return JsonMessage.error("找不到商品");
|
|
|
|
+// }
|
|
|
|
+// BigDecimal productPrice = product.getRmbPrice();
|
|
|
|
+// if(promoCodeList.size()>0){
|
|
|
|
+// //有优惠码
|
|
|
|
+// BigDecimal onePrice = new BigDecimal("0.00");
|
|
|
|
+// int 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.valueOf(num)){
|
|
|
|
+// int a = Integer.valueOf(num)-i;
|
|
|
|
+// BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
+// price =price.add(price2);
|
|
|
|
+// onePrice = onePrice.add(price2);
|
|
|
|
+// }
|
|
|
|
+// note.append(onePrice).append(",");
|
|
|
|
+// }else {
|
|
|
|
+// //1,type=0,原始设定,没有第二件半价
|
|
|
|
+// int a = Integer.valueOf(num);
|
|
|
|
+// BigDecimal price2 = productPrice.multiply(new BigDecimal(a)).setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
+// price =price.add(price2);
|
|
|
|
+// note.append(price2).append(",");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }else {
|
|
|
|
+// //2,type=1,第二件半价
|
|
|
|
+// //2.1 判定是否有第二件,有多少个第二件半价
|
|
|
|
+// for (String key : productNameMap.keySet()) {
|
|
|
|
+//// System.out.println("key= "+ key + " and value= " + productNameMap.get(key));
|
|
|
|
+// String entryValue = String.valueOf(productNameMap.get(key));
|
|
|
|
+// List<String> value = JSON.parseArray(entryValue, String.class);
|
|
|
|
+// String[] productNum = key.split("-");
|
|
|
|
+// String productNamea = productNum[0];
|
|
|
|
+// String num = productNum[1];
|
|
|
|
+// 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);
|
|
|
|
+// note.append(productNamea).append(num).append(":");
|
|
|
|
+// switch (num) {
|
|
|
|
+// case "1":
|
|
|
|
+// //1个 0个半价
|
|
|
|
+// price =price.add(productPrice);
|
|
|
|
+// note.append(price).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));
|
|
|
|
+// note.append(price).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);
|
|
|
|
+// note.append(price).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));
|
|
|
|
+// note.append(price).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);
|
|
|
|
+// note.append(price).append(",");
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// if (equipment == null) {
|
|
|
|
+// return JsonMessage.error("找不到设备");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// Long equipmentId = equipment.getId();
|
|
|
|
+// //查找商品
|
|
|
|
+//// 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("商品价格异常");
|
|
|
|
+// }
|
|
|
|
+// Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
|
|
+// String sn1 = orderService.initSn(client6);
|
|
|
|
+// //获取分销 关联设备
|
|
|
|
+// TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
|
+// if (admin == null) {
|
|
|
|
+// return JsonMessage.error("找不到设备商家");
|
|
|
|
+// }
|
|
|
|
+// JSONArray altInfo = new JSONArray();
|
|
|
|
+// String orderNo1 = sn1;
|
|
|
|
+// BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
+// amount = amount.multiply(new BigDecimal(100));
|
|
|
|
+// String notifyUrl = JoinpayConstant.Notify_Url;
|
|
|
|
+// String frpCode1 = "WEIXIN_NATIVE";
|
|
|
|
+// TOrder order = new TOrder();
|
|
|
|
+// order.setId(IDGenerator.orderID());
|
|
|
|
+// order.setCreateDate(new Date());
|
|
|
|
+// order.setModifyDate(new Date());
|
|
|
|
+// order.setAdminId(admin.getId());
|
|
|
|
+// order.setSn(sn1);
|
|
|
|
+// order.setProductName(productName.toString());
|
|
|
|
+// order.setPrice(price);
|
|
|
|
+// order.setClientId(equipment.getClientId());
|
|
|
|
+// order.setEquipmentId(equipmentId);
|
|
|
|
+// order.setFrpCode(frpCode1);
|
|
|
|
+// order.setAltInfo(altInfo.toString());
|
|
|
|
+// order.setStatus(0);
|
|
|
|
+// String payPlatform = "3";
|
|
|
|
+// order.setPayPlatform(payPlatform);
|
|
|
|
+// if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
|
+// order.setIsSettlement("0");
|
|
|
|
+// }
|
|
|
|
+// order.setNote(note.toString());
|
|
|
|
+// orderService.save(order);
|
|
|
|
+// Iterator<Object> iterator = altInfo.iterator();
|
|
|
|
+// while (iterator.hasNext()) {
|
|
|
|
+// JSONObject jsonObject = (JSONObject) iterator.next();
|
|
|
|
+// String altAmount = jsonObject.getString("altAmount");
|
|
|
|
+// if (altAmount.equals("0.00")) {
|
|
|
|
+// iterator.remove();
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// String result = null;
|
|
|
|
+//
|
|
|
|
+// try {
|
|
|
|
+// result = orderService.weixinPay(
|
|
|
|
+// orderNo1, amount, productName.toString(), admin.getId(), notifyUrl
|
|
|
|
+// );
|
|
|
|
+// } catch (Exception e) {
|
|
|
|
+// e.printStackTrace();
|
|
|
|
+// return JsonMessage.error("申请支付失败");
|
|
|
|
+// }
|
|
|
|
+// // 微信支付支付申请返回支付二维码图片
|
|
|
|
+// JSONObject kindData = new JSONObject();
|
|
|
|
+// kindData.put("sn", sn1);
|
|
|
|
+// kindData.put("code_url", result);
|
|
|
|
+// return JsonMessage.success(kindData.toString());
|
|
// }
|
|
// }
|
|
-
|
|
|
|
- if (BigDecimal.ZERO.compareTo(price) >= 0) {
|
|
|
|
- return JsonMessage.error("商品价格异常");
|
|
|
|
- }
|
|
|
|
- Long client6 = Long.parseLong(clientId.substring(clientId.length() - 6));
|
|
|
|
- String sn1 = orderService.initSn(client6);
|
|
|
|
- //获取分销 关联设备
|
|
|
|
- TAdmin admin = R.getDataIfSuccess(szwlFeign.getAdmin(String.valueOf(equipment.getAdminId())));
|
|
|
|
- if (admin == null) {
|
|
|
|
- return JsonMessage.error("找不到设备商家");
|
|
|
|
- }
|
|
|
|
- JSONArray altInfo = new JSONArray();
|
|
|
|
- String orderNo1 = sn1;
|
|
|
|
- BigDecimal amount = price.setScale(2, RoundingMode.HALF_DOWN);
|
|
|
|
- amount = amount.multiply(new BigDecimal(100));
|
|
|
|
- String notifyUrl = JoinpayConstant.Notify_Url;
|
|
|
|
- String frpCode1 = "WEIXIN_NATIVE";
|
|
|
|
- TOrder order = new TOrder();
|
|
|
|
- order.setId(IDGenerator.orderID());
|
|
|
|
- order.setCreateDate(new Date());
|
|
|
|
- order.setModifyDate(new Date());
|
|
|
|
- order.setAdminId(admin.getId());
|
|
|
|
- order.setSn(sn1);
|
|
|
|
- order.setProductName(productName.toString());
|
|
|
|
- order.setPrice(price);
|
|
|
|
- order.setClientId(equipment.getClientId());
|
|
|
|
- order.setEquipmentId(equipmentId);
|
|
|
|
- order.setFrpCode(frpCode1);
|
|
|
|
- order.setAltInfo(altInfo.toString());
|
|
|
|
- order.setStatus(0);
|
|
|
|
- String payPlatform = "3";
|
|
|
|
- order.setPayPlatform(payPlatform);
|
|
|
|
- if(StringUtils.isNotEmpty(payPlatform)&&payPlatform.equals("1")){
|
|
|
|
- order.setIsSettlement("0");
|
|
|
|
- }
|
|
|
|
- order.setNote(note.toString());
|
|
|
|
- orderService.save(order);
|
|
|
|
- Iterator<Object> iterator = altInfo.iterator();
|
|
|
|
- while (iterator.hasNext()) {
|
|
|
|
- JSONObject jsonObject = (JSONObject) iterator.next();
|
|
|
|
- String altAmount = jsonObject.getString("altAmount");
|
|
|
|
- if (altAmount.equals("0.00")) {
|
|
|
|
- iterator.remove();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- String result = null;
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- result = orderService.weixinPay(
|
|
|
|
- orderNo1, amount, productName.toString(), admin.getId(), notifyUrl
|
|
|
|
- );
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- return JsonMessage.error("申请支付失败");
|
|
|
|
- }
|
|
|
|
- // 微信支付支付申请返回支付二维码图片
|
|
|
|
- JSONObject kindData = new JSONObject();
|
|
|
|
- kindData.put("sn", sn1);
|
|
|
|
- kindData.put("code_url", result);
|
|
|
|
- return JsonMessage.success(kindData.toString());
|
|
|
|
- }
|
|
|
|
/**
|
|
/**
|
|
* 成功回调 微信
|
|
* 成功回调 微信
|
|
*
|
|
*
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- @RequestMapping(value = "/notify", method = RequestMethod.POST)
|
|
|
|
- @ResponseBody
|
|
|
|
- public Object notify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
- Gson gson = new Gson();
|
|
|
|
- //应答对象
|
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
|
- String body = HttpUtils.readData(request);
|
|
|
|
- Map<String, Object> bodyMap = gson.fromJson(body, HashMap.class);
|
|
|
|
- //处理支付回调成功的订单
|
|
|
|
- String plainText = weixinPayConfigService.decryptFromResource(bodyMap);
|
|
|
|
- if(StringUtils.isNotEmpty(plainText)){
|
|
|
|
- JSONObject resultJson = JSONObject.parseObject(plainText);
|
|
|
|
- String sn = resultJson.getString("out_trade_no");
|
|
|
|
- if(StringUtils.isNotEmpty(sn)){
|
|
|
|
- LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
|
- query.eq(TOrder::getSn,sn);
|
|
|
|
- query.eq(TOrder::getStatus,0);
|
|
|
|
- TOrder order = orderService.getOne(query);
|
|
|
|
- order.setStatus(1);
|
|
|
|
- String success_time = resultJson.getString("success_time");
|
|
|
|
- Date date = new Date();
|
|
|
|
- try {
|
|
|
|
- date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(success_time);
|
|
|
|
- } catch (ParseException e) {
|
|
|
|
- //LOGGER.error("时间转换错误, string = {}", s, e);
|
|
|
|
- }
|
|
|
|
- order.setPayDate(date);
|
|
|
|
- order.setTrxNo(resultJson.getString("transaction_id"));
|
|
|
|
- orderService.updateById(order);
|
|
|
|
- TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
|
- JSONObject kindData = new JSONObject();
|
|
|
|
- kindData.put("sn", order.getSn());
|
|
|
|
- kindData.put("productName", order.getProductName());
|
|
|
|
- equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return "success";
|
|
|
|
- }
|
|
|
|
|
|
+// @RequestMapping(value = "/notify", method = RequestMethod.POST)
|
|
|
|
+// @ResponseBody
|
|
|
|
+// public Object notify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
|
+// Gson gson = new Gson();
|
|
|
|
+// //应答对象
|
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
|
+// String body = HttpUtils.readData(request);
|
|
|
|
+// Map<String, Object> bodyMap = gson.fromJson(body, HashMap.class);
|
|
|
|
+// //处理支付回调成功的订单
|
|
|
|
+// String plainText = weixinPayConfigService.decryptFromResource(bodyMap);
|
|
|
|
+// if(StringUtils.isNotEmpty(plainText)){
|
|
|
|
+// JSONObject resultJson = JSONObject.parseObject(plainText);
|
|
|
|
+// String sn = resultJson.getString("out_trade_no");
|
|
|
|
+// if(StringUtils.isNotEmpty(sn)){
|
|
|
|
+// LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
|
+// query.eq(TOrder::getSn,sn);
|
|
|
|
+// query.eq(TOrder::getStatus,0);
|
|
|
|
+// TOrder order = orderService.getOne(query);
|
|
|
|
+// order.setStatus(1);
|
|
|
|
+// String success_time = resultJson.getString("success_time");
|
|
|
|
+// Date date = new Date();
|
|
|
|
+// try {
|
|
|
|
+// date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(success_time);
|
|
|
|
+// } catch (ParseException e) {
|
|
|
|
+// //LOGGER.error("时间转换错误, string = {}", s, e);
|
|
|
|
+// }
|
|
|
|
+// order.setPayDate(date);
|
|
|
|
+// order.setTrxNo(resultJson.getString("transaction_id"));
|
|
|
|
+// orderService.updateById(order);
|
|
|
|
+// TEquipment byClientId = R.getDataIfSuccess(szwlFeign.findEquipmentByClientId(order.getClientId()));
|
|
|
|
+// JSONObject kindData = new JSONObject();
|
|
|
|
+// kindData.put("sn", order.getSn());
|
|
|
|
+// kindData.put("productName", order.getProductName());
|
|
|
|
+// equipmentService.sentMessage(byClientId.getClientId(), PushUtils.buildJson("pay_success", kindData.toString()).toString());
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// return "success";
|
|
|
|
+// }
|
|
|
|
|
|
- @ApiOperation(value = "退款")
|
|
|
|
- @GetMapping("/refund")
|
|
|
|
- ResponseModel<String> refund(@RequestParam String sn,@RequestParam BigDecimal refusePrice){
|
|
|
|
- if(StringUtils.isEmpty(sn)){
|
|
|
|
- return R.fail("订单为空/error");
|
|
|
|
- }
|
|
|
|
- LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
|
- query.eq(TOrder::getSn,sn);
|
|
|
|
- query.eq(TOrder::getStatus,1);
|
|
|
|
- TOrder order = orderService.getOne(query);
|
|
|
|
- if(order==null){
|
|
|
|
- return R.fail("订单为空/error");
|
|
|
|
- }
|
|
|
|
- CreateRequest createRequest = new CreateRequest();
|
|
|
|
- createRequest.setOutTradeNo(order.getSn());
|
|
|
|
- AmountReq amount = new AmountReq();
|
|
|
|
- amount.setRefund(refusePrice.multiply(new BigDecimal(100)).longValue());
|
|
|
|
- if(order.getRefundAmount()!=null){
|
|
|
|
- BigDecimal refusep = order.getPrice().add(order.getRefundAmount()).multiply(new BigDecimal(100));
|
|
|
|
- amount.setTotal(refusep.longValue());
|
|
|
|
- }else {
|
|
|
|
- BigDecimal multiply = order.getPrice().multiply(new BigDecimal(100));
|
|
|
|
- amount.setTotal(multiply.longValue());
|
|
|
|
- }
|
|
|
|
- amount.setCurrency("CNY");
|
|
|
|
- createRequest.setAmount(amount);
|
|
|
|
- Long client6 = Long.parseLong(order.getClientId().substring(order.getClientId().length() - 6));
|
|
|
|
- String refundNo = orderService.initSn(client6);
|
|
|
|
- createRequest.setOutRefundNo(refundNo);
|
|
|
|
- createRequest.setNotifyUrl("https://app.sunzee.com.cn/PAY-SERVER/tWeixinPay/refundNotify");
|
|
|
|
-// createRequest.setNotifyUrl("http://mianhuatang.gz2vip.91tunnel.com/tWeixinPay/refundNotify");
|
|
|
|
-// createRequest.setNotifyUrl("http://soobin.5gzvip.91tunnel.com/tWeixinPay/refundNotify");
|
|
|
|
- Refund refund = orderService.weixinRefundApi(createRequest,order.getAdminId());
|
|
|
|
- System.out.println("退款参数"+refund.toString());
|
|
|
|
- if(refund.getStatus()==PROCESSING){
|
|
|
|
- return R.ok("退款申请中,请30秒后再查询");
|
|
|
|
- }else {
|
|
|
|
- return R.ok("退款失败,请重试");
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- @ApiOperation(value = "退款成功回调")
|
|
|
|
- @PostMapping("/refundNotify")
|
|
|
|
- ResponseModel<String> refundNotify(HttpServletRequest request, HttpServletResponse response){
|
|
|
|
- String result = orderService.weixinRefund(request,response);
|
|
|
|
- return R.ok(result);
|
|
|
|
- };
|
|
|
|
|
|
+// @ApiOperation(value = "退款")
|
|
|
|
+// @GetMapping("/refund")
|
|
|
|
+// ResponseModel<String> refund(@RequestParam String sn,@RequestParam BigDecimal refusePrice){
|
|
|
|
+// if(StringUtils.isEmpty(sn)){
|
|
|
|
+// return R.fail("订单为空/error");
|
|
|
|
+// }
|
|
|
|
+// LambdaQueryWrapper<TOrder> query = Wrappers.lambdaQuery();
|
|
|
|
+// query.eq(TOrder::getSn,sn);
|
|
|
|
+// query.eq(TOrder::getStatus,1);
|
|
|
|
+// TOrder order = orderService.getOne(query);
|
|
|
|
+// if(order==null){
|
|
|
|
+// return R.fail("订单为空/error");
|
|
|
|
+// }
|
|
|
|
+// CreateRequest createRequest = new CreateRequest();
|
|
|
|
+// createRequest.setOutTradeNo(order.getSn());
|
|
|
|
+// AmountReq amount = new AmountReq();
|
|
|
|
+// amount.setRefund(refusePrice.multiply(new BigDecimal(100)).longValue());
|
|
|
|
+// if(order.getRefundAmount()!=null){
|
|
|
|
+// BigDecimal refusep = order.getPrice().add(order.getRefundAmount()).multiply(new BigDecimal(100));
|
|
|
|
+// amount.setTotal(refusep.longValue());
|
|
|
|
+// }else {
|
|
|
|
+// BigDecimal multiply = order.getPrice().multiply(new BigDecimal(100));
|
|
|
|
+// amount.setTotal(multiply.longValue());
|
|
|
|
+// }
|
|
|
|
+// amount.setCurrency("CNY");
|
|
|
|
+// createRequest.setAmount(amount);
|
|
|
|
+// Long client6 = Long.parseLong(order.getClientId().substring(order.getClientId().length() - 6));
|
|
|
|
+// String refundNo = orderService.initSn(client6);
|
|
|
|
+// createRequest.setOutRefundNo(refundNo);
|
|
|
|
+// createRequest.setNotifyUrl("https://app.sunzee.com.cn/PAY-SERVER/tWeixinPay/refundNotify");
|
|
|
|
+//// createRequest.setNotifyUrl("http://mianhuatang.gz2vip.91tunnel.com/tWeixinPay/refundNotify");
|
|
|
|
+//// createRequest.setNotifyUrl("http://soobin.5gzvip.91tunnel.com/tWeixinPay/refundNotify");
|
|
|
|
+// Refund refund = orderService.weixinRefundApi(createRequest, order.getAdminId());
|
|
|
|
+// System.out.println("退款参数"+refund.toString());
|
|
|
|
+// if(refund.getStatus()==PROCESSING){
|
|
|
|
+// return R.ok("退款申请中,请30秒后再查询");
|
|
|
|
+// }else {
|
|
|
|
+// return R.ok("退款失败,请重试");
|
|
|
|
+// }
|
|
|
|
+// };
|
|
|
|
+// @ApiOperation(value = "退款成功回调")
|
|
|
|
+// @PostMapping("/refundNotify")
|
|
|
|
+// ResponseModel<String> refundNotify(HttpServletRequest request, HttpServletResponse response){
|
|
|
|
+// String result = orderService.wechatRefund(request,response);
|
|
|
|
+// return R.ok(result);
|
|
|
|
+// };
|
|
}
|
|
}
|
|
|
|
|