Ver Fonte

修改支付图片和小程序支付金额

huan.wang@yueguanjia.com há 5 anos atrás
pai
commit
10346555cc

+ 21 - 13
src/main/java/com/ygj/yuemum/controller/admin/ImageUploadController.java

@@ -22,7 +22,9 @@ import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Api(tags = "图片、简历相关接口")
 @RestController
@@ -352,35 +354,41 @@ import java.util.List;
 
     @RequestMapping(value = "/uploadPayImg", method = RequestMethod.POST)
     @ResponseBody
-    public int uploadPayImg(@RequestParam("file") MultipartFile file,
-                            @RequestParam(value = "eh_code") String eh_code,
-                            @RequestParam(value = "cv_orderstaus") Integer cv_orderstaus) {
+    public Map<String, String> uploadPayImg(@RequestParam("file") MultipartFile file,
+                                            @RequestParam(value = "eh_code") String eh_code,
+                                            @RequestParam(value = "out_trade_no") String out_trade_no,
+                                            @RequestParam(value = "cv_orderstaus") Integer cv_orderstaus) {
         int dot = file.getOriginalFilename().lastIndexOf('.');
         String newName = file.getOriginalFilename().substring(dot);
         CustomerPayVoucher customerPayVoucher = new CustomerPayVoucher();
         if (file.isEmpty()) {
-            return 0;
+            return null;
         }
         Date date = new Date();
         DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
         File dest = new File(payvoucher + "/" + eh_code + sdf.format(date) + newName);
+        Map<String, String> tableData = new HashMap<>();
+        tableData.put("url",httppayvoucher + "/" + eh_code + sdf.format(date) + newName);
+        tableData.put("filename",eh_code + sdf.format(date) + newName);
         // 删除
         try {
             file.transferTo(dest); //保存文件
-            customerPayVoucher.setEh_code(eh_code);
-            customerPayVoucher.setCv_filename(eh_code + sdf.format(date) + newName);
-            customerPayVoucher.setCv_orderstaus(cv_orderstaus);
-            customerPayVoucher.setCv_filepath(httppayvoucher + "/" + eh_code + sdf.format(date) + newName);
-            customerPayVoucherService.insertCustomerPayVoucher(customerPayVoucher);
-            return 1;
+            //先不保存凭证呢
+//            customerPayVoucher.setEh_code(eh_code);
+//            customerPayVoucher.setCv_filename(eh_code + sdf.format(date) + newName);
+//            customerPayVoucher.setCv_orderstaus(cv_orderstaus);
+//            customerPayVoucher.setOut_trade_no(out_trade_no);
+//            customerPayVoucher.setCv_filepath(httppayvoucher + "/" + eh_code + sdf.format(date) + newName);
+//            customerPayVoucherService.insertCustomerPayVoucher(customerPayVoucher);
+            return  tableData;
         } catch (IllegalStateException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-            return 0;
+            return null;
         } catch (IOException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-            return 0;
+            return null;
         }
     }
 
@@ -390,7 +398,7 @@ import java.util.List;
             String path = payvoucher + "/" + cv_filename;
             File dest = new File(path);
             dest.delete();
-            return customerPayVoucherService.deleteCustomerPayVoucher(cv_filename);
+            return 1;
         } catch (Exception ex) {
             ex.printStackTrace();
             return 0;

+ 1 - 0
src/main/java/com/ygj/yuemum/controller/order/YSOrderController.java

@@ -84,6 +84,7 @@ public class YSOrderController {
         tableData.put("orderInfo", order);
         tableData.put("orderPay",customerPays);
         tableData.put("paySum",paySum);
+        tableData.put("customerPay",order.getOd_order_pay_amount());
         return tableData;
     }
 

+ 5 - 0
src/main/java/com/ygj/yuemum/controller/pay/CustomerPayVoucherController.java

@@ -24,4 +24,9 @@ public class CustomerPayVoucherController {
         return customerPayVoucherService.queryVoucherByTradeNo(out_trade_no);
     }
 
+    @GetMapping("/checkOutTradeNo")
+    public int checkOutTradeNo(@RequestParam("out_trade_no") String out_trade_no) {
+        return customerPayVoucherService.checkOutTradeNo(out_trade_no);
+    }
+
 }

+ 1 - 0
src/main/java/com/ygj/yuemum/dao/pay/CustomerPayVoucherDao.java

@@ -15,4 +15,5 @@ public interface CustomerPayVoucherDao {
     int deleteCustomerPayVoucherAll(String eh_code);
     int deleteOrderPayPhoto(CustomerPayVoucher customerPayVoucher);
     CustomerPayVoucher queryVoucherByTradeNo(String out_trade_no);
+    int checkOutTradeNo(String out_trade_no);
 }

+ 5 - 2
src/main/java/com/ygj/yuemum/service/order/YSOrderService.java

