|
|
@@ -8,25 +8,46 @@ import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.utils.ParseUtils;
|
|
|
+import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.core.security.LoginUser;
|
|
|
+import com.fs.core.web.service.TokenService;
|
|
|
+import com.fs.crm.domain.CrmCustomer;
|
|
|
+import com.fs.crm.service.ICrmCustomerService;
|
|
|
import com.fs.erp.domain.ErpDeliverys;
|
|
|
import com.fs.erp.domain.ErpOrderQuery;
|
|
|
import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
|
import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
+import com.fs.erp.utils.ErpContextHolder;
|
|
|
import com.fs.live.domain.LiveOrder;
|
|
|
+import com.fs.live.domain.LiveOrderItem;
|
|
|
+import com.fs.live.domain.LiveOrderLogs;
|
|
|
+import com.fs.live.domain.LiveOrderPayment;
|
|
|
import com.fs.live.enums.LiveOrderCancleReason;
|
|
|
+import com.fs.live.service.ILiveOrderItemService;
|
|
|
+import com.fs.live.service.ILiveOrderLogsService;
|
|
|
+import com.fs.live.service.ILiveOrderPaymentService;
|
|
|
import com.fs.live.service.ILiveOrderService;
|
|
|
import com.fs.live.vo.LiveGoodsVo;
|
|
|
import com.fs.live.vo.LiveOrderPaymentVo;
|
|
|
import com.fs.live.vo.LiveOrderVo;
|
|
|
+import com.fs.store.domain.FsStoreOrder;
|
|
|
+import com.fs.store.domain.FsStoreOrderStatus;
|
|
|
+import com.fs.store.domain.FsUser;
|
|
|
+import com.fs.store.mapper.FsWarehousesMapper;
|
|
|
+import com.fs.store.param.*;
|
|
|
import com.fs.store.service.IFsExpressService;
|
|
|
+import com.fs.store.service.IFsUserService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -43,6 +64,24 @@ public class LiveOrderController extends BaseController
|
|
|
{
|
|
|
@Autowired
|
|
|
private ILiveOrderService liveOrderService;
|
|
|
+ @Autowired
|
|
|
+ private ICrmCustomerService crmCustomerService;
|
|
|
+ @Autowired
|
|
|
+ private IFsUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveOrderItemService orderItemService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveOrderLogsService orderLogsService;
|
|
|
+ @Autowired
|
|
|
+ private ILiveOrderPaymentService orderPaymentService;
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private IFsExpressService expressService;
|
|
|
+ @Autowired
|
|
|
+ private FsWarehousesMapper fsWarehousesMapper;
|
|
|
+ @Autowired
|
|
|
+ IErpOrderService erpOrderService;
|
|
|
|
|
|
|
|
|
// @Autowired
|
|
|
@@ -254,7 +293,172 @@ public class LiveOrderController extends BaseController
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
+ @Log(title = "退款", businessType = BusinessType.UPDATE)
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:refundOrderMoney')")
|
|
|
+ @PostMapping("/refundOrderMoney")
|
|
|
+ public synchronized R refundOrderMoney(@Validated @RequestBody FsStoreOrderRefundParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.refundOrderMoney(param.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取订单详细信息
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:query')")
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public R getInfo(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ LiveOrder order=liveOrderService.selectLiveOrderByOrderId(String.valueOf(id));
|
|
|
+ order.setUserPhone(ParseUtils.parsePhone(order.getUserPhone()));
|
|
|
+ order.setUserAddress(ParseUtils.parseAddress(order.getUserAddress()));
|
|
|
+ FsUser user=userService.selectFsUserById(Long.valueOf(order.getUserId()));
|
|
|
+ user.setPhone(ParseUtils.parsePhone(user.getPhone()));
|
|
|
+ List<LiveOrderItem> items=orderItemService.selectCheckedByOrderId(id);
|
|
|
+ FsStoreOrderStatus statusMap=new FsStoreOrderStatus();
|
|
|
+
|
|
|
+ List<LiveOrderLogs> logs=orderLogsService.selectLiveOrderLogsByOrderId(id);
|
|
|
+ List<LiveOrderPayment> payments=orderPaymentService.selectLiveOrderPaymentByOrderId(id);
|
|
|
+
|
|
|
+ CrmCustomer customer=null;
|
|
|
+ if(order.getCustomerId()!=null&&order.getCustomerId()>0){
|
|
|
+ customer=crmCustomerService.selectCrmCustomerById(order.getCustomerId());
|
|
|
+ }
|
|
|
+ return R.ok().put("order", order).put("items", items).put("logs",logs).put("user",user).put("customer",customer).put("payments",payments) ;
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/queryAddress/{id}")
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:queryAddress')")
|
|
|
+ public R getAddress(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(id));
|
|
|
+ String address = order.getUserAddress();
|
|
|
+ return R.ok().put("address",address);
|
|
|
+ }
|
|
|
+ @GetMapping(value = "/queryPhone/{id}")
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:queryPhone')")
|
|
|
+ @Log(title = "查看电话", businessType = BusinessType.GRANT)
|
|
|
+ public R getPhone(@PathVariable("id") Long id)
|
|
|
+ {
|
|
|
+ LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(id));
|
|
|
+ String userPhone = order.getUserPhone();
|
|
|
+ return R.ok().put("userPhone",userPhone);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据orderId查询
|
|
|
+ */
|
|
|
+ @GetMapping("/getByOrderId/{orderId}")
|
|
|
+ public R getByOrderId(@PathVariable Long orderId) {
|
|
|
+ LiveOrder liveOrder = liveOrderService.selectLiveOrderByOrderId(String.valueOf(orderId));
|
|
|
+ return R.ok().put("data",liveOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation("物流查询")
|
|
|
+ @PostMapping("/getExpressByDeliverId")
|
|
|
+ public R getExpressByDeliverId(@Validated @RequestBody FsStoreOrderExpressParam param, HttpServletRequest request){
|
|
|
+ return expressService.getLiveExpressByDeliverId(param);
|
|
|
+ }
|
|
|
+
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:auditPayRemain')")
|
|
|
+ @PostMapping("/auditPayRemain")
|
|
|
+ public R auditPayRemain(@Validated @RequestBody FsStoreOrderAuditPayRemainParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.auditPayRemain(param.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "分佣", businessType = BusinessType.UPDATE)
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:addTuiMoney')")
|
|
|
+ @PostMapping("/addTuiMoney")
|
|
|
+ public R addTuiMoney(@Validated @RequestBody FsStoreOrderAddTuiMoneyParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.addTuiMoney(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "同步物流", businessType = BusinessType.UPDATE)
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:syncExpress')")
|
|
|
+ @PostMapping("/syncExpress")
|
|
|
+ public R syncExpress(@Validated @RequestBody FsStoreOrderExpressEditParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.syncExpress(param.getOrderId());
|
|
|
+ }
|
|
|
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:updateExpress')")
|
|
|
+ @PostMapping("/updateExpress")
|
|
|
+ public R updateExpress(@Validated @RequestBody FsStoreOrderExpressEditParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.updateExpress(param.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:getEroOrder')")
|
|
|
+ @GetMapping("/getEroOrder")
|
|
|
+ public R getEroOrder(@RequestParam("extendOrderId") String extendOrderId) {
|
|
|
+ ErpOrderQueryRequert request = new ErpOrderQueryRequert();
|
|
|
+ request.setCode(extendOrderId);
|
|
|
+ if(StringUtils.isEmpty(extendOrderId)) return R.error("物流订单ID为空!");
|
|
|
+
|
|
|
+ LiveOrder order = liveOrderService.selectLiveOrderByExtendId(extendOrderId);
|
|
|
+
|
|
|
+ // 根据仓库code找erp
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotBlank(order.getStoreHouseCode())){
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
+ ErpContextHolder.setErpType(erp);
|
|
|
+ }
|
|
|
+
|
|
|
+ ErpOrderQueryResponse response = erpOrderService.getOrder(request);
|
|
|
+ return R.ok().put("data",response);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "冻结、解冻佣金", businessType = BusinessType.UPDATE)
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:editTuiMoney')")
|
|
|
+ @PostMapping("/editTuiMoney")
|
|
|
+ public R editTuiMoney(@Validated @RequestBody FsStoreOrderEditTuiMoneyParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.editTuiMoney(param.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "确认订单", businessType = BusinessType.UPDATE)
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:finishOrder')")
|
|
|
+ @PostMapping("/finishOrder")
|
|
|
+ public R finishOrder(@Validated @RequestBody FsStoreOrderFinishParam param, HttpServletRequest request) {
|
|
|
+ return liveOrderService.finishOrder(param.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "手动推管易", businessType = BusinessType.INSERT)
|
|
|
+ @ApiOperation("创建ERP订单")
|
|
|
+// @PreAuthorize("@ss.hasPermi('store:storeOrder:createErpOrder')")
|
|
|
+ @GetMapping("/createErpOrder")
|
|
|
+ public R createErpOrder(@RequestParam("orderCode") String orderCode) throws Exception
|
|
|
+ {
|
|
|
+ LiveOrder order=liveOrderService.selectOrderIdByOrderCode(orderCode);
|
|
|
+ liveOrderService.createOmsOrder(order.getOrderId());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "同步管易物流单号", businessType = BusinessType.UPDATE)
|
|
|
+ @PreAuthorize("@ss.hasPermi('store:storeOrder:updateErpOrder')")
|
|
|
+ @PostMapping("/updateErpOrder")
|
|
|
+ public R updateErpOrder(@Validated @RequestBody FsStoreOrderExpressEditParam param) {
|
|
|
+ LiveOrder order = liveOrderService.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
+ ErpOrderQueryRequert request = new ErpOrderQueryRequert();
|
|
|
+ request.setCode(order.getExtendOrderId());
|
|
|
+
|
|
|
+ // 根据仓库code找erp
|
|
|
+ if(com.fs.common.utils.StringUtils.isNotBlank(order.getStoreHouseCode())){
|
|
|
+ String erp = fsWarehousesMapper.selectErpByCode(order.getStoreHouseCode());
|
|
|
+ ErpContextHolder.setErpType(erp);
|
|
|
+ }
|
|
|
+
|
|
|
+ ErpOrderQueryResponse response = erpOrderService.getOrder(request);
|
|
|
+ if(response.getOrders()!=null&&response.getOrders().size()>0){
|
|
|
+ for(ErpOrderQuery orderQuery : response.getOrders()){
|
|
|
+ if(orderQuery.getDeliverys()!=null&&orderQuery.getDeliverys().size()>0){
|
|
|
+ for(ErpDeliverys delivery:orderQuery.getDeliverys()){
|
|
|
+ if(delivery.getDelivery()&& StringUtils.isNotEmpty(delivery.getMail_no())){
|
|
|
+ //更新商订单状态
|
|
|
+ liveOrderService.updateDeliveryOrder(param.getOrderId(), delivery.getMail_no(),delivery.getExpress_code(),delivery.getExpress_name());
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.error("未查询到快递信息");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|