1
This commit is contained in:
@@ -24,6 +24,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.domain.JDOrder;
|
||||
import com.ruoyi.jarvis.domain.dto.JDOrderSimpleDTO;
|
||||
import com.ruoyi.jarvis.service.IJDOrderProfitService;
|
||||
import com.ruoyi.jarvis.service.IJDOrderService;
|
||||
import com.ruoyi.jarvis.service.IInstructionService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
@@ -40,16 +41,19 @@ public class JDOrderListController extends BaseController
|
||||
{
|
||||
|
||||
private final IJDOrderService jdOrderService;
|
||||
private final IJDOrderProfitService jdOrderProfitService;
|
||||
private final IOrderRowsService orderRowsService;
|
||||
private final IInstructionService instructionService;
|
||||
private final GroupRebateExcelImportService groupRebateExcelImportService;
|
||||
private final IGroupRebateExcelUploadService groupRebateExcelUploadService;
|
||||
|
||||
public JDOrderListController(IJDOrderService jdOrderService, IOrderRowsService orderRowsService,
|
||||
public JDOrderListController(IJDOrderService jdOrderService, IJDOrderProfitService jdOrderProfitService,
|
||||
IOrderRowsService orderRowsService,
|
||||
IInstructionService instructionService,
|
||||
GroupRebateExcelImportService groupRebateExcelImportService,
|
||||
IGroupRebateExcelUploadService groupRebateExcelUploadService) {
|
||||
this.jdOrderService = jdOrderService;
|
||||
this.jdOrderProfitService = jdOrderProfitService;
|
||||
this.orderRowsService = orderRowsService;
|
||||
this.instructionService = instructionService;
|
||||
this.groupRebateExcelImportService = groupRebateExcelImportService;
|
||||
@@ -279,6 +283,8 @@ public class JDOrderListController extends BaseController
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody JDOrder jdOrder)
|
||||
{
|
||||
jdOrderProfitService.recalculate(jdOrder);
|
||||
jdOrder.getParams().put("applyProfitFields", Boolean.TRUE);
|
||||
return toAjax(jdOrderService.updateJDOrder(jdOrder));
|
||||
}
|
||||
|
||||
@@ -373,6 +379,43 @@ public class JDOrderListController extends BaseController
|
||||
* 一次性批量更新历史订单:将赔付金额大于0的订单标记为后返到账
|
||||
* 此方法只应执行一次,用于处理历史数据
|
||||
*/
|
||||
/**
|
||||
* 按 ID 批量重算售价(自动从型号配置回填)与利润(清除手动锁定后按规则计算)
|
||||
*/
|
||||
@Log(title = "JD订单批量重算利润", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/tools/recalc-profit")
|
||||
@SuppressWarnings("unchecked")
|
||||
public AjaxResult recalcProfitBatch(@RequestBody(required = false) Map<String, Object> body) {
|
||||
if (body == null || !body.containsKey("ids")) {
|
||||
return AjaxResult.error("请传入 ids 数组");
|
||||
}
|
||||
Object raw = body.get("ids");
|
||||
if (!(raw instanceof List)) {
|
||||
return AjaxResult.error("ids 须为数组");
|
||||
}
|
||||
List<?> idList = (List<?>) raw;
|
||||
if (idList.isEmpty()) {
|
||||
return AjaxResult.error("ids 不能为空");
|
||||
}
|
||||
int affected = 0;
|
||||
for (Object o : idList) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
long id = ((Number) o).longValue();
|
||||
JDOrder order = jdOrderService.selectJDOrderById(id);
|
||||
if (order == null) {
|
||||
continue;
|
||||
}
|
||||
order.setProfitManual(0);
|
||||
order.setSellingPriceManual(0);
|
||||
jdOrderProfitService.recalculate(order);
|
||||
order.getParams().put("applyProfitFields", Boolean.TRUE);
|
||||
affected += jdOrderService.updateJDOrder(order);
|
||||
}
|
||||
return AjaxResult.success("已更新 " + affected + " 条订单的售价/利润字段");
|
||||
}
|
||||
|
||||
@Log(title = "批量标记后返到账", businessType = BusinessType.UPDATE)
|
||||
@RequestMapping(value = "/tools/batch-mark-rebate-received", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public AjaxResult batchMarkRebateReceivedForCompensation() {
|
||||
|
||||
Reference in New Issue
Block a user