Althars123 3 yıl önce
ebeveyn
işleme
20b5c10abd

+ 26 - 3
twzd-admin/src/main/java/com/miaxis/app/controller/wx/WxController.java

@@ -13,6 +13,7 @@ import com.miaxis.common.utils.SecurityUtils;
 import com.miaxis.common.utils.uuid.CommonUtils;
 import com.miaxis.system.service.ISysDictDataService;
 import com.miaxis.wx.domain.WxOrder;
+import com.miaxis.wx.dto.WxOrderDTO;
 import com.miaxis.wx.service.IWxOrderService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -28,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -95,7 +97,7 @@ public class WxController extends BaseController {
      */
     @PostMapping(value = "/prepareOrder")
     @ApiOperation("微信支付下单")
-    public Response<JSONObject> getPrepareOrder() throws Exception{
+    public Response<JSONObject> getPrepareOrder(@RequestBody WxOrderDTO wxOrderDTO) throws Exception{
 
         //创建本地微信订单
         WxOrder order = new WxOrder();
@@ -106,14 +108,35 @@ public class WxController extends BaseController {
         order.setGoodsType("1");
         wxOrderService.createVipOrder(order);
         wxOrderService.save(order);
-        return Response.success(placeWxOrder(order, "学车vip充值"));
+        return Response.success(placeWxOrder(order, "学车vip充值",notifyUrl));
+
+
+    }
+
+    /**
+     * 微信支付获取预订单id
+     */
+    @PostMapping(value = "/prepareOrder-test")
+    @ApiOperation("微信支付下单-测试")
+    public Response<JSONObject> getPrepareOrderTest() throws Exception{
+
+        //创建本地微信订单
+        WxOrder order = new WxOrder();
+        UserInfo student = SecurityUtils.getLoginUser().getStudent();
+        String orderCode = getOrderCode(student.getId());
+        order.setOutTradeNo(orderCode);
+        order.setOpenid(student.getOpenid());
+        order.setGoodsType("1");
+        wxOrderService.createVipOrder(order);
+        wxOrderService.save(order);
+        return Response.success(placeWxOrder(order, "学车vip充值", ""));
 
 
     }
 
 
     //下单
-    private JSONObject placeWxOrder(WxOrder order, String goodsName) throws Exception {
+    private JSONObject placeWxOrder(WxOrder order, String goodsName, String notifyUrl) throws Exception {
         HttpPost httpPost = initHttpPost();
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         ObjectMapper objectMapper = new ObjectMapper();

+ 19 - 0
twzd-service/src/main/java/com/miaxis/wx/dto/WxOrderDTO.java

@@ -0,0 +1,19 @@
+package com.miaxis.wx.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class WxOrderDTO {
+    private static final long serialVersionUID = 1L;
+
+
+
+    @ApiModelProperty(value = "商品字典编码")
+    private Long dictCode;
+
+
+
+
+
+}