@@ -134,7 +134,7 @@ public class YSOrderService {
 
 
     public YSOrder getYSOrder(Integer id) {
-        YSOrder ysOrder = YSOrderDao.selectByPrimaryKey(id);
+            YSOrder ysOrder = YSOrderDao.selectByPrimaryKey(id);
         //获取产品信息
         Packages packages = packagesService.getRatioById(ysOrder.getOd_product_id());
         float discount =   ysOrder.getOd_mgm_discount() + ysOrder.getOd_other_discount() + ysOrder.getOd_promotion_discount();
@@ -150,7 +150,10 @@ public class YSOrderService {
                 if (customerPays.size() >= ratioArray.length) {
                     ysOrder.setOd_order_pay_amount((ysOrder.getOd_order_amount() - discount) - pay_sum);
                 } else {
-                    ysOrder.setOd_order_pay_amount((ysOrder.getOd_order_amount() - discount) * Float.parseFloat(ratioArray[customerPays.size()]));
+                    double ration = Double.valueOf(ratioArray[customerPays.size()]);
+                    double orderAmount = Double.valueOf(ysOrder.getOd_order_amount() - discount);
+                    double customerPay = ration * orderAmount;
+                    ysOrder.setOd_order_pay_amount((float) customerPay);
                 }
                 if(pay_sum + ysOrder.getOd_order_pay_amount() > ysOrder.getOd_order_amount()) {
                     ysOrder.setOd_order_pay_amount((ysOrder.getOd_order_amount() - discount) - pay_sum);

+ 15 - 0
src/main/java/com/ygj/yuemum/service/pay/CustomerPayService.java

@@ -10,6 +10,7 @@ import com.ygj.yuemum.domain.equipment.EquipmenteHireDetail;
 import com.ygj.yuemum.domain.equipment.EquipmenteHireHead;
 import com.ygj.yuemum.domain.order.YSOrder;
 import com.ygj.yuemum.domain.pay.CustomerPay;
+import com.ygj.yuemum.domain.pay.CustomerPayVoucher;
 import com.ygj.yuemum.service.equipment.EquipmentInfoService;
 import com.ygj.yuemum.service.equipment.EquipmentLogService;
 import com.ygj.yuemum.service.order.YSOrderService;
@@ -48,6 +49,8 @@ public class CustomerPayService {
     private YSOrderService ysOrderService;
     @Autowired
     private PayMentsService payMentsService;
+    @Autowired
+    private CustomerPayVoucherService customerPayVoucherService;
 
     public List<CustomerPay> selectCustomerPay(String cp_orderno) {
         return customerPayDao.selectCustomerPay(cp_orderno);
@@ -103,6 +106,9 @@ public class CustomerPayService {
     }
 
     public int insertYsOrderPay(CustomerPay customerPay) {
+        if (customerPayVoucherService.checkOutTradeNo(customerPay.getOut_trade_no()) > 0) {
+            return 99;
+        }
         if (customerPay.getOut_trade_no() == null ) {  //没有流水号
             List<CustomerPay> customerPayOlds = customerPayDao.selectCustomerPay(customerPay.getCp_orderno());
             if (customerPayOlds != null && customerPayOlds.size() > 0) {
@@ -116,6 +122,15 @@ public class CustomerPayService {
                 customerPay.setCp_paytype("1");
             }
         }
+        if (customerPay.getCv_filepath() != null) {
+            CustomerPayVoucher customerPayVoucher = new CustomerPayVoucher();
+            customerPayVoucher.setEh_code(customerPay.getCp_orderno());
+            customerPayVoucher.setCv_orderstaus(customerPay.getCp_orderstatus());
+            customerPayVoucher.setCv_filepath(customerPay.getCv_filepath());
+            customerPayVoucher.setOut_trade_no(customerPay.getOut_trade_no());
+            customerPayVoucherService.insertCustomerPayVoucher(customerPayVoucher);
+        }
+
         try {
             YSOrder ysOrder = ysOrderService.selectByOdNo(customerPay.getCp_orderno());
             BigDecimal amount = new BigDecimal(String.valueOf(ysOrder.getOd_order_amount()));

+ 4 - 0
src/main/java/com/ygj/yuemum/service/pay/CustomerPayVoucherService.java

@@ -39,5 +39,9 @@ public class CustomerPayVoucherService {
         return customerPayVoucherDao.deleteOrderPayPhoto(customerPayVoucher);
     }
 
+    public int checkOutTradeNo (String out_trade_no){
+        return customerPayVoucherDao.checkOutTradeNo(out_trade_no);
+    }
+
 
 }

+ 9 - 0
src/main/resources/mybatis/mapper/pay/CustomerPayVoucherMapper.xml

@@ -99,4 +99,13 @@
         where eh_code = #{eh_code,jdbcType=VARCHAR}
         and cv_orderstaus = #{cv_orderstaus,jdbcType=INTEGER}
     </delete>
+
+
+    <select id="checkOutTradeNo" resultType="java.lang.Integer" parameterType="java.lang.String" >
+        select
+        count(1)
+        from customer_pay_voucher
+        where out_trade_no = #{out_trade_no,jdbcType=VARCHAR}
+        order by id desc
+    </select>
 </mapper>