suochencheng 7 лет назад
Родитель
Сommit
c65ea1767f

+ 17 - 0
src/main/java/com/izouma/awesomeadmin/constant/AppConstant.java

@@ -287,4 +287,21 @@ public interface AppConstant {
          */
         int COMPOSITE = 4;
     }
+
+    /**
+     * 订单类型
+     */
+    public interface OrderType {
+
+        /**
+         * 导航包
+         */
+        int PACKAGE = 0;
+
+        /**
+         * 商品
+         */
+        int PRODUCT = 1;
+
+    }
 }

+ 43 - 0
src/main/java/com/izouma/awesomeadmin/dao/UserOrderMapper.xml

@@ -25,6 +25,8 @@
         <result column="type_flag" property="typeFlag" jdbcType="INTEGER"/>
         <result column="product_id" property="productId" jdbcType="INTEGER"/>
         <result column="tuniu_order_id" property="tuniuOrderId" jdbcType="VARCHAR"/>
+        <result column="product_type" property="productType" jdbcType="INTEGER"/>
+        <result column="outTradeNo" property="outTradeNo" jdbcType="VARCHAR"/>
     </resultMap>
     <sql id="Base_Column_List">
         <trim suffixOverrides=",">
@@ -69,6 +71,8 @@
             type_flag,
             product_id,
             tuniu_order_id,
+            product_type,
+            outTradeNo,
 
         </trim>
     </sql>
@@ -155,6 +159,12 @@
             <if test="tuniuOrderId!= null">
                 tuniu_order_id,
             </if>
+            <if test="productType!= null">
+                product_type,
+            </if>
+            <if test="outTradeNo!= null">
+                outTradeNo,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">
@@ -226,6 +236,12 @@
             <if test="tuniuOrderId != null">
                 #{tuniuOrderId,jdbcType=VARCHAR},
             </if>
+            <if test="productType != null">
+                #{productType},
+            </if>
+            <if test="outTradeNo != null">
+                #{outTradeNo},
+            </if>
         </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.izouma.awesomeadmin.model.UserOrder">
@@ -300,6 +316,12 @@
             <if test="tuniuOrderId != null">
                 tuniu_order_id= #{tuniuOrderId,jdbcType=VARCHAR},
             </if>
+            <if test="productType != null">
+                product_type= #{productType},
+            </if>
+            <if test="outTradeNo != null">
+                outTradeNo= #{outTradeNo},
+            </if>
         </set>
         where
         <if test="id != null and !&quot;&quot;.equals(id)">
@@ -387,6 +409,12 @@
             <if test="record.tuniuOrderId != null and !&quot;&quot;.equals(record.tuniuOrderId)">
                 and tuniu_order_id = #{record.tuniuOrderId}
             </if>
