|
|
@@ -4,6 +4,8 @@ package com.goafanti.order.controller;
|
|
|
|
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
@@ -14,13 +16,14 @@ import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.CertifyApiController;
|
|
|
import com.goafanti.common.model.TemporaryReceivables;
|
|
|
+import com.goafanti.order.bo.TemporaryReceivablesBo;
|
|
|
import com.goafanti.order.service.OrderReceivablesService;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/api/admin/receivables")
|
|
|
public class AdminOrderReceivablesApiController extends CertifyApiController {
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private OrderReceivablesService orderReceivablesService;
|
|
|
/**
|
|
|
* 新增预计回款信息
|
|
|
@@ -28,8 +31,16 @@ public class AdminOrderReceivablesApiController extends CertifyApiController {
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/addReceivables",method = RequestMethod.POST)
|
|
|
- public Result addReceivables(TemporaryReceivables t){
|
|
|
+ public Result addReceivables(TemporaryReceivablesBo t){
|
|
|
Result res = new Result();
|
|
|
+ res=inputCheck(t, res);
|
|
|
+ if (!res.getError().isEmpty()) {
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.data(orderReceivablesService.addReceivables(t));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ private Result inputCheck(TemporaryReceivablesBo t, Result res) {
|
|
|
if(StringUtils.isBlank(t.getOrderNo())){
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号编号"));
|
|
|
return res;
|
|
|
@@ -38,21 +49,20 @@ public class AdminOrderReceivablesApiController extends CertifyApiController {
|
|
|
res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","收款金额"));
|
|
|
return res;
|
|
|
}
|
|
|
- res.data(orderReceivablesService.addReceivables(t));
|
|
|
+ if(t.getReceivablesTimes() == null){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","收款时间"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
return res;
|
|
|
}
|
|
|
/**
|
|
|
* 修改预计回款
|
|
|
*/
|
|
|
@RequestMapping(value = "/updateReceivables",method = RequestMethod.POST)
|
|
|
- public Result updateReceivables(TemporaryReceivables t){
|
|
|
+ public Result updateReceivables(TemporaryReceivablesBo t){
|
|
|
Result res = new Result();
|
|
|
- if(StringUtils.isBlank(t.getOrderNo())){
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","订单编号编号"));
|
|
|
- return res;
|
|
|
- }
|
|
|
- if(t.getAmount() == null){
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","收款金额"));
|
|
|
+ res=inputCheck(t, res);
|
|
|
+ if (!res.getError().isEmpty()) {
|
|
|
return res;
|
|
|
}
|
|
|
res.data(orderReceivablesService.updateReceivables(t));
|
|
|
@@ -60,15 +70,25 @@ public class AdminOrderReceivablesApiController extends CertifyApiController {
|
|
|
}
|
|
|
/**
|
|
|
* 删除预计回款
|
|
|
+ * @param ids 逗号隔开的id
|
|
|
+ * @param type 0 多个 1全部
|
|
|
+ * @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/deleteReceivables",method = RequestMethod.POST)
|
|
|
- public Result deleteReceivables(String ids){
|
|
|
+ public Result deleteReceivables(String ids,Integer type){
|
|
|
Result res = new Result();
|
|
|
- if(null==ids) {
|
|
|
- res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","id"));
|
|
|
+ if(type==null) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","删除类型"));
|
|
|
return res;
|
|
|
+ }else if (type==0) {
|
|
|
+ if(null==ids) {
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"","id或删除量"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.data(orderReceivablesService.deleteReceivables(ids));
|
|
|
+ } else {
|
|
|
+ res.data(orderReceivablesService.deleteAllReceivables());
|
|
|
}
|
|
|
- res.data(orderReceivablesService.deleteReceivables(ids));
|
|
|
return res;
|
|
|
}
|
|
|
}
|