Răsfoiți Sursa

接口完成

Pine 6 ani în urmă
părinte
comite
a558acd4f5

+ 10 - 10
db/demo_info.sql

@@ -20,20 +20,20 @@ SET FOREIGN_KEY_CHECKS = 0;
 -- ----------------------------
 -- Table structure for demo_info
 -- ----------------------------
-DROP TABLE IF EXISTS `user_info`;
-CREATE TABLE `user_info`  (
+DROP TABLE IF EXISTS `offline_payments`;
+CREATE TABLE `offline_payments`  (
   `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
-  `type` int(11) NULL DEFAULT NULL,
-  `status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
+  `car_order_id` bigint(11) NULL DEFAULT NULL,
+  `down_payment_status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '首付状态 0 未支付 1 已支付',
+  `invoice_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '发票地址',
+  `payType` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支付方式  1 全款 2 贷款',
+    `tail_status` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '尾款状态 0 未支付 1 已经支付',
+    `delivery_path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '交车证明',
+
   `create_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建时间',
   `update_time` timestamp(0) NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
   `del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT 'N',
-  `backup_a` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `backup_b` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `backup_c` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `backup_d` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
-  `backup_e` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
   PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '用户信息' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '线下支付详情' ROW_FORMAT = Dynamic;
 
 SET FOREIGN_KEY_CHECKS = 1;

+ 34 - 5
pine-admin/src/main/java/com/pine/admin/modules/business/controller/CarOrderController.java

@@ -23,7 +23,7 @@ import com.pine.admin.modules.business.service.CarOrderService;
  * @email 771190883@qq.com
  * @date 2019-07-22 21:11:49
  */
-@Api(value = "选配车订单表接口", tags = {"选配车订单表接口" })
+@Api(value = "选配车订单表接口", tags = {"选配车订单表接口"})
 @RestController
 @RequestMapping("business/CarOrder")
 public class CarOrderController extends BaseController {
@@ -51,7 +51,7 @@ public class CarOrderController extends BaseController {
     @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
     public Result getCarOrderEntity(@PathVariable("id") String id) {
 
-            CarOrder data = carOrderService.getById(id);
+        CarOrder data = carOrderService.getById(id);
         return Result.success(true, data);
     }
 
@@ -62,7 +62,7 @@ public class CarOrderController extends BaseController {
     @RequestMapping(value = "/getOne", method = RequestMethod.GET)
     public Result getOne(CarOrder record) {
 
-            CarOrder data = carOrderService.getOne(record);
+        CarOrder data = carOrderService.getOne(record);
         return Result.success(true, data);
     }
 
@@ -143,13 +143,42 @@ public class CarOrderController extends BaseController {
      */
     @PutMapping(value = "/offlineReview")
     @ApiOperation(value = "线下审核状态", notes = "线下审核状态")
-    public Result offlineReview(@RequestParam(required = true, value = "id") Long id, @RequestParam(required = true, value = "loanStatus")String loanStatus, @RequestParam(required = false, value = "downPaymentRate")BigDecimal  downPaymentRate) {
+    public Result offlineReview(@RequestParam(required = true, value = "id") Long id, @RequestParam(required = true, value = "loanStatus") String loanStatus, @RequestParam(required = false, value = "downPaymentRate") BigDecimal downPaymentRate) {
 
-        boolean num = carOrderService.offlineReview(id,loanStatus,downPaymentRate);
+        boolean num = carOrderService.offlineReview(id, loanStatus, downPaymentRate);
         if (num) {
             return Result.success(true, "线下审核成功");
         }
         return Result.error("线下审核异常");
     }
 
+
+    /**
+     * 支付,支付
+     */
+    @PutMapping(value = "/pay")
+    @ApiOperation(value = "支付", notes = "支付")
+    public Result pay(@RequestParam(required = true, value = "id") Long id, @RequestParam(required = true, value = "invoicePath") String invoicePath) {
+
+        boolean num = carOrderService.pay(id, invoicePath);
+        if (num) {
+            return Result.success(true, "支付修改成功");
+        }
+        return Result.error("支付修改异常");
+    }
+
+    /**
+     * 交车
+     */
+    @PutMapping(value = "/delivery")
+    @ApiOperation(value = "交车", notes = "交车")
+    public Result delivery(@RequestParam(required = true, value = "id") Long id, @RequestParam(required = true, value = "invoicePath") String invoicePath) {
+
+        boolean num = carOrderService.delivery(id, invoicePath);
+        if (num) {
+            return Result.success(true, "交车成功");
+        }
+        return Result.error("交车异常");
+    }
+
 }

+ 144 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/controller/OfflinePaymentsController.java

@@ -0,0 +1,144 @@
+package com.pine.admin.modules.business.controller;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.pine.common.dto.Page;
+import com.pine.admin.modules.base.binder.BaseController;
+import com.pine.common.dto.Result;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.RequestMethod;
+import com.pine.admin.modules.business.entity.OfflinePayments;
+import com.pine.admin.modules.business.service.OfflinePaymentsService;
+
+
+/**
+ * 线下支付详情
+ *
+ * @author Pine
+ * @email 771190883@qq.com
+ * @date 2019-07-25 18:38:56
+ */
+@Api(value = "线下支付详情接口", tags = {"线下支付详情接口" })
+//@RestController
+//@RequestMapping("business/OfflinePayments")
+public class OfflinePaymentsController extends BaseController {
+
+    @Autowired
+    private OfflinePaymentsService offlinePaymentsService;
+
+
+    /**
+     * <p>获取全部记录。</p>
+     */
+    @ApiOperation(value = "获取所有线下支付详情数据", notes = "可以根据条件获取")
+    @RequestMapping(value = "/all", method = RequestMethod.GET)
+    public Result all(OfflinePayments record) {
+
+        List<OfflinePayments> pp = offlinePaymentsService.getAllList(record);
+        return Result.success(true, pp);
+    }
+
+
+    /**
+     * <p>根据Id。</p>
+     */
+    @ApiOperation(value = "获取线下支付详情数据", notes = "根据id来获取线下支付详情详细信息")
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    public Result getOfflinePaymentsEntity(@PathVariable("id") String id) {
+
+            OfflinePayments data = offlinePaymentsService.getById(id);
+        return Result.success(true, data);
+    }
+
+    /**
+     * <p>根据条件获取。</p>
+     */
+    @ApiOperation(value = "获取线下支付详情数据", notes = "根据条件获取")
+    @RequestMapping(value = "/getOne", method = RequestMethod.GET)
+    public Result getOne(OfflinePayments record) {
+
+            OfflinePayments data = offlinePaymentsService.getOne(record);
+        return Result.success(true, data);
+    }
+
+    /**
+     * <p>分页查询。</p>
+     */
+    @ApiOperation(value = "分页获取线下支付详情数据", notes = "根据条件获取")
+    @RequestMapping(value = "/page", method = RequestMethod.GET)
+    public Result page(Page page, OfflinePayments record) {
+
+        Map<String, Object> result = new HashMap<>();
+
+        List<OfflinePayments> pp = offlinePaymentsService.getByPage(page, record);
+
+        result.put("page", page);
+        result.put("pp", pp);
+        return Result.success(true, result);
+    }
+
+    /**
+     * <p>保存。</p>
+     */
+    @ApiOperation(value = "新增一条线下支付详情数据", notes = "新增一条线下支付详情数据")
+    @RequestMapping(value = "/save", method = RequestMethod.POST)
+    public Result save(OfflinePayments record) {
+
+        boolean num = offlinePaymentsService.create(record);
+        if (num) {
+            return Result.success(true, record.getId());
+        }
+        return Result.error("保存异常");
+    }
+
+    /**
+     * <p>更新信息。</p>
+     */
+    @ApiOperation(value = "更新一条线下支付详情数据", notes = "更新一条线下支付详情数据")
+    @RequestMapping(value = "/update", method = RequestMethod.PUT)
+    public Result updateOfflinePayments(OfflinePayments record) {
+
+        boolean num = offlinePaymentsService.update(record);
+        if (num) {
+            return Result.success(true, "保存成功");
+        }
+        return Result.error("保存异常");
+    }
+
+    /**
+     * <p>删除。</p>
+     */
+    @RequestMapping(value = "/del/{id}", method = RequestMethod.DELETE)
+    @ApiOperation(value = "删除一条线下支付详情数据", notes = "根据Id一条线下支付详情数据")
+    public Result deleteOfflinePayments(@PathVariable("id") String id) {
+
+        boolean num = offlinePaymentsService.delete(id);
+        if (num) {
+            return Result.success(true, "删除成功");
+        }
+        return Result.error("删除异常");
+    }
+
+    /**
+     * <p>批量删除。</p>
+     */
+    @RequestMapping(value = "/deltetByIds", method = RequestMethod.DELETE)
+    @ApiOperation(value = "删除多条线下支付详情数据", notes = "删除id的集合多个用英文逗号分隔")
+    public Result delOfflinePaymentsAll(@RequestParam(required = true, value = "ids") String ids) {
+
+        boolean num = offlinePaymentsService.deltetByIds(ids);
+        if (num) {
+            return Result.success(true, "删除成功");
+        }
+        return Result.error("删除异常");
+    }
+
+}

+ 15 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/dao/OfflinePaymentsDao.java

@@ -0,0 +1,15 @@
+package com.pine.admin.modules.business.dao;
+
+import com.pine.admin.modules.business.entity.OfflinePayments;
+import com.pine.admin.modules.base.binder.BaseDao;
+
+/**
+ * 线下支付详情
+ *
+ * @author Pine
+ * @email 771190883@qq.com
+ * @date 2019-07-25 18:38:56
+ */
+public interface OfflinePaymentsDao extends BaseDao<OfflinePayments> {
+
+}

+ 61 - 64
pine-admin/src/main/java/com/pine/admin/modules/business/entity/CarOrder.java

@@ -1,18 +1,15 @@
 package com.pine.admin.modules.business.entity;
 
-        import java.math.BigDecimal;
+import java.math.BigDecimal;
 
-        import com.fasterxml.jackson.annotation.JsonFormat;
-        import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
 import lombok.Data;
-        import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.format.annotation.DateTimeFormat;
 
-        import java.io.Serializable;
+import java.io.Serializable;
 import java.util.Date;
 
 /**
@@ -75,62 +72,62 @@ public class CarOrder implements Serializable {
     private String carJson;
     /**
      * 车辆选配信息  json信息如下: var a = {
-    // 卡钳
-    "carCaliper": {
-        // 名称
-        "name": "卡钳",
-        // 价格
-        "price": 10,
-        // 类型5 卡钳
-        "type": "5",
-        // 选择的卡钳值
-        "value": "黑色卡钳"
-    },
-    // 车身颜色
-    "carColor": {
-        // 名称
-        "name": "车身颜色",
-        // 价格
-        "price": 10,
-        // 类型2 车身颜色
-        "type": "2",
-        // 颜色和材质值 用/分割
-        "value": "红色/基础版"
-    },
-    // 座椅
-    "carSeat": {
-        // 名称
-        "name": "座椅布局",
-        // 价格
-        "price": 10,
-        // 类型1 座椅
-        "type": "1",
-        // 座椅值
-        "value": "5座"
-    },
-    // 轮廓
-    "carWheelHub": {
-        // 名称
-        "name": "轮毂",
-        // 价格
-        "price": 10,
-        // 类型4 轮廓
-        "type": "4",
-        // 轮廓值
-        "value": "轮毂型号名称"
-    },
-    // 内饰
-    "catUpholstery": {
-        // 名称
-        "name": "内饰",
-        // 价格
-        "price": 10,
-        // 类型3 内饰
-        "type": "3",
-        // 内饰值
-        "value": "红黑条纹软包套件"
-    }
-};
+     * // 卡钳
+     * "carCaliper": {
+     * // 名称
+     * "name": "卡钳",
+     * // 价格
+     * "price": 10,
+     * // 类型5 卡钳
+     * "type": "5",
+     * // 选择的卡钳值
+     * "value": "黑色卡钳"
+     * },
+     * // 车身颜色
+     * "carColor": {
+     * // 名称
+     * "name": "车身颜色",
+     * // 价格
+     * "price": 10,
+     * // 类型2 车身颜色
+     * "type": "2",
+     * // 颜色和材质值 用/分割
+     * "value": "红色/基础版"
+     * },
+     * // 座椅
+     * "carSeat": {
+     * // 名称
+     * "name": "座椅布局",
+     * // 价格
+     * "price": 10,
+     * // 类型1 座椅
+     * "type": "1",
+     * // 座椅值
+     * "value": "5座"
+     * },
+     * // 轮廓
+     * "carWheelHub": {
+     * // 名称
+     * "name": "轮毂",
+     * // 价格
+     * "price": 10,
+     * // 类型4 轮廓
+     * "type": "4",
+     * // 轮廓值
+     * "value": "轮毂型号名称"
+     * },
+     * // 内饰
+     * "catUpholstery": {
+     * // 名称
+     * "name": "内饰",
+     * // 价格
+     * "price": 10,
+     * // 类型3 内饰
+     * "type": "3",
+     * // 内饰值
+     * "value": "红黑条纹软包套件"
+     * }
+     * };
      */
     @ApiModelProperty(value = "车辆选配信息", name = "pickedCarInformation")
     private String pickedCarInformation;

+ 76 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/entity/OfflinePayments.java

@@ -0,0 +1,76 @@
+package com.pine.admin.modules.business.entity;
+
+    import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.Data;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 线下支付详情
+ *
+ * @author Pine
+ * @email 771190883@qq.com
+ * @date 2019-07-25 18:38:56
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+@ApiModel(value = "线下支付详情对象", description = "线下支付详情对象")
+public class OfflinePayments implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty(value = "主键", name = "id")
+    private Long id;
+    /**
+     *
+     */
+    @ApiModelProperty(value = "", name = "carOrderId")
+    private Long carOrderId;
+    /**
+     * 首付状态 0 未支付 1 已支付
+     */
+    @ApiModelProperty(value = "首付状态 0 未支付 1 已支付", name = "downPaymentStatus")
+    private String downPaymentStatus;
+    /**
+     * 发票地址
+     */
+    @ApiModelProperty(value = "发票地址", name = "invoicePath")
+    private String invoicePath;
+    /**
+     * 支付方式  1 全款 2 贷款
+     */
+    @ApiModelProperty(value = "支付方式  1 全款 2 贷款", name = "paytype")
+    private String paytype;
+    /**
+     * 尾款状态 0 未支付 1 已经支付
+     */
+    @ApiModelProperty(value = "尾款状态 0 未支付 1 已经支付", name = "tailStatus")
+    private String tailStatus;
+    /**
+     * 交车证明
+     */
+    @ApiModelProperty(value = "交车证明", name = "deliveryPath")
+    private String deliveryPath;
+    /**
+     * 创建时间
+     */
+    @ApiModelProperty(value = "创建时间", name = "createTime")
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    @ApiModelProperty(value = "更新时间", name = "updateTime")
+    private Date updateTime;
+    /**
+     *
+     */
+    @ApiModelProperty(value = "", name = "delFlag")
+    private String delFlag;
+
+}

+ 9 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/service/CarOrderService.java

@@ -21,5 +21,14 @@ public interface CarOrderService extends BaseService<CarOrder> {
      */
     boolean offlineReview (Long id, String loanStatus, BigDecimal downPaymentRate);
 
+    /**
+     * 支付,没有支付没有数据代表未支付
+     */
+    boolean pay(Long id,String invoicePath);
+
+    /**
+     * 交车
+     */
+    boolean delivery(Long id,String invoicePath);
 }
 

+ 16 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/service/OfflinePaymentsService.java

@@ -0,0 +1,16 @@
+package com.pine.admin.modules.business.service;
+
+import com.pine.admin.modules.business.entity.OfflinePayments;
+import com.pine.admin.modules.base.binder.BaseService;
+
+/**
+ * 线下支付详情
+ *
+ * @author Pine
+ * @email 771190883@qq.com
+ * @date 2019-07-25 18:38:56
+ */
+public interface OfflinePaymentsService extends BaseService<OfflinePayments> {
+
+}
+

+ 102 - 4
pine-admin/src/main/java/com/pine/admin/modules/business/service/impl/CarOrderServiceImpl.java

@@ -1,12 +1,17 @@
 package com.pine.admin.modules.business.service.impl;
 
+import com.pine.admin.modules.business.dao.OfflinePaymentsDao;
 import com.pine.admin.modules.business.entity.CarOrder;
+import com.pine.admin.modules.business.entity.OfflinePayments;
 import com.pine.common.exception.ApiException;
+import io.swagger.annotations.Api;
+import org.apache.commons.lang.StringUtils;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -25,7 +30,8 @@ public class CarOrderServiceImpl implements CarOrderService {
 
     @Autowired
     private CarOrderDao carOrderDao;
-
+    @Autowired
+    private OfflinePaymentsDao offlinePaymentsDao;
 
     @Override
     @Transactional
@@ -183,7 +189,7 @@ public class CarOrderServiceImpl implements CarOrderService {
 
             CarOrder carOrder = new CarOrder();
             carOrder.setId(id);
-            CarOrder carOrderLast = carOrderDao.queryOne(carOrder);
+            CarOrder carOrderLast = getCarOrder(id);
             carOrder.setLoanStatus(loanStatus);
             if ("5".equals(loanStatus)) {
                 if (null == downPaymentRate) {
@@ -192,8 +198,9 @@ public class CarOrderServiceImpl implements CarOrderService {
                 carOrder.setDownPaymentRate(downPaymentRate);
 //                carOrder.setDownPaymentPrice();
                 //计算首付金额
-                BigDecimal downPaymentPrice = carOrderLast.getTotalPrice().multiply(downPaymentRate).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).subtract(carOrderLast.getDepositPrice());
-
+                DecimalFormat decimalFormat = new DecimalFormat("0.##");
+                BigDecimal downPaymentPrice = carOrderLast.getTotalPrice().multiply(downPaymentRate).subtract(carOrderLast.getDepositPrice());
+                downPaymentPrice = new BigDecimal(decimalFormat.format(downPaymentPrice));
                 carOrder.setDownPaymentPrice(downPaymentPrice);
             }
             int updates = carOrderDao.updateByPrimaryKeySelective(carOrder);
@@ -210,6 +217,97 @@ public class CarOrderServiceImpl implements CarOrderService {
         return false;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean pay(Long id, String invoicePath) {
+        log.info("pay");
+        try {
+            /**
+             * 查询订单
+             *
+             */
+            CarOrder carOrder = getCarOrder(id);
+
+            //判断是什么订单 支付方式  1 全款 2 贷款
+            OfflinePayments offlinePayments = new OfflinePayments();
+            offlinePayments.setCarOrderId(carOrder.getId());
+            OfflinePayments check = offlinePaymentsDao.queryOne(offlinePayments);
+            if (null != check){
+                throw new ApiException("已经支付");
+            }
+            if ("1".equals(carOrder.getPayType())) {
+                offlinePayments.setPaytype("1");
+                offlinePayments.setTailStatus("1");
+                offlinePayments.setInvoicePath(invoicePath);
+            } else {
+                offlinePayments.setPaytype("2");
+                offlinePayments.setDownPaymentStatus("1");
+                offlinePayments.setInvoicePath(invoicePath);
+            }
+
+            int i = offlinePaymentsDao.insertSelective(offlinePayments);
+            if (i>0){
+                return true;
+            }
+        } catch (Exception e) {
+            log.info("pay", e);
+            throw new ApiException(e.getMessage());
+        }
+
+        return false;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean delivery(Long id, String invoicePath) {
+
+        log.info("delivery");
+        try {
+            /**
+             * 查询订单
+             *
+             */
+            CarOrder carOrder = getCarOrder(id);
+            carOrder.setStatus("3");
+            int c = carOrderDao.updateByPrimaryKeySelective(carOrder);
+
+            OfflinePayments offlinePayments = new OfflinePayments();
+            offlinePayments.setCarOrderId(carOrder.getCarId());
+            offlinePayments = offlinePaymentsDao.queryOne(offlinePayments);
+            if (null == offlinePayments){
+                throw new ApiException("非法流程");
+            }
+            if (!StringUtils.isEmpty(offlinePayments.getDeliveryPath())){
+                throw new ApiException("交车流程已经提交");
+
+            }
+            offlinePayments.setDeliveryPath(invoicePath);
+            int o = offlinePaymentsDao.updateByPrimaryKeySelective(offlinePayments);
+//            offlinePaymentsDao.queryOne(carOrder.getId());
+            if (c>0 && o >0){
+                return true;
+            }
+//            offlinePaymentsDao.insertSelective(offlinePayments);
+
+        } catch (Exception e) {
+            log.info("delivery", e);
+            throw new ApiException(e.getMessage());
+        }
+
+        return false;
+    }
+
+    private CarOrder getCarOrder(Long id) {
+        CarOrder carOrder = new CarOrder();
+        carOrder.setId(id);
+        CarOrder carOrderLast = carOrderDao.queryOne(carOrder);
+
+        if (null == carOrderLast) {
+            throw new ApiException("订单不存在");
+        }
+        return carOrder;
+    }
+
     public static void main(String[] args) {
 
         String loanStatus = "5";

+ 168 - 0
pine-admin/src/main/java/com/pine/admin/modules/business/service/impl/OfflinePaymentsServiceImpl.java

@@ -0,0 +1,168 @@
+package com.pine.admin.modules.business.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import lombok.extern.slf4j.Slf4j;
+import com.pine.common.dto.Page;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.pine.admin.modules.business.dao.OfflinePaymentsDao;
+import com.pine.admin.modules.business.entity.OfflinePayments;
+import com.pine.admin.modules.business.service.OfflinePaymentsService;
+
+
+@Service("offlinePaymentsService")
+@Slf4j
+public class OfflinePaymentsServiceImpl implements OfflinePaymentsService {
+
+    @Autowired
+    private OfflinePaymentsDao offlinePaymentsDao;
+
+
+    @Override
+    @Transactional
+    public List<OfflinePayments> getAllList(OfflinePayments record) {
+
+        log.info("getOfflinePaymentsList");
+        try {
+
+            return offlinePaymentsDao.queryAll(record);
+        } catch (Exception e) {
+            log.error("getOfflinePaymentsList", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public List<OfflinePayments> getByPage(Page page, OfflinePayments record) {
+
+        log.info("getOfflinePaymentsByPage");
+        try {
+
+            Map<String, Object> parameter = new HashMap<String, Object>();
+            parameter.put("record", record);
+            parameter.put("page", page);
+
+            return offlinePaymentsDao.queryByPage(parameter);
+        } catch (Exception e) {
+            log.error("getOfflinePaymentsByPage", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public OfflinePayments getById(String id) {
+
+        log.info("getOfflinePaymentsById");
+        try {
+
+            return offlinePaymentsDao.selectByPrimaryKey(Integer.valueOf(id));
+        } catch (Exception e) {
+            log.error("getOfflinePaymentsById", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public OfflinePayments getOne(OfflinePayments record) {
+
+        log.info("getOfflinePayments");
+        try {
+
+            return offlinePaymentsDao.queryOne(record);
+        } catch (Exception e) {
+            log.error("getOfflinePayments", e);
+        }
+
+        return null;
+    }
+
+    @Override
+    @Transactional
+    public boolean create(OfflinePayments record) {
+
+        log.info("createOfflinePayments");
+        try {
+
+            int updates = offlinePaymentsDao.insertSelective(record);
+
+            if (updates > 0) {
+                return true;
+            }
+        } catch (Exception e) {
+            log.error("createOfflinePayments", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    @Transactional
+    public boolean delete(String id) {
+
+        log.info("deleteOfflinePayments");
+        try {
+
+            int updates = offlinePaymentsDao.delete(Integer.valueOf(id));
+
+            if (updates > 0) {
+                return true;
+            }
+        } catch (Exception e) {
+            log.error("deleteOfflinePayments", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    @Transactional
+    public boolean deltetByIds(String ids) {
+
+        log.info("deleteeOfflinePayments byIDS");
+        try {
+
+            String[] id = ids.split(";");
+            int updates = offlinePaymentsDao.deleteIds(id);
+
+            if (id.length == updates) {
+                return true;
+            }
+        } catch (Exception e) {
+            log.error("deleteeOfflinePayments byIDS", e);
+        }
+
+        return false;
+    }
+
+    @Override
+    @Transactional
+    public boolean update(OfflinePayments record) {
+
+        log.info("updateOfflinePayments");
+        try {
+
+            int updates = offlinePaymentsDao.updateByPrimaryKeySelective(record);
+
+            if (updates > 0) {
+                return true;
+            }
+        } catch (Exception e) {
+            log.error("updateOfflinePayments", e);
+        }
+
+        return false;
+    }
+
+}

+ 123 - 0
pine-admin/src/main/java/com/pine/admin/modules/youpaiyun/util/MD5Utils.java

@@ -0,0 +1,123 @@
+package com.pine.admin.modules.youpaiyun.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * md5工具类
+ */
+public class MD5Utils {
+
+    /**
+     * 调试日志
+     */
+    private Logger logger = LoggerFactory.getLogger(MD5Utils.class);
+
+    private static final MD5Utils INSTANCE = new MD5Utils();
+
+    public static MD5Utils getInstance() {
+        return INSTANCE;
+    }
+
+
+    private MD5Utils() {
+
+    }
+
+
+    /**
+     * 判断订单号是否含有中文
+     *
+     * @param waybillCode 订单号
+     * @return true 含有中文 false 不含中文
+     */
+    public boolean isContainChinese(String waybillCode) {
+
+        Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
+        Matcher m = p.matcher(waybillCode);
+        if (m.find()) {
+            return true;
+        }
+        return false;
+    }
+    /**
+     * 创建md5值
+     *
+     * @param string 待加密的字符串
+     * @return 返回加密后的值
+     */
+    public String createMd5(String string)  {
+        String result = "";
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(string.getBytes("utf-8"));
+            byte b[] = md.digest();
+            int i;
+            StringBuilder buf = new StringBuilder();
+            for (int offset = 0; offset < b.length; offset++) {
+                i = b[offset];
+                if (i < 0) {
+                    i += 256;
+                }
+                if (i < 16) {
+                    buf.append("0");
+                }
+
+                buf.append(Integer.toHexString(i));
+            }
+            return buf.toString();
+        } catch (NoSuchAlgorithmException e) {
+            logger.error("createMd5 fail...", e);
+        } catch (UnsupportedEncodingException e){
+            logger.error("createMd5 fail...", e);
+        }
+        return result;
+    }
+
+    /**
+     * 生成md5值
+     *
+     * @param is 输入流
+     * @return 返回md5加密后的字符串
+     * @throws IOException
+     */
+    public String createMd5ForImageUpload(InputStream is) throws IOException {
+        char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+        MessageDigest md5 = null;
+        try {
+            md5 = MessageDigest.getInstance("MD5");
+            byte[] j = new byte[1024];
+            while (true) {
+                int var14 = is.read(j);
+                if (var14 > 0) {
+                    md5.update(j, 0, var14);
+                }
+                if (var14 == -1) {
+                    is.skip(0L);
+                    break;
+                }
+            }
+        } catch (NoSuchAlgorithmException var12) {
+            throw new RuntimeException(var12.getMessage());
+        } finally {
+            is.close();
+        }
+        byte[] var15 = md5.digest();
+        int var16 = var15.length;
+        char[] finalValue = new char[var16 * 2];
+        int k = 0;
+        for (byte encoded : var15) {
+            finalValue[k++] = hexDigits[encoded >> 4 & 15];
+            finalValue[k++] = hexDigits[encoded & 15];
+        }
+        return new String(finalValue);
+    }
+}

+ 31 - 0
pine-admin/src/main/java/com/pine/admin/modules/youpaiyun/util/UpYunConf.java

@@ -0,0 +1,31 @@
+package com.pine.admin.modules.youpaiyun.util;
+
+import lombok.Data;
+
+/**
+ * Created by dujinkai on 17/5/8.
+ * 又拍云配置
+ */
+
+@Data
+public class UpYunConf {
+    /**
+     * 服务名称 对应ls_upyun_setting表中的name_space
+     */
+    public static String nameSpace ="jetour";
+
+    /**
+     * 用户名 对应ls_upyun_setting表中的username
+     */
+    public static String userName = "admin";
+
+    /**
+     * 密码 对应ls_upyun_setting表中的password
+     */
+    public static String password = "d3hmhMgfN4f1SbWIMoAdCCfaojuPe0gZ";
+
+    /**
+     * 访问地址 对应ls_upyun_setting表中的address
+     */
+    public static String address = "'http://shopimg.jetour.com.cn";
+}

+ 91 - 0
pine-admin/src/main/java/com/pine/admin/modules/youpaiyun/util/YunUploadUtils.java

@@ -0,0 +1,91 @@
+package com.pine.admin.modules.youpaiyun.util;
+
+import com.upyun.UpYun;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.TimeZone;
+
+/**
+ * Created by dujinkai on 17/5/8.
+ * 又拍云上传工具
+ */
+public class YunUploadUtils {
+
+    /**
+     * 调试工具
+     */
+    private Logger logger = LoggerFactory.getLogger(YunUploadUtils.class);
+
+    private static final YunUploadUtils INSTANCE = new YunUploadUtils();
+
+    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
+
+    private YunUploadUtils() {
+    }
+
+    public static YunUploadUtils getInstance() {
+        return INSTANCE;
+    }
+
+
+    /**
+     * 上传又拍云
+     *
+     * @param upYunConf   又拍云设置
+     * @param inputStream 输入流
+     * @param bytes       图片字节
+     * @return 返回图片在又拍云的地址
+     */
+    public String uploadToUpYun(UpYunConf upYunConf, InputStream inputStream, byte[] bytes) {
+        logger.debug("Being to uploadToUpYun.....");
+        if (bytes == null || bytes.length == 0) {
+            logger.error("uploadToUpYun fail due to bytes is empty ....");
+            return "";
+        }
+
+        // 如果上传的不是图片 则直接返回
+        if (!isPicture(bytes)) {
+            throw new RuntimeException("file is not a picture ...");
+        }
+        try {
+            String picName = String.valueOf(System.currentTimeMillis()) + ".jpg";
+            String date = simpleDateFormat.format(Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00")).getTime());
+            String filePath = "/" + date + "/" + picName;
+            UpYun upYun = new UpYun(UpYunConf.nameSpace.trim(), UpYunConf.userName.trim(), UpYunConf.password.trim());
+            upYun.setDebug(true);
+            upYun.setContentMD5(MD5Utils.getInstance().createMd5ForImageUpload(inputStream));
+            upYun.setFileSecret("");
+            // 上传文件
+            if (upYun.writeFile(filePath, bytes, true)) {
+                return UpYunConf.address + date + "/" + picName;
+            }
+        } catch (Exception e) {
+            logger.error("uploadToUpYun fail ....", e);
+        }
+        return "";
+    }
+
+    /**
+     * 判断是否是图片
+     *
+     * @param bytes 字节数组
+     * @return 是图片返回true  否则返回false
+     */
+    private boolean isPicture(byte[] bytes) {
+        try {
+            BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
+            return image != null;
+        } catch (IOException e) {
+            logger.error("file is not a picture ...", e);
+            return false;
+        }
+    }
+}

BIN
pine-admin/src/main/resources/lib/upyun-1.0.0.jar


+ 235 - 0
pine-admin/src/main/resources/mapper/business/OfflinePaymentsDao.xml

@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.pine.admin.modules.business.dao.OfflinePaymentsDao">
+
+    <!-- 可根据自己的需求,是否要使用 -->
+    <resultMap type="com.pine.admin.modules.business.entity.OfflinePayments" id="entityMap">
+        <result property="id" column="id"/>
+        <result property="carOrderId" column="car_order_id"/>
+        <result property="downPaymentStatus" column="down_payment_status"/>
+        <result property="invoicePath" column="invoice_path"/>
+        <result property="paytype" column="payType"/>
+        <result property="tailStatus" column="tail_status"/>
+        <result property="deliveryPath" column="delivery_path"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="delFlag" column="del_flag"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+                 id,
+                     car_order_id,
+                     down_payment_status,
+                     invoice_path,
+                     payType,
+                     tail_status,
+                     delivery_path,
+                     create_time,
+                     update_time,
+                    del_flag         </sql>
+    <!-- 根据Id查询-->
+    <select id="selectByPrimaryKey" resultMap="entityMap" parameterType="java.lang.Long">
+        select
+        <include refid="Base_Column_List"/>
+        from ls_offline_payments
+        where id = #{id}
+    </select>
+
+    <!-- 根据Id删除-->
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+		delete from ls_offline_payments
+		where id = #{id}
+	</delete>
+
+    <!-- 插入数据-->
+    <insert id="insertSelective" parameterType="com.pine.admin.modules.business.entity.OfflinePayments"
+            useGeneratedKeys="true" keyProperty="id">
+        insert into ls_offline_payments
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
+            <if test="carOrderId != null">car_order_id,</if>
+            <if test="downPaymentStatus != null">down_payment_status,</if>
+            <if test="invoicePath != null">invoice_path,</if>
+            <if test="paytype != null">payType,</if>
+            <if test="tailStatus != null">tail_status,</if>
+            <if test="deliveryPath != null">delivery_path,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="delFlag != null">del_flag,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
+            <if test="carOrderId != null">#{carOrderId},</if>
+            <if test="downPaymentStatus != null">#{downPaymentStatus},</if>
+            <if test="invoicePath != null">#{invoicePath},</if>
+            <if test="paytype != null">#{paytype},</if>
+            <if test="tailStatus != null">#{tailStatus},</if>
+            <if test="deliveryPath != null">#{deliveryPath},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+        </trim>
+    </insert>
+
+    <!-- 更新数据-->
+    <update id="updateByPrimaryKeySelective"
+            parameterType="com.pine.admin.modules.business.entity.OfflinePayments">
+        update ls_offline_payments
+        <set>
+            <if test="id != null">id = #{id},</if>
+            <if test="carOrderId != null">car_order_id = #{carOrderId},</if>
+            <if test="downPaymentStatus != null">down_payment_status = #{downPaymentStatus},</if>
+            <if test="invoicePath != null">invoice_path = #{invoicePath},</if>
+            <if test="paytype != null">payType = #{paytype},</if>
+            <if test="tailStatus != null">tail_status = #{tailStatus},</if>
+            <if test="deliveryPath != null">delivery_path = #{deliveryPath},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+        </set>
+        where id = #{id,jdbcType=INTEGER}
+    </update>
+
+    <!-- 分页查询-->
+    <select id="queryByPage" parameterType="java.util.Map"
+            resultMap="entityMap">
+        select
+        <include refid="Base_Column_List"/>
+        from ls_offline_payments
+        <where>
+            and del_flag = 'N'
+            <if test="record.id != null and !&quot;&quot;.equals(record.id)">
+                and id = #{record.id}
+            </if>
+            <if test="record.carOrderId != null and !&quot;&quot;.equals(record.carOrderId)">
+                and car_order_id = #{record.carOrderId}
+            </if>
+            <if test="record.downPaymentStatus != null and !&quot;&quot;.equals(record.downPaymentStatus)">
+                and down_payment_status = #{record.downPaymentStatus}
+            </if>
+            <if test="record.invoicePath != null and !&quot;&quot;.equals(record.invoicePath)">
+                and invoice_path = #{record.invoicePath}
+            </if>
+            <if test="record.paytype != null and !&quot;&quot;.equals(record.paytype)">
+                and payType = #{record.paytype}
+            </if>
+            <if test="record.tailStatus != null and !&quot;&quot;.equals(record.tailStatus)">
+                and tail_status = #{record.tailStatus}
+            </if>
+            <if test="record.deliveryPath != null and !&quot;&quot;.equals(record.deliveryPath)">
+                and delivery_path = #{record.deliveryPath}
+            </if>
+            <if test="record.createTime != null and !&quot;&quot;.equals(record.createTime)">
+                and create_time = #{record.createTime}
+            </if>
+            <if test="record.updateTime != null and !&quot;&quot;.equals(record.updateTime)">
+                and update_time = #{record.updateTime}
+            </if>
+            <if test="record.delFlag != null and !&quot;&quot;.equals(record.delFlag)">
+                and del_flag = #{record.delFlag}
+            </if>
+        </where>
+        order by id desc
+    </select>
+
+    <!-- 全部查询 -->
+    <select id="queryAll" parameterType="java.util.Map"
+            resultMap="entityMap">
+        select
+        <include refid="Base_Column_List"/>
+        from ls_offline_payments
+        <where>
+            and del_flag = 'N'
+            <if test="id != null and !&quot;&quot;.equals(id)">
+                and id = #{id}
+            </if>
+            <if test="carOrderId != null and !&quot;&quot;.equals(carOrderId)">
+                and car_order_id = #{carOrderId}
+            </if>
+            <if test="downPaymentStatus != null and !&quot;&quot;.equals(downPaymentStatus)">
+                and down_payment_status = #{downPaymentStatus}
+            </if>
+            <if test="invoicePath != null and !&quot;&quot;.equals(invoicePath)">
+                and invoice_path = #{invoicePath}
+            </if>
+            <if test="paytype != null and !&quot;&quot;.equals(paytype)">
+                and payType = #{paytype}
+            </if>
+            <if test="tailStatus != null and !&quot;&quot;.equals(tailStatus)">
+                and tail_status = #{tailStatus}
+            </if>
+            <if test="deliveryPath != null and !&quot;&quot;.equals(deliveryPath)">
+                and delivery_path = #{deliveryPath}
+            </if>
+            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
+                and create_time = #{createTime}
+            </if>
+            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
+                and update_time = #{updateTime}
+            </if>
+            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                and del_flag = #{delFlag}
+            </if>
+        </where>
+        order by id desc
+    </select>
+
+    <!-- 根据条件查询一个 -->
+    <select id="queryOne" parameterType="java.util.Map"
+            resultMap="entityMap">
+        select
+        <include refid="Base_Column_List"/>
+        from ls_offline_payments
+        <where>
+            and del_flag = 'N'
+            <if test="id != null and !&quot;&quot;.equals(id)">
+                and id = #{id}
+            </if>
+            <if test="carOrderId != null and !&quot;&quot;.equals(carOrderId)">
+                and car_order_id = #{carOrderId}
+            </if>
+            <if test="downPaymentStatus != null and !&quot;&quot;.equals(downPaymentStatus)">
+                and down_payment_status = #{downPaymentStatus}
+            </if>
+            <if test="invoicePath != null and !&quot;&quot;.equals(invoicePath)">
+                and invoice_path = #{invoicePath}
+            </if>
+            <if test="paytype != null and !&quot;&quot;.equals(paytype)">
+                and payType = #{paytype}
+            </if>
+            <if test="tailStatus != null and !&quot;&quot;.equals(tailStatus)">
+                and tail_status = #{tailStatus}
+            </if>
+            <if test="deliveryPath != null and !&quot;&quot;.equals(deliveryPath)">
+                and delivery_path = #{deliveryPath}
+            </if>
+            <if test="createTime != null and !&quot;&quot;.equals(createTime)">
+                and create_time = #{createTime}
+            </if>
+            <if test="updateTime != null and !&quot;&quot;.equals(updateTime)">
+                and update_time = #{updateTime}
+            </if>
+            <if test="delFlag != null and !&quot;&quot;.equals(delFlag)">
+                and del_flag = #{delFlag}
+            </if>
+        </where>
+        LIMIT 1
+    </select>
+
+    <update id="delete">
+        UPDATE ls_offline_payments SET del_flag = 'Y'
+        <where>
+            AND id = #{id}
+        </where>
+    </update>
+
+    <update id="deleteIds" parameterType="java.util.ArrayList">
+        UPDATE ls_offline_payments SET del_flag = 'Y'
+        WHERE id IN
+        <foreach item='ids' collection="array" index="index" open="(" separator="," close=")">
+            #{ids}
+        </foreach>
+    </update>
+
+</mapper>