|
@@ -7,6 +7,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
7
|
7
|
import com.yunzhi.inte.common.BaseController;
|
8
|
8
|
import com.yunzhi.inte.common.ResponseBean;
|
9
|
9
|
import java.util.List;
|
|
10
|
+
|
|
11
|
+import com.yunzhi.inte.entity.Dishes;
|
|
12
|
+import com.yunzhi.inte.entity.GuaranteeTask;
|
|
13
|
+import com.yunzhi.inte.service.DishesService;
|
|
14
|
+import com.yunzhi.inte.service.GuaranteeTaskService;
|
10
|
15
|
import io.swagger.annotations.Api;
|
11
|
16
|
import io.swagger.annotations.ApiOperation;
|
12
|
17
|
import io.swagger.annotations.ApiParam;
|
|
@@ -28,6 +33,12 @@ public class GuaranteeDetailController extends BaseController {
|
28
|
33
|
@Autowired
|
29
|
34
|
private GuaranteeDetailService guaranteeDetailService;
|
30
|
35
|
|
|
36
|
+ @Autowired
|
|
37
|
+ private DishesService dishesService;
|
|
38
|
+
|
|
39
|
+ @Autowired
|
|
40
|
+ private GuaranteeTaskService guaranteeTaskService;
|
|
41
|
+
|
31
|
42
|
/**
|
32
|
43
|
* 通过ID查询单条数据
|
33
|
44
|
*
|
|
@@ -104,8 +115,22 @@ public class GuaranteeDetailController extends BaseController {
|
104
|
115
|
guaranteeDetailService.remove(queryWrapper);
|
105
|
116
|
|
106
|
117
|
// 再批量插入
|
|
118
|
+ int costs = 0;
|
107
|
119
|
for (GuaranteeDetail item : list) {
|
108
|
120
|
item.setGuaranteeId(guaranteeId);
|
|
121
|
+
|
|
122
|
+ Dishes dishes = dishesService.getById(item.getDishId());
|
|
123
|
+ if (null != dishes) {
|
|
124
|
+ Integer price = dishes.getPrice();
|
|
125
|
+ costs += null == price ? 0 : price;
|
|
126
|
+ }
|
|
127
|
+ }
|
|
128
|
+
|
|
129
|
+ // 更新成本
|
|
130
|
+ GuaranteeTask task = guaranteeTaskService.getById(guaranteeId);
|
|
131
|
+ if (null != task) {
|
|
132
|
+ task.setCosts(costs);
|
|
133
|
+ guaranteeTaskService.updateById(task);
|
109
|
134
|
}
|
110
|
135
|
|
111
|
136
|
guaranteeDetailService.saveBatch(list);
|