+            <if test="record.productType != null and !&quot;&quot;.equals(record.productType)">
+                and product_type = #{record.productType}
+            </if>
+            <if test="record.outTradeNo != null and !&quot;&quot;.equals(record.outTradeNo)">
+                and outTradeNo = #{record.outTradeNo}
+            </if>
             <if test="record.searchKey != null and !&quot;&quot;.equals(record.searchKey)">
                 <trim prefix="and (" suffix=")" prefixOverrides="OR">
                     OR user_id LIKE concat('%',#{record.searchKey},'%')
@@ -531,6 +559,14 @@
             <if test="tuniuOrderId != null and !&quot;&quot;.equals(tuniuOrderId)">
                 and tuniu_order_id = #{tuniuOrderId}
             </if>
+
+            <if test="productType != null and !&quot;&quot;.equals(productType)">
+                and product_type = #{productType}
+            </if>
+            <if test="outTradeNo != null and !&quot;&quot;.equals(outTradeNo)">
+                and outTradeNo = #{outTradeNo}
+            </if>
+
             <if test="searchKey != null and !&quot;&quot;.equals(searchKey)">
                 <trim prefix="and (" suffix=")" prefixOverrides="OR">
                     OR user_id LIKE concat('%',#{searchKey},'%')
@@ -673,6 +709,13 @@
                 and tuniu_order_id = #{tuniuOrderId}
             </if>
 
+            <if test="productType != null and !&quot;&quot;.equals(productType)">
+                and product_type = #{productType}
+            </if>
+            <if test="outTradeNo != null and !&quot;&quot;.equals(outTradeNo)">
+                and outTradeNo = #{outTradeNo}
+            </if>
+
         </where>
         LIMIT 1
     </select>

+ 89 - 0
src/main/java/com/izouma/awesomeadmin/dto/tuniu/AdmissionVoucher.java

@@ -0,0 +1,89 @@
+package com.izouma.awesomeadmin.dto.tuniu;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+/**
+ * AdmissionVoucher--入园方式
+ */
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class AdmissionVoucher {
+
+    /**
+     * 入园方式编码
+     * <p>
+     * 1实体票入园,
+     * <p>
+     * 201换票入园短信,
+     * <p>
+     * 202换票入园二维码,
+     * <p>
+     * 203换票入园数字码,
+     * <p>
+     * 204换票入园换票证,
+     * <p>
+     * 205换票入园邮件,
+     * <p>
+     * 206换票入园身份证,
+     * <p>
+     * 207换票入园护照,
+     * <p>
+     * 208换票入园港澳通行证,
+     * <p>
+     * 209换票入园军官证,
+     * <p>
+     * 210换票入园台胞证,
+     * <p>
+     * 301直接验证入园二维码,
+     * <p>
+     * 302直接验证入园邮件,
+     * <p>
+     * 303直接验证入园身份证,
+     * <p>
+     * 304直接验证入园护照,
+     * <p>
+     * 305直接验证入园港澳通行证,
+     * <p>
+     * 306直接验证入园军官证,
+     * <p>
+     * 307直接验证入园台胞证
+     */
+    private String admissionVoucherCode;
+
+    /**
+     * 入园方式描述
+     */
+    private String admissionVoucherDesc;
+
+    /**
+     * 短信内容
+     */
+    private String smsMessage;
+
+    public String getAdmissionVoucherCode() {
+        return admissionVoucherCode;
+    }
+
+    public void setAdmissionVoucherCode(String admissionVoucherCode) {
+        this.admissionVoucherCode = admissionVoucherCode;
+    }
+
+    public String getAdmissionVoucherDesc() {
+        return admissionVoucherDesc;
+    }
+
+    public void setAdmissionVoucherDesc(String admissionVoucherDesc) {
+        this.admissionVoucherDesc = admissionVoucherDesc;
+    }
+
+    public String getSmsMessage() {
+        return smsMessage;
+    }
+
+    public void setSmsMessage(String smsMessage) {
+        this.smsMessage = smsMessage;
+    }
+}
+

+ 19 - 0
src/main/java/com/izouma/awesomeadmin/dto/tuniu/Order.java

@@ -155,6 +155,9 @@ public class Order {
      */
     private String statusDesc;
 
+    private String canCancel;
+
+
 
     public String getSourceOrderId() {
         return sourceOrderId;
@@ -347,5 +350,21 @@ public class Order {
     public void setEnterCertificate(EnterCertificate enterCertificate) {
         this.enterCertificate = enterCertificate;
     }
+
+    public String getStatusDesc() {
+        return statusDesc;
+    }
+
+    public void setStatusDesc(String statusDesc) {
+        this.statusDesc = statusDesc;
+    }
+
+    public String getCanCancel() {
+        return canCancel;
+    }
+
+    public void setCanCancel(String canCancel) {
+        this.canCancel = canCancel;
+    }
 }
 

+ 67 - 0
src/main/java/com/izouma/awesomeadmin/dto/tuniu/PriceCalendar.java

@@ -0,0 +1,67 @@
+package com.izouma.awesomeadmin.dto.tuniu;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+
+/**
+ * Contact--取票人信息
+ */
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class PriceCalendar {
+
+
+    /**
+     * 开始价格?
+     */
+    private String startPrice;
+
+    /**
+     * 单位元,分销价(下单用这个价格)
+     */
+    private String salePrice;
+
+    /**
+     * 团期
+     */
+    private String departDate;
+
+    /**
+     * 子价格?
+     */
+    private String childPrice;
+
+    public String getStartPrice() {
+        return startPrice;
+    }
+
+    public void setStartPrice(String startPrice) {
+        this.startPrice = startPrice;
+    }
+
+    public String getSalePrice() {
+        return salePrice;
+    }
+
+    public void setSalePrice(String salePrice) {
+        this.salePrice = salePrice;
+    }
+
+    public String getDepartDate() {
+        return departDate;
+    }
+
+    public void setDepartDate(String departDate) {
+        this.departDate = departDate;
+    }
+
+    public String getChildPrice() {
+        return childPrice;
+    }
+
+    public void setChildPrice(String childPrice) {
+        this.childPrice = childPrice;
+    }
+}
+

+ 326 - 0
src/main/java/com/izouma/awesomeadmin/dto/tuniu/Ticket.java

@@ -0,0 +1,326 @@
+package com.izouma.awesomeadmin.dto.tuniu;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import java.util.List;
+
+
+/**
+ * Ticket--门票详情
+ */
+@JsonAutoDetect
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class Ticket {
+
+    private Integer productId;//门票产品ID
+    private String resourceId;//资源ID
+    private String productName;//门票产品ID
+    private Integer scenicId;//门票产品ID
+    private String webPrice;//单位元,景点价(当前景点的价格,信息可能有滞后,仅供参考)
+    private String salePrice;//单位元,分销起价(所有团期中最低的价格,仅供参考)
+    private Integer drawType;//取票方式:1实体票 8预付电子票
+    private String drawAddress;//取票地点,必须展示
+    private Integer subType;//1门票2 联票3套票4专项
+    private String indate;//有效期.如: "指定日期有效(2月2日或者3日)",必须展示
+    private Integer advanceDay;//预订截止天数,必须展示
+    private Integer advanceHour;//预订截止小时数(表示几点钟),必须展示
+    private String bookNotice;//预订须知,必须展示
+    private Integer limitNumLow;//起订张数
+    private Integer limitNumHigh;//最多预订张数
+    /**
+     * 预订项要求
+     * <p>
+     * 1取票人姓名+手机号;
+     * <p>
+     * 2取票人姓名+手机号,所有游客姓名+手机号;
+     * <p>
+     * 3取票人姓名+手机号,所有游客姓名+手机号+证件号;
+     * <p>
+     * 4取票人姓名+手机号+证件号;
+     * <p>
+     * 6取票人姓名+手机号+证件号,所有游客姓名+手机号+证件号;
+     * <p>
+     * 7取票人姓名+手机号+证件号,所有游客姓名+手机号;
+     */
+    private Integer custInfoLimit;
+
+    /**
+     * 证件类型, (逗号分隔) 如”1,2,3,4”
+     * <p>
+     * 1身份证
+     * <p>
+     * 2护照
+     * <p>
+     * 3军官证
+     * <p>
+     * 4港澳通行证
+     * <p>
+     * 7台胞证
+     * <p>
+     * 为空表示只支持1身份证,或者不需要录入证件
+     */
+    private String certificateType;
+
+    /**
+     * 1短信换票入园
+     * <p>
+     * 2短信二维码入园
+     * <p>
+     * 3有效证件入园
+     * <p>
+     * 4邮件打印凭证入园
+     * <p>
+     * 5导游带团入园
+     * <p>
+     * 6电话预约入园
+     * (该字段将于2018.11废弃)
+     */
+    private Integer enterCertisficate;
+
+    private AdmissionVoucher admissionVoucher;//入园方式,必须展示
+
+    private List<PriceCalendar> priceCalendar;//价格日历。下单价格
+
+    private String info;//其他说明,必须展示
+
+    private String smsMessage;
+
+    private Integer productLineDestId;
+
+    private Integer isLoss;
+
+    private String costInclude;
+
+    private Integer costType;
+
+    private Integer invoiceType;
+
+    private String admissionVoucherDesc;
+
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getResourceId() {
+        return resourceId;
+    }
+
+    public void setResourceId(String resourceId) {
+        this.resourceId = resourceId;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public Integer getScenicId() {
+        return scenicId;
+    }
+
+    public void setScenicId(Integer scenicId) {
+        this.scenicId = scenicId;
+    }
+
+    public String getWebPrice() {
+        return webPrice;
+    }
+
+    public void setWebPrice(String webPrice) {
+        this.webPrice = webPrice;
+    }
+
+    public String getSalePrice() {
+        return salePrice;
+    }
+
+    public void setSalePrice(String salePrice) {
+        this.salePrice = salePrice;
+    }
+
+    public Integer getDrawType() {
+        return drawType;
+    }
+
+    public void setDrawType(Integer drawType) {
+        this.drawType = drawType;
+    }
+
+    public String getDrawAddress() {
+        return drawAddress;
+    }
+
+    public void setDrawAddress(String drawAddress) {
+        this.drawAddress = drawAddress;
+    }
+
+    public Integer getSubType() {
+        return subType;
+    }
+
+    public void setSubType(Integer subType) {
+        this.subType = subType;
+    }
+
+    public String getIndate() {
+        return indate;
+    }
+
+    public void setIndate(String indate) {
+        this.indate = indate;
+    }
+
+    public Integer getAdvanceDay() {
+        return advanceDay;
+    }
+
+    public void setAdvanceDay(Integer advanceDay) {
+        this.advanceDay = advanceDay;
+    }
+
+    public Integer getAdvanceHour() {
+        return advanceHour;
+    }
+
+    public void setAdvanceHour(Integer advanceHour) {
+        this.advanceHour = advanceHour;
+    }
+
+    public String getBookNotice() {
+        return bookNotice;
+    }
+
+    public void setBookNotice(String bookNotice) {
+        this.bookNotice = bookNotice;
+    }
+
+    public Integer getLimitNumLow() {
+        return limitNumLow;
+    }
+
+    public void setLimitNumLow(Integer limitNumLow) {
+        this.limitNumLow = limitNumLow;
+    }
+
+    public Integer getLimitNumHigh() {
+        return limitNumHigh;
+    }
+
+    public void setLimitNumHigh(Integer limitNumHigh) {
+        this.limitNumHigh = limitNumHigh;
+    }
+
+    public Integer getCustInfoLimit() {
+        return custInfoLimit;
+    }
+
+    public void setCustInfoLimit(Integer custInfoLimit) {
+        this.custInfoLimit = custInfoLimit;
+    }
+
+    public String getCertificateType() {
+        return certificateType;
+    }
+
+    public void setCertificateType(String certificateType) {
+        this.certificateType = certificateType;
+    }
+
+    public Integer getEnterCertisficate() {
+        return enterCertisficate;
+    }
+
+    public void setEnterCertisficate(Integer enterCertisficate) {
+        this.enterCertisficate = enterCertisficate;
+    }
+
+    public AdmissionVoucher getAdmissionVoucher() {
+        return admissionVoucher;
+    }
+
+    public void setAdmissionVoucher(AdmissionVoucher admissionVoucher) {
+        this.admissionVoucher = admissionVoucher;
+    }
+
+    public List<PriceCalendar> getPriceCalendar() {
+        return priceCalendar;
+    }
+
+    public void setPriceCalendar(List<PriceCalendar> priceCalendar) {
+        this.priceCalendar = priceCalendar;
+    }
+
+    public String getInfo() {
+        return info;
+    }
+
+    public void setInfo(String info) {
+        this.info = info;
+    }
+
+    public String getSmsMessage() {
+        return smsMessage;
+    }
+
+    public void setSmsMessage(String smsMessage) {
+        this.smsMessage = smsMessage;
+    }
+
+    public Integer getProductLineDestId() {
+        return productLineDestId;
+    }
+
+    public void setProductLineDestId(Integer productLineDestId) {
+        this.productLineDestId = productLineDestId;
+    }
+
+    public Integer getIsLoss() {
+        return isLoss;
+    }
+
+    public void setIsLoss(Integer isLoss) {
+        this.isLoss = isLoss;
+    }
+
+    public String getCostInclude() {
+        return costInclude;
+    }
+
+    public void setCostInclude(String costInclude) {
+        this.costInclude = costInclude;
+    }
+
+    public Integer getCostType() {
+        return costType;
+    }
+
+    public void setCostType(Integer costType) {
+        this.costType = costType;
+    }
+
+    public Integer getInvoiceType() {
+        return invoiceType;
+    }
+
+    public void setInvoiceType(Integer invoiceType) {
+        this.invoiceType = invoiceType;
+    }
+
+    public String getAdmissionVoucherDesc() {
+        return admissionVoucherDesc;
+    }
+
+    public void setAdmissionVoucherDesc(String admissionVoucherDesc) {
+        this.admissionVoucherDesc = admissionVoucherDesc;
+    }
+}
+

+ 4 - 3
src/main/java/com/izouma/awesomeadmin/model/ProductInfo.java

@@ -6,6 +6,7 @@ import java.util.*;
 import com.alibaba.fastjson.JSONObject;
 import com.fasterxml.jackson.annotation.JsonAutoDetect;
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.izouma.awesomeadmin.dto.tuniu.Ticket;
 
 
 @JsonAutoDetect
@@ -53,7 +54,7 @@ public class ProductInfo {
      */
     private String orderByStr;
 
-    private JSONObject ticketDetail;
+    private Ticket ticketDetail;
 
     public Integer getId() {
         return this.id;
@@ -303,11 +304,11 @@ public class ProductInfo {
         this.idStr = idStr;
     }
 
-    public JSONObject getTicketDetail() {
+    public Ticket getTicketDetail() {
         return ticketDetail;
     }
 
-    public void setTicketDetail(JSONObject ticketDetail) {
+    public void setTicketDetail(Ticket ticketDetail) {
         this.ticketDetail = ticketDetail;
     }
 }

+ 19 - 5
src/main/java/com/izouma/awesomeadmin/model/UserOrder.java

@@ -54,7 +54,13 @@ public class UserOrder {
     private String orderByStr;
 
     private Order tuniuOrder;
-    private JSONObject tuniuOrderJson;
+
+    private Integer productType;
+
+    /**
+     * 途牛交流流水号
+     */
+    private String outTradeNo;
 
     public Integer getId() {
         return this.id;
@@ -280,12 +286,20 @@ public class UserOrder {
         this.tuniuOrder = tuniuOrder;
     }
 
-    public JSONObject getTuniuOrderJson() {
-        return tuniuOrderJson;
+    public Integer getProductType() {
+        return productType;
+    }
+
+    public void setProductType(Integer productType) {
+        this.productType = productType;
+    }
+
+    public String getOutTradeNo() {
+        return outTradeNo;
     }
 
-    public void setTuniuOrderJson(JSONObject tuniuOrderJson) {
-        this.tuniuOrderJson = tuniuOrderJson;
+    public void setOutTradeNo(String outTradeNo) {
+        this.outTradeNo = outTradeNo;
     }
 }
 

+ 2 - 1
src/main/java/com/izouma/awesomeadmin/service/impl/ProductInfoServiceImpl.java

@@ -3,6 +3,7 @@ package com.izouma.awesomeadmin.service.impl;
 import java.util.*;
 
 import com.alibaba.fastjson.JSONObject;
+import com.izouma.awesomeadmin.dto.tuniu.Ticket;
 import com.izouma.awesomeadmin.tuniu.util.TicketUtil;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -88,7 +89,7 @@ public class ProductInfoServiceImpl implements ProductInfoService {
 
                 JSONObject resultJson = JSONObject.parseObject(result);
                 if (resultJson.getBoolean("success")) {
-                    productInfo.setTicketDetail(resultJson.getJSONObject("data"));
+                    productInfo.setTicketDetail(JSONObject.toJavaObject(resultJson.getJSONObject("data"), Ticket.class));
                 }
 
             }

+ 50 - 2
src/main/java/com/izouma/awesomeadmin/service/impl/UserOrderServiceImpl.java

@@ -211,6 +211,9 @@ public class UserOrderServiceImpl implements UserOrderService {
                     return new Result(false, "商品未上线或不存在");
                 }
 
+                record.setProductType(productInfo.getTypeFlag());
+
+
                 record.setLankMarkId(productInfo.getLandmarkId());
 
                 BigDecimal totlePrice = productInfo.getPrice();
@@ -246,6 +249,11 @@ public class UserOrderServiceImpl implements UserOrderService {
                 record.setDealPrice(dealPrice);
 
                 if (AppConstant.ProductType.TICKET == productInfo.getTypeFlag()) {
+
+                    if (productInfo.getPrice().doubleValue() < Double.valueOf(productInfo.getTicketDetail().getSalePrice())) {
+                        return new Result(false, "商品价格低于门票价格不能下单!");
+                    }
+
                     // 请求的接口地址
                     String url = "Ticket/createOrderNew";
                     // 设置请求的参数
@@ -263,7 +271,6 @@ public class UserOrderServiceImpl implements UserOrderService {
 
                     JSONObject resultJson = JSONObject.parseObject(result);
                     if (resultJson.getBoolean("success")) {
-                        productInfo.setTicketDetail(resultJson.getJSONObject("data"));
                         record.setTuniuOrderId(resultJson.getJSONObject("data").getInteger("orderId").toString());
                     } else {
 
@@ -359,12 +366,13 @@ public class UserOrderServiceImpl implements UserOrderService {
 
             userOrder.setId(Integer.valueOf(orderId));
 
-            userOrder = userOrderMapper.queryUserOrder(userOrder);
+            userOrder = getUserOrder(userOrder);
 
             if (userOrder == null) {
                 return new Result(false, "支付失败,订单不存在");
             }
 
+
             double money = userOrder.getDealPrice().doubleValue();
 
             if (AppConstant.PayMode.COIN == payMode) {
@@ -402,6 +410,45 @@ public class UserOrderServiceImpl implements UserOrderService {
                 return new Result(false, "支付失败,金额不足");
             }
 
+            if (AppConstant.OrderType.PRODUCT == userOrder.getTypeFlag()) {
+                if (StringUtils.isNotBlank(userOrder.getTuniuOrderId())) {
+
+                    Order tuniuOrder = userOrder.getTuniuOrder();
+                    if (tuniuOrder == null) {
+
+                        return new Result(false, "支付失败,途牛订单不存在");
+                    }
+
+                    if ("1".equals(tuniuOrder.getCanPay()) && "待付款".equals(tuniuOrder.getOrderStatus())) {
+                        if (tuniuOrder.getAmoutPrice() > userOrder.getTotlePrice().doubleValue()) {
+                            return new Result(false, "支付失败 订单价格小于途牛");
+                        }
+
+                        // 请求的接口地址
+                        String url = "Ticket/createOrderNew";
+
+
+                        String result = TicketUtil.submitOrder(Integer.valueOf(userOrder.getTuniuOrderId()), 1, tuniuOrder.getAmoutPrice(), "10001");
+
+                        JSONObject resultJson = JSONObject.parseObject(result);
+                        if (resultJson.getBoolean("success")) {
+                            userOrder.setOutTradeNo(resultJson.getJSONObject("data").getString("outTradeNo"));
+                        } else {
+
+                            return new Result(false, result);
+                        }
+
+
+                    } else {
+
+                        return new Result(false, "支付失败,途牛订单处于:" + tuniuOrder.getOrderStatus());
+                    }
+
+
+                }
+
+            }
+
             if (point > 0) {
                 //积分兑换区 只能用商城积分
                 MemberPoint memberPoint = new MemberPoint();
@@ -450,6 +497,7 @@ public class UserOrderServiceImpl implements UserOrderService {
             userOrderPay.setPayMode(payMode);
             userOrderPay.setPayTime(new Date());
             userOrderPay.setStatusFlag(AppConstant.OrderStatus.PAY_OVER);
+            userOrderPay.setOutTradeNo(userOrder.getOutTradeNo());
 
             userOrderMapper.updateByPrimaryKeySelective(userOrderPay);
 

+ 128 - 0
src/main/java/com/izouma/awesomeadmin/tuniu/util/TicketUtil.java

@@ -15,6 +15,11 @@ public class TicketUtil {
         return SendHttpRequest.sendPostConn(URLConfig.URL + url, params, apiKey, secretKey);
     }
 
+    /**
+     * 订单详情
+     * @param orderId
+     * @return
+     */
     public static String orderDetail(String orderId) {
         // 请求的接口地址
         String url = "Ticket/orderDetail";
@@ -26,4 +31,127 @@ public class TicketUtil {
         return TicketUtil.getResult(url, params);
     }
 
+    /**
+     * 当订单状态为“待支付”、且“支付开关”打开时,调用此接口。笛风从分销商钱包账户里代扣票款并开始出票,订单状态变为“已确认”。
+     * @param orderId
+     * @param payType 支付方式.1:途牛钱包代扣 3.企业支付宝代扣;
+     * @param pay 付款金额。(单位元,不支持小数)
+     * @param platform 平台标识
+     * @return
+     */
+    public static String submitOrder(Integer orderId, Integer payType, Integer pay, String platform) {
+        // 请求的接口地址
+        String url = "Ticket/submitOrder";
+
+        // 设置请求的参数
+        Map<String, Object> params = new HashMap<>();
+        params.put("acctId", PropertiesFileLoader.getProperties("tuniu_acctId")); //
+        params.put("orderId", orderId); //订单ID
+        params.put("payType", payType); //支付方式.1:途牛钱包代扣 3.企业支付宝代扣;
+        /**
+         * 付款金额。(单位元,不支持小数)
+         * 如果付款金额和订单剩余应付金额不一致,接口不会扣款,会返回false。例如:订单金额500,未付款,剩余应付金额就是500。如果付款金额不是500,接口就会返回false,不会扣款。
+         */
+        params.put("pay", pay); //
+
+        /**
+         * 平台标识(10001:PC,20000:m站,30001:app安卓,30002:appIOS,30003:appWindows)(默认是pc)
+         */
+        params.put("platform", platform); //
+        return TicketUtil.getResult(url, params);
+    }
+
+    /**
+     * 取消订单
+     * 1.“待确认”、“待付款”状态下,才能调用此接口;
+     *
+     * @param orderId
+     * @param remark
+     * @return
+     */
+    public static String cancelOrder(Integer orderId, String remark) {
+
+        // 请求的接口地址
+        String url = "Ticket/cancelOrder";
+
+        // 设置请求的参数
+        Map<String, Object> params = new HashMap<>();
+        params.put("orderId", orderId); //订单ID
+        params.put("remark", remark); //取消原因
+        return TicketUtil.getResult(url, params);
+
+    }
+
+    /**
+     *核销查询
+     * @param orderId
+     * @return
+     * 核销信息。有4种格式,解析第1种格式可以获取核销数量。
+     * 1.“总数量2次,已使用2次”
+     * 2.“未找到订单记录!”
+     * 3.“未查询到核销信息”
+     * 4.“发生异常:XXX”
+     */
+    public static String verifyOrder(Integer orderId) {
+
+        // 请求的接口地址
+        String url = "Ticket/verifyOrder";
+
+        // 设置请求的参数
+        Map<String, Object> params = new HashMap<>();
+        params.put("orderId", orderId); //订单ID
+        return TicketUtil.getResult(url, params);
+    }
+
+    /**
+     * 订单状态
+     * @param orderId
+     * @return
+     *
+     * 订单状态:
+     *
+     * 待确认:订单正在校验/占位;
+     * 待付款:订单在此状态下,同时满足“支付开关canPay=1.可支付”,则可以调用出票代扣接口进行付款;
+     *
+     * 出票中(已确认):付款后出票中到此状态;
+     * 已完成:表示出票成功;
+     * 已取消:订单取消成功,或者退票成功,到此状态;
+     *
+     */
+    public static String orderStatus(Integer orderId) {
+
+        // 请求的接口地址
+        String url = "Ticket/orderStatus";
+
+        // 设置请求的参数
+        Map<String, Object> params = new HashMap<>();
+        params.put("orderId", orderId); //订单ID
+        params.put("acctId", PropertiesFileLoader.getProperties("tuniu_acctId")); //
+        return TicketUtil.getResult(url, params);
+    }
+
+    /**
+     * @param orderId      订单ID
+     * @param causeType    退订类型
+     *                     0	行程变更
+     *                     1	价格不优惠
+     *                     2	门票预订错误
+     *                     3	未收到入园凭证
+     *                     4	景区闭园
+     *                     5	其他原因(传5的时候,content自填,最好不要超过50字)
+     * @param causeContent 退订原因
+     * @return
+     */
+    public static String tuiPiao(Integer orderId, Integer causeType, String causeContent) {
+
+        // 请求的接口地址
+        String url = "Ticket/tuiPiao";
+
+        // 设置请求的参数
+        Map<String, Object> params = new HashMap<>();
+        params.put("orderId", orderId); //订单ID
+        params.put("causeType", causeType); //退订类型
+        params.put("causeContent", causeContent); //退订原因
+        return TicketUtil.getResult(url, params);
+    }
 }

+ 33 - 0
src/main/java/com/izouma/awesomeadmin/web/TuNiuOpenApiController.java

@@ -96,6 +96,39 @@ public class TuNiuOpenApiController {
         return new Result(true, JSONObject.parseObject(result));
     }
 
+    @RequestMapping(value = "/submitOrder", method = RequestMethod.POST)
+    @ResponseBody
+    public Result orderDetail(@RequestParam(value = "orderId") Integer orderId,
+                              @RequestParam(value = "payType") Integer payType,
+                              @RequestParam(value = "pay") Integer pay) {
+
+
+        String result = TicketUtil.submitOrder(orderId, payType, pay, null);
+
+        return new Result(true, JSONObject.parseObject(result));
+    }
+
+    @RequestMapping(value = "/cancelOrder", method = RequestMethod.POST)
+    @ResponseBody
+    public Result cancelOrder(@RequestParam(value = "orderId") Integer orderId,
+                              @RequestParam(value = "remark") String remark) {
+
+
+        String result = TicketUtil.cancelOrder(orderId, remark);
+
+        return new Result(true, JSONObject.parseObject(result));
+    }
+
+    @RequestMapping(value = "/orderStatus", method = RequestMethod.POST)
+    @ResponseBody
+    public Result orderStatus(@RequestParam(value = "orderId") Integer orderId) {
+
+
+        String result = TicketUtil.orderStatus(orderId);
+
+        return new Result(true, JSONObject.parseObject(result));
+    }
+
 
 }