|
@@ -1,14 +1,27 @@
|
|
package com.qs.mp.web.controller.api.channel;
|
|
package com.qs.mp.web.controller.api.channel;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.qs.mp.channel.domain.ChannelGoodsOrder;
|
|
import com.qs.mp.channel.domain.ChannelGoodsSettleOrder;
|
|
import com.qs.mp.channel.domain.ChannelGoodsSettleOrder;
|
|
import com.qs.mp.channel.domain.ChannelGoodsSettleOrderItem;
|
|
import com.qs.mp.channel.domain.ChannelGoodsSettleOrderItem;
|
|
|
|
+import com.qs.mp.channel.domain.param.OrderPayParam;
|
|
import com.qs.mp.channel.domain.vo.ChannelGoodsSettleItem;
|
|
import com.qs.mp.channel.domain.vo.ChannelGoodsSettleItem;
|
|
import com.qs.mp.channel.domain.vo.ChannelSettleVO;
|
|
import com.qs.mp.channel.domain.vo.ChannelSettleVO;
|
|
import com.qs.mp.channel.service.IChannelGoodsSettleOrderItemService;
|
|
import com.qs.mp.channel.service.IChannelGoodsSettleOrderItemService;
|
|
import com.qs.mp.channel.service.IChannelGoodsSettleOrderService;
|
|
import com.qs.mp.channel.service.IChannelGoodsSettleOrderService;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.domain.AjaxResult;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
|
+import com.qs.mp.common.enums.AppSourceEnum;
|
|
|
|
+import com.qs.mp.common.enums.BizTypeEnum;
|
|
|
|
+import com.qs.mp.common.enums.ErrorCodeEnum;
|
|
|
|
+import com.qs.mp.common.exception.ServiceException;
|
|
|
|
+import com.qs.mp.common.utils.LogUtil;
|
|
|
|
+import com.qs.mp.common.utils.StringUtils;
|
|
|
|
+import com.qs.mp.pay.service.IWalletService;
|
|
|
|
+import com.qs.mp.system.domain.SysUser;
|
|
|
|
+import com.qs.mp.system.service.ISysUserService;
|
|
|
|
+import com.qs.mp.utils.SecurityUtils;
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -16,11 +29,9 @@ import io.swagger.annotations.ApiResponse;
|
|
import io.swagger.annotations.ApiResponses;
|
|
import io.swagger.annotations.ApiResponses;
|
|
import ma.glasnost.orika.MapperFacade;
|
|
import ma.glasnost.orika.MapperFacade;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -39,6 +50,12 @@ public class ChannelGoodsSettleController extends BaseApiController {
|
|
@Autowired
|
|
@Autowired
|
|
private IChannelGoodsSettleOrderItemService settleOrderItemService;
|
|
private IChannelGoodsSettleOrderItemService settleOrderItemService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISysUserService sysUserService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWalletService walletService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private MapperFacade mapperFacade;
|
|
private MapperFacade mapperFacade;
|
|
|
|
|
|
@@ -49,8 +66,12 @@ public class ChannelGoodsSettleController extends BaseApiController {
|
|
@ApiResponse(code = 200, message = "成功", response = ChannelSettleVO.class)
|
|
@ApiResponse(code = 200, message = "成功", response = ChannelSettleVO.class)
|
|
)
|
|
)
|
|
public TableDataInfo list() {
|
|
public TableDataInfo list() {
|
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
startPage();
|
|
startPage();
|
|
- List<ChannelGoodsSettleOrder> list = settleOrderService.list();
|
|
|
|
|
|
+ List<ChannelGoodsSettleOrder> list = settleOrderService.list(new LambdaQueryWrapper<ChannelGoodsSettleOrder>()
|
|
|
|
+ .eq(ChannelGoodsSettleOrder::getChannelId, channelId)
|
|
|
|
+ .orderByAsc(ChannelGoodsSettleOrder::getStatus)
|
|
|
|
+ .orderByDesc(ChannelGoodsSettleOrder::getCreatedTime));
|
|
List<ChannelSettleVO> channelSettleVOS = mapperFacade.mapAsList(list, ChannelSettleVO.class);
|
|
List<ChannelSettleVO> channelSettleVOS = mapperFacade.mapAsList(list, ChannelSettleVO.class);
|
|
return getDataTable(channelSettleVOS);
|
|
return getDataTable(channelSettleVOS);
|
|
}
|
|
}
|
|
@@ -60,11 +81,40 @@ public class ChannelGoodsSettleController extends BaseApiController {
|
|
@ApiResponses(
|
|
@ApiResponses(
|
|
@ApiResponse(code = 200, message = "成功", response = ChannelSettleVO.class)
|
|
@ApiResponse(code = 200, message = "成功", response = ChannelSettleVO.class)
|
|
)
|
|
)
|
|
- public AjaxResult detail(@PathVariable Long orderId) {
|
|
|
|
|
|
+ public AjaxResult detail(@PathVariable String orderId) {
|
|
|
|
+ Long channelId = SecurityUtils.getLoginUser().getChannelId();
|
|
ChannelGoodsSettleOrder settleOrder = settleOrderService.getById(orderId);
|
|
ChannelGoodsSettleOrder settleOrder = settleOrderService.getById(orderId);
|
|
ChannelSettleVO channelSettleVO = mapperFacade.map(settleOrder, ChannelSettleVO.class);
|
|
ChannelSettleVO channelSettleVO = mapperFacade.map(settleOrder, ChannelSettleVO.class);
|
|
- List<ChannelGoodsSettleOrderItem> items = settleOrderItemService.list(new LambdaQueryWrapper<ChannelGoodsSettleOrderItem>().eq(ChannelGoodsSettleOrderItem::getOrderId, orderId));
|
|
|
|
|
|
+ List<ChannelGoodsSettleOrderItem> items = settleOrderItemService.list(new LambdaQueryWrapper<ChannelGoodsSettleOrderItem>()
|
|
|
|
+ .eq(ChannelGoodsSettleOrderItem::getChannelId, channelId)
|
|
|
|
+ .eq(ChannelGoodsSettleOrderItem::getOrderId, orderId));
|
|
channelSettleVO.setItems(items);
|
|
channelSettleVO.setItems(items);
|
|
return AjaxResult.success(channelSettleVO);
|
|
return AjaxResult.success(channelSettleVO);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @PostMapping("/settle/order/pay")
|
|
|
|
+ @ApiOperation("我的结算支付")
|
|
|
|
+ public AjaxResult pay(@Valid @RequestBody OrderPayParam param) {
|
|
|
|
+ Long userId = SecurityUtils.getLoginUser().getUserId();
|
|
|
|
+ SysUser sysUser = sysUserService.selectUserById(userId);
|
|
|
|
+ String channelOpenId = "";
|
|
|
|
+ if (StringUtils.isNotBlank(param.getOpenId())) {
|
|
|
|
+ channelOpenId = param.getOpenId();
|
|
|
|
+ } else {
|
|
|
|
+ channelOpenId = sysUser.getChannelOpenId();
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(channelOpenId)) {
|
|
|
|
+ return AjaxResult.error(ErrorCodeEnum.ERROR_CODE_1005);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ChannelGoodsSettleOrder channelGoodsOrder = settleOrderService.getById(param.getOrderId());
|
|
|
|
+ JSONObject jsonObject;
|
|
|
|
+ try {
|
|
|
|
+ jsonObject = walletService.pay(BizTypeEnum.CHANNEL_GOODS__SETTLE_ORDER, param.getOrderId(), channelOpenId, channelGoodsOrder.getSettleAmt(), channelGoodsOrder.getTitle(), AppSourceEnum.CHANNEL.getValue());
|
|
|
|
+ } catch (ServiceException e) {
|
|
|
|
+ LogUtil.error(logger, e, "门店采购商品结算订单创建支付单失败。userId:{0},orderId:{1}", new Object[]{userId, param.getOrderId()});
|
|
|
|
+ return AjaxResult.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return AjaxResult.success(jsonObject);
|
|
|
|
+ }
|
|
}
|
|
}
|