|
@@ -7,12 +7,14 @@ import com.miaxis.order.domain.OrderInfo;
|
|
|
import com.miaxis.order.dto.OrderInfoDto;
|
|
|
import com.miaxis.order.service.IOrderInfoService;
|
|
|
import com.miaxis.wx.domain.WxOrder;
|
|
|
+import com.miaxis.wx.dto.WxOrderShareProfitDTO;
|
|
|
import com.miaxis.wx.service.IRefundRecordService;
|
|
|
import com.miaxis.wx.service.IWxOrderService;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static com.miaxis.common.utils.OrderCodeFactory.getOrderCode;
|
|
@@ -25,7 +27,7 @@ import static com.miaxis.common.utils.OrderCodeFactory.getOrderCode;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/order/info")
|
|
|
-@Api(tags={"【PC-订单信息】"})
|
|
|
+@Api(tags = {"【PC-订单信息】"})
|
|
|
public class PcOrderInfoController extends BaseController {
|
|
|
@Autowired
|
|
|
private IOrderInfoService orderInfoService;
|
|
@@ -40,16 +42,75 @@ public class PcOrderInfoController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping("/list")
|
|
|
@ApiOperation("查询订单信息列表")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
|
|
|
- @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
|
|
|
})
|
|
|
- public ResponsePageInfo<OrderInfo> list(@ModelAttribute OrderInfoDto orderInfoDto){
|
|
|
+ public ResponsePageInfo<OrderInfo> list(@ModelAttribute OrderInfoDto orderInfoDto) {
|
|
|
startPage();
|
|
|
List<OrderInfo> list = orderInfoService.selectOrderInfoList(orderInfoDto);
|
|
|
return toResponsePageInfo(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询分帐订单列表
|
|
|
+ */
|
|
|
+ @GetMapping("/wxlist")
|
|
|
+ @ApiOperation("查询分帐订单列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "pageNum", value = "当前页码", dataType = "int", paramType = "query", required = false),
|
|
|
+ @ApiImplicitParam(name = "pageSize", value = "每页数据量", dataType = "int", paramType = "query", required = false),
|
|
|
+ })
|
|
|
+ public ResponsePageInfo<WxOrder> wxlist(@ModelAttribute WxOrderShareProfitDTO wxOrderShareProfitDTO) {
|
|
|
+ startPage();
|
|
|
+ List<WxOrder> list = wxOrderService.selectWxOrderProfitList(wxOrderShareProfitDTO);
|
|
|
+ return toResponsePageInfo(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起分账
|
|
|
+ */
|
|
|
+ @PutMapping(value = "/shareProfit/{outTradeNo}")
|
|
|
+ @ApiOperation("发起分账")
|
|
|
+ public Response<OrderInfo> shareProfit(
|
|
|
+ @ApiParam(name = "outTradeNo", value = "商户订单信息", required = true)
|
|
|
+ @PathVariable("outTradeNo") String outTradeNo) throws Exception {
|
|
|
+ WxOrder order = wxOrderService.getByOutTradeNo(outTradeNo);
|
|
|
+
|
|
|
+ if (!"SUCCESS".equals(order.getTradeState())) {
|
|
|
+ Response response = new Response(200, "非支付成功的订单,无法分账。");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ if (order.getProfitSharing() != 1) {
|
|
|
+ Response response = new Response(200, "非待分账订单,无法分账。");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前时间
|
|
|
+ Date currentDate = new Date();
|
|
|
+ // 添加5分钟
|
|
|
+ long fiveMinutesInMillis = 1 * 60 * 1000; // 5分钟的毫秒数
|
|
|
+ Date nowDate = new Date(currentDate.getTime() - fiveMinutesInMillis);
|
|
|
+
|
|
|
+ if (nowDate.compareTo(order.getSuccessTime()) < 0) {
|
|
|
+ Response response = new Response(200, "支付成功的订单,未满5分钟无法分账,请稍后操作。");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean addFlag = wxOrderService.wxAddFenZhang(order);
|
|
|
+ boolean flag = wxOrderService.wxProfitsharing(order);
|
|
|
+ if (flag && addFlag) {
|
|
|
+ Response response = new Response(200, "分账成功");
|
|
|
+ return response;
|
|
|
+ } else {
|
|
|
+ Response response = new Response(200, "分账失败,请联系管理员");
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取订单信息详细信息
|
|
|
*/
|
|
@@ -58,7 +119,7 @@ public class PcOrderInfoController extends BaseController {
|
|
|
public Response<OrderInfo> getInfo(
|
|
|
@ApiParam(name = "id", value = "订单信息参数", required = true)
|
|
|
@PathVariable("id") Long id
|
|
|
- ){
|
|
|
+ ) {
|
|
|
return Response.success(orderInfoService.getById(id));
|
|
|
}
|
|
|
|
|
@@ -75,14 +136,11 @@ public class PcOrderInfoController extends BaseController {
|
|
|
) throws Exception {
|
|
|
String refundCode = getOrderCode(null);
|
|
|
WxOrder order = wxOrderService.getByOutTradeNo(outTradeNo);
|
|
|
- refundRecordService.refund(order,refundCode,reason);
|
|
|
+ refundRecordService.refund(order, refundCode, reason);
|
|
|
//TODO 取消会员内容
|
|
|
orderInfoService.refundOrder(order);
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|