yeguodong 2 weeks ago
parent
commit
b2190f4149

+ 2 - 2
src/main/java/cn/hnthyy/thmz/service/pay/NongPayService.java

@@ -34,8 +34,8 @@ public class NongPayService {
         BigDecimal amountBigDecimal = new BigDecimal(amount);
         String payAmount = String.valueOf(amountBigDecimal.multiply(new BigDecimal(100)).setScale(0, RoundingMode.HALF_UP));
         // todo 测试写死1分钱
-        body.put("amount", "1");
-//        body.put("amount", payAmount);
+//        body.put("amount", "1");
+        body.put("amount", payAmount);
         body.put("subject", body.get("subject"));
         body.put("body", body.get("body"));
         JSONObject channelExtra = new JSONObject();

+ 26 - 2
src/main/java/cn/hnthyy/thmz/service/yb/YbService.java

@@ -87,7 +87,7 @@ public class YbService {
             e.printStackTrace();
             response = new ResultVo(-1, "商品销售失败");
         }
-        String id = UUID.randomUUID().toString().replaceAll("-", "");
+        /*String id = UUID.randomUUID().toString().replaceAll("-", "");
         selInfo.setId(id);
         int insertSelinfo = selinfoSoldMapper.insert(selInfo);
         if(insertSelinfo > 0) {
@@ -95,7 +95,7 @@ public class YbService {
                 String itemId = UUID.randomUUID().toString().replaceAll("-", "");
                 selinfoSoldMapper.insertSelinfoSoldDrugtrac(itemId, id, codg.getDrugTracCodg());
             }
-        }
+        }*/
 
 
         return response;
@@ -104,6 +104,30 @@ public class YbService {
     public ResultVo returnGoodsItem(SelinfoReturn selinfoReturn) {
         ResultVo response = null;
         List<DrugTracCodg> drugTracCodgList = selinfoReturn.getDrugtracinfo();
+        if(drugTracCodgList == null || drugTracCodgList.isEmpty()) {
+            response = new ResultVo(-1, "追溯码不能为空");
+            return response;
+        }
+        String drugTracCodg = drugTracCodgList.get(0).getDrugTracCodg();
+        String result = taobaoService.sendGet("/queryCodeDetail?codes=" + drugTracCodg);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        if (code == 200) {
+            JSONObject data = resultJson.getJSONObject("data");
+            Integer dataCode = data.getInteger("code");
+            if (dataCode == 0) {
+                JSONArray content = data.getJSONArray("data");
+                if(content != null && content.size() > 0) {
+                    JSONObject item = content.getJSONObject(0);
+                    JSONArray produceInfoList = item.getJSONObject("codeProduceInfoDTO").getJSONArray("produceInfoList");
+                    if(produceInfoList != null && produceInfoList.size() > 0) {
+                        JSONObject produceInfo = produceInfoList.getJSONObject(0);
+                        selinfoReturn.setManuLotnum(produceInfo.getString("batchNo"));
+                        selinfoReturn.setManuDate(produceInfo.getString("produceDateStr"));
+                    }
+                }
+            }
+        }
         selinfoReturn.setSelRetnCnt(drugTracCodgList.size());
         String now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
         selinfoReturn.setSelRetnTime(now);