浏览代码

增加,乐器和配件配置文件

周箭河 5 年之前
父节点
当前提交
bbfd570f89

+ 57 - 11
src/main/java/com/ym/mec/collectfee/controller/YqPayController.java

@@ -27,6 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 
 import java.io.InputStreamReader;
+import java.io.SyncFailedException;
 import java.math.BigDecimal;
 import java.util.*;
 
@@ -59,17 +60,60 @@ public class YqPayController extends BaseController {
     @ApiOperation(value = "提交支付", notes = "易乾支付统一下单")
     @PostMapping("/toPay")
     @Transactional
-    public Map toPay(@ModelAttribute @Validated Order order) throws Exception {
+    public Object toPay(@ModelAttribute @Validated Order order) throws Exception {
+        BigDecimal amount = new BigDecimal("0");
+        //1、判断已报名人数
+        CourseGroupInfo courseGroupInfo = CourseGroupInfoService.get(order.getCourseId());
+        if (courseGroupInfo.getRegNum() >= courseGroupInfo.getPlanNum()) {
+            return failed("乐团人数暂时已满,请稍后再试");
+        }
+
+        //课程组价格
+        BigDecimal courseFee = courseGroupInfo.getFeeAmount();
+        amount = amount.add(courseFee);
+
+        ClassPathResource classPathResource = new ClassPathResource("instruments.json");
+
+        BigDecimal instrumentPrice = new BigDecimal("0");//乐器价格
+        String instrumentName = "";//乐器名称
 
-        //2、判断已报名人数
-        CourseGroupInfo courseGroupInfo = CourseGroupInfoService.get(order.getCourse_id());
+        //获取乐器的价格
+        String instrumentId = order.getInstrument();
+        String jsonString = IOUtils.toString(new InputStreamReader(classPathResource.getInputStream(), "UTF-8"));
+        Instrument instrument = JSONObject.parseObject(jsonString, Instrument.class);
+
+        if (order.getInstrument() != null && !order.getInstrument().isEmpty()) {
+            instrumentPrice = new BigDecimal(instrument.getInstruments().get(instrumentId).get("referencePrice"));
+            instrumentName = (String) instrument.getInstruments().get(instrumentId).get("index") + "-" +
+                    (String) instrument.getInstruments().get(instrumentId).get("name");
+        }
+
+        //2 版本为3.0( 26),不收乐器费用,收押金800放乐器费用
+        if (courseGroupInfo.getFeeType().equals("26")) {
+            instrumentPrice = new BigDecimal("800");
+        }
+        amount = amount.add(instrumentPrice);
+
+        //辅件价格
+        String adjunctIds = order.getAdjunct();
+        BigDecimal adjunctPrice = new BigDecimal("0");//辅件价格
+        String adjunctName = "";//辅件名称
+        if (adjunctIds != null && !adjunctIds.isEmpty()) {
+            String[] adjunctIdArr = adjunctIds.split(",");
+            for (String adjunctId : adjunctIdArr) {
+                adjunctPrice = adjunctPrice.add(new BigDecimal(instrument.getAuxiliaries().get(adjunctId).get("referencePrice")));
+                adjunctName += (String) instrument.getAuxiliaries().get(adjunctId).get("name") + "|";
+            }
+        }
+
+        amount = amount.add(adjunctPrice);
+        order.setAmount(amount);
+        order.setRemark(instrumentName);
+        order.setTuiFee(courseFee);
+        order.setGoodsFee(instrumentPrice);
+        order.setSdName(adjunctName + "教材|琴谱");
+        order.setSdFee(adjunctPrice);
 
-//        ClassPathResource classPathResource = new ClassPathResource("instruments.json");
-//
-//        String str = IOUtils.toString(new InputStreamReader(classPathResource.getInputStream(),"UTF-8"));
-//        Instrument instrument = JSONObject.parseObject(str, Instrument.class);
-//
-//        System.out.println(instrument.getInstruments().get("flute").get("config"));
 
         String notifyUrl = "http://47.99.212.176:9000/yqpay/notify"; //异步通知地址
         String returnUrl = "http://dev.dayaedu.com";//支付后返回页面
@@ -101,11 +145,12 @@ public class YqPayController extends BaseController {
         List<Map> tempRoutingList = new ArrayList();
         tempRoutingList.add(routingList);
 
+        order.setAccount(routingMerNo);
 
         //1、插入订单
         orderService.insert(order);
         //2、修改已报名人数
-        courseGroupInfo.setRegNum(courseGroupInfo.getRegNum()+1);
+        courseGroupInfo.setRegNum(courseGroupInfo.getRegNum() + 1);
         CourseGroupInfoService.upByIdAndVersion(courseGroupInfo);
         //3、修改分佣账户已收金额
         accountService.upByIdAndVersion(account);
@@ -130,7 +175,8 @@ public class YqPayController extends BaseController {
         resultMap.put("tempRoutingList", JSON.toJSONString(tempRoutingList));//分账设置
         Map rqMap = new YqPayUtil(notifyUrl, resultMap).getRequestMap();
         rqMap.put("host", payUrl);
-        return rqMap;
+
+        return succeed(rqMap);
     }
 
     /**

+ 17 - 4
src/main/java/com/ym/mec/collectfee/entity/Instrument.java

@@ -1,10 +1,23 @@
 package com.ym.mec.collectfee.entity;
-
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 
 public class Instrument {
-    private Map<String, Map<String,Map>> instruments;
+    private Map<String, Map<String,String>> instruments;
+    private Map<String, Map<String,String>> auxiliaries;
+
+    public Map<String, Map<String, String>> getInstruments() {
+        return instruments;
+    }
+
+    public void setInstruments(Map<String, Map<String, String>> instruments) {
+        this.instruments = instruments;
+    }
+
+    public Map<String, Map<String, String>> getAuxiliaries() {
+        return auxiliaries;
+    }
 
+    public void setAuxiliaries(Map<String, Map<String, String>> auxiliaries) {
+        this.auxiliaries = auxiliaries;
+    }
 }

+ 9 - 21
src/main/java/com/ym/mec/collectfee/entity/Order.java

@@ -83,7 +83,7 @@ public class Order {
 
 	/** 课程组信息 */
 	@ApiModelProperty(name = "courseId", value = "课程组id",required = true)
-	private String courseId;
+	private Integer courseId;
 
 	/** 声部 */
 	@ApiModelProperty(name = "voicyPart", value = "声部")
@@ -97,10 +97,6 @@ public class Order {
 	@ApiModelProperty(name = "batchNum", value = "批次号",hidden = true)
 	private String batchNum;
 
-	/** 课程 */
-	@ApiModelProperty(name = "course", value = "课程内容-价格(以json内容)",required = true)
-	private String course;
-
 	/** 乐器 */
 	@ApiModelProperty(name = "instrument", value = "乐器")
 	private String instrument;
@@ -113,21 +109,20 @@ public class Order {
 	@ApiModelProperty(name = "other", value = "其他")
 	private String other;
 
-	/** 课程组id */
-	@ApiModelProperty(name = "course_id", value = "课程组id")
-	private Integer course_id;
-
-
 	//学费金额(元)。本次缴纳的学费金额。
+	@ApiModelProperty(name = "tuiFee", value = "学费金额",hidden = true)
 	private BigDecimal tuiFee;
 
 	//乐器费用(元)
+	@ApiModelProperty(name = "goodsFee", value = "乐器费用",hidden = true)
 	private BigDecimal goodsFee;
 
 	//杂费金额(元)
+	@ApiModelProperty(name = "goodsFee", value = "杂费金额",hidden = true)
 	private BigDecimal sdFee;
 
 	//杂费名称,如:乐保、教谱等。
+	@ApiModelProperty(name = "goodsFee", value = "杂费名称",hidden = true)
 	private String sdName;
 
 	public BigDecimal getTuiFee() {
@@ -323,13 +318,6 @@ public class Order {
 		this.orderNo = orderNo;
 	}
 
-	public String getCourse() {
-		return course;
-	}
-
-	public void setCourse(String course) {
-		this.course = course;
-	}
 
 	public String getInstrument() {
 		return instrument;
@@ -368,11 +356,11 @@ public class Order {
 		this.branchId = branchId;
 	}
 
-	public Integer getCourse_id() {
-		return course_id;
+	public Integer getCourseId() {
+		return courseId;
 	}
 
-	public void setCourse_id(Integer course_id) {
-		this.course_id = course_id;
+	public void setCourseId(Integer courseId) {
+		this.courseId = courseId;
 	}
 }

+ 1 - 1
src/main/resources/config/mybatis/OrderMapper.xml

@@ -50,7 +50,7 @@
 		SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
 		</selectKey>
 		-->
-		INSERT INTO `order` (id,oid,order_no,branch_id,user_id,amount,pay,bank,account,u_account,pay_id,pay_time,remark,class_id,status,create_time,po_name,voicy_part,balance,batch_num) VALUES(#{id},#{oid},#{branchId},#{orderNo},#{userId},#{amount},#{pay},#{bank},#{account},#{uAccount},#{payId},#{payTime},#{remark},#{classId},#{status},#{createTime},#{poName},#{voicyPart},#{balance},#{batchNum})
+		INSERT INTO `order` (id,oid,order_no,branch_id,user_id,amount,pay,bank,account,u_account,pay_id,pay_time,remark,class_id,status,create_time,po_name,voicy_part,balance,batch_num,tui_fee,goods_fee,sd_name,sd_fee) VALUES(#{id},#{oid},#{orderNo},#{branchId},#{userId},#{amount},#{pay},#{bank},#{account},#{uAccount},#{payId},#{payTime},#{remark},#{classId},#{status},#{createTime},#{poName},#{voicyPart},#{balance},#{batchNum},#{tuiFee},#{goodsFee},#{sdName},#{sdFee})
 	</insert>
 
 	<!-- 根据主键查询一条记录 -->

+ 150 - 354
src/main/resources/instruments.json

@@ -1,366 +1,162 @@
 {
   "instruments": {
-    "flute": {
-      "name": "长笛",
-      "config": {
-        "初级配置": {
-          "default": 1,
-          "name": "初级配置",
-          "marketPrice": 3150,
-          "referencePrice": 2680,
-          "checked": true,
-          "texture": "白铜管体"
-        },
-        "初级配置": {
-          "default": 0,
-          "name": "标准配置",
-          "marketPrice": 4500,
-          "referencePrice": 3570,
-          "checked": false,
-          "texture": "进口镍白铜管体、法式键"
-        }
-      },
-      "configuration": "C调 表面镀银厚度:8μm  管材厚度:0.42mm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "referencePrice": 95,
-          "checked": false
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "referencePrice": 65,
-          "checked": false
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "referencePrice": 300,
-          "checked": false
-        }
-      ]
+    "1": {
+      "index": "长笛",
+      "default": 1,
+      "name": "初级配置",
+      "marketPrice": 3150,
+      "referencePrice": 2680,
+      "checked": true,
+      "texture": "白铜管体"
     },
-    "clarinet": {
-      "name": "单簧管",
-      "config": [
-        {
-          "default": 1,
-          "name": "初级配置",
-          "marketPrice": 3280,
-          "referencePrice": 2780,
-          "checked": true,
-          "texture": "胶木"
-        },
-        {
-          "default": 0,
-          "name": "标准配置",
-          "marketPrice": 4580,
-          "referencePrice": 3650,
-          "checked": false,
-          "texture": "聚碳酸酯、蓝钢针弹簧线"
-        }
-      ],
-      "configuration": "降B调、八字螺丝固定键柱 按键铍铜、镍白铜 喇叭口直径:8cm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "软木膏",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "哨片",
-          "marketPrice": 150,
-          "checked": false,
-          "referencePrice": 120
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "2": {
+      "index": "长笛",
+      "default": 0,
+      "name": "标准配置",
+      "marketPrice": 4500,
+      "referencePrice": 3570,
+      "checked": false,
+      "texture": "进口镍白铜管体、法式键"
     },
-    "saxophone": {
-      "name": "萨克斯管",
-      "config": [
-        {
-          "default": 1,
-          "name": "初级配置",
-          "marketPrice": 4200,
-          "referencePrice": 3550,
-          "checked": true,
-          "texture": "/"
-        },
-        {
-          "default": 0,
-          "name": "标准配置",
-          "marketPrice": 6080,
-          "referencePrice": 4500,
-          "checked": false,
-          "texture": "68铜、实心保护盖、蓝钢针弹簧线"
-        }
-      ],
-      "configuration": "降E调、黄铜材质、表面电泳处理 喇叭口直径:11.8cm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "软木膏",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "哨片",
-          "marketPrice": 150,
-          "checked": false,
-          "referencePrice": 120
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "3": {
+      "index": "单簧管",
+      "default": 1,
+      "name": "初级配置",
+      "marketPrice": 3280,
+      "referencePrice": 2780,
+      "checked": true,
+      "texture": "胶木"
     },
-    "trumpet": {
-      "name": "小号",
-      "config": [
-        {
-          "default": 1,
-          "name": "标准配置",
-          "marketPrice": 4800,
-          "referencePrice": 3650,
-          "checked": true,
-          "texture": "白铜变音管磷铜发音管"
-        }
-      ],
-      "configuration": "降B调 特殊结构:可调试调音管控制环 喇叭口直径:123mm 内管:11.66mm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "活塞油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "调音管油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "4": {
+      "index": "单簧管",
+      "default": 0,
+      "name": "标准配置",
+      "marketPrice": 4580,
+      "referencePrice": 3650,
+      "checked": false,
+      "texture": "聚碳酸酯、蓝钢针弹簧线"
     },
-    "trombone": {
-      "name": "长号",
-      "config": [
-        {
-          "default": 1,
-          "name": "标准配置",
-          "marketPrice": 5550,
-          "referencePrice": 3870,
-          "checked": true,
-          "texture": "白铜内外伸缩管"
-        }
-      ],
-      "configuration": "降B/F调、喇叭口:215mm、内管:13.9mm管:13.9mm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "活塞油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "拉杆油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "5": {
+      "index": "萨克斯管",
+      "default": 1,
+      "name": "初级配置",
+      "marketPrice": 4200,
+      "referencePrice": 3550,
+      "checked": true,
+      "texture": "/"
     },
-    "horn": {
-      "name": "圆号",
-      "config": [
-        {
-          "default": 1,
-          "name": "标准配置",
-          "marketPrice": 5500,
-          "referencePrice": 3910,
-          "checked": true,
-          "texture": "白铜变音管磷铜发音管"
-        }
-      ],
-      "configuration": "降B/F调、结构:双排管 喇叭口直径:306mm 内管:11.5mm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "活塞油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "调音管油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "6": {
+      "index": "萨克斯管",
+      "default": 0,
+      "name": "标准配置",
+      "marketPrice": 6080,
+      "referencePrice": 4500,
+      "checked": false,
+      "texture": "68铜、实心保护盖、蓝钢针弹簧线"
     },
-    "upperBass": {
-      "name": "上低音号",
-      "config": [
-        {
-          "default": 1,
-          "name": "标准配置",
-          "marketPrice": 5800,
-          "referencePrice": 3980,
-          "checked": true,
-          "texture": "白铜变音管磷铜发音管"
-        }
-      ],
-      "configuration": "降B调、结构:三立键 喇叭口直径:278mm、内管:13.4mm",
-      "auxiliaries": [
-        {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        },
-        {
-          "name": "活塞油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "调音管油",
-          "marketPrice": 30,
-          "checked": false,
-          "referencePrice": 25
-        },
-        {
-          "name": "乐器维护",
-          "marketPrice": 480,
-          "checked": false,
-          "referencePrice": 300
-        }
-      ]
+    "7": {
+      "index": "小号",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 4800,
+      "referencePrice": 3650,
+      "checked": true,
+      "texture": "白铜变音管磷铜发音管"
     },
-    "snareDrum": {
-      "name": "小军鼓",
-      "config": [
-        {
-          "default": 1,
-          "name": "标准配置",
-          "marketPrice": 3700,
-          "referencePrice": 3190,
-          "checked": true,
-          "texture": ""
-        }
-      ],
-      "configuration": "珍珠镍小军鼓,桦木鼓腔,高碳钢纱带",
-      "auxiliaries": {
-        "1": {
-          "name": "节拍器",
-          "marketPrice": 120,
-          "checked": false,
-          "referencePrice": 95
-        },
-        "2": {
-          "name": "谱架",
-          "marketPrice": 80,
-          "checked": false,
-          "referencePrice": 65
-        }
-      }
+    "8": {
+      "index": "长号",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 5550,
+      "referencePrice": 3870,
+      "checked": true,
+      "texture": "白铜内外伸缩管"
+    },
+    "9": {
+      "index": "圆号",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 5500,
+      "referencePrice": 3910,
+      "checked": true,
+      "texture": "白铜变音管磷铜发音管"
+    },
+    "10": {
+      "index": "上低音号",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 5800,
+      "referencePrice": 3980,
+      "checked": true,
+      "texture": "白铜变音管磷铜发音管"
+    },
+    "11": {
+      "index": "小军鼓",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 3700,
+      "referencePrice": 3190,
+      "checked": true,
+      "texture": ""
+    },
+    "99": {
+      "index": "小号",
+      "default": 1,
+      "name": "标准配置",
+      "marketPrice": 0,
+      "referencePrice": 0,
+      "checked": true,
+      "texture": "白铜内外伸缩管"
+    }
+  },
+  "auxiliaries": {
+    "1": {
+      "name": "节拍器",
+      "marketPrice": "120",
+      "checked": false,
+      "referencePrice": "95"
+    },
+    "2": {
+      "name": "谱架",
+      "marketPrice": "80",
+      "checked": false,
+      "referencePrice": "65"
+    },
+    "3": {
+      "name": "活塞油",
+      "marketPrice": "30",
+      "checked": false,
+      "referencePrice": "25"
+    },
+    "4": {
+      "name": "软木膏",
+      "marketPrice": "30",
+      "checked": false,
+      "referencePrice": "25"
+    },
+    "5": {
+      "name": "哨片",
+      "marketPrice": "150",
+      "checked": false,
+      "referencePrice": "120"
+    },
+    "6": {
+      "name": "拉杆油",
+      "marketPrice": "30",
+      "checked": false,
+      "referencePrice": "25"
+    },
+    "7": {
+      "name": "调音管油",
+      "marketPrice": "30",
+      "checked": false,
+      "referencePrice": "25"
+    },
+    "8": {
+      "name": "乐器维护",
+      "marketPrice": "480",
+      "checked": false,
+      "referencePrice": "300"
     }
   }
 }