diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java index 7ae3332c..a1ea8d1f 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java @@ -113,32 +113,28 @@ public class CustomerSelectionController extends BaseController */ @PostMapping("/app/add") @ResponseBody - public AjaxResult appAddSave(@RequestBody List customerSelection) + public AjaxResult appAddSave(@RequestBody CustomerSelection customerSelection) { try { - if(!CollectionUtils.isEmpty(customerSelection)){ - CustomerSelection checkOne = customerSelection.get(0); - Customer customer = customerService.selectByCustomerId(checkOne.getCustomerId()); - if(StringUtil.isEmpty(customer.getPhone())){ - throw new BaseException("手机号为空,无法关联师傅!"); - } - Worker worker = new Worker(); - worker.setPhone(customer.getPhone()); - Long workId; - List workList = workerService.getWorkList(worker); - if(CollectionUtils.isEmpty(workList)){ - throw new BaseException("消费者没有对应的师傅,无需配置选品!"); - }else { - workId = workList.get(0).getWorkerId(); - } - customerSelection.forEach(selection->{ - selection.setWorkId(workId); - customerSelectionService.insertCustomerSelection(selection); - }); - return AjaxResult.success("新增成功"); - }else { - return AjaxResult.error("不能一个都不选哦!"); + Customer customer = customerService.selectByCustomerId(customerSelection.getCustomerId()); + if(StringUtil.isEmpty(customer.getPhone())){ + throw new BaseException("手机号为空,无法关联师傅!"); } + Worker worker = new Worker(); + worker.setPhone(customer.getPhone()); + Long workId; + List workList = workerService.getWorkList(worker); + if(CollectionUtils.isEmpty(workList)){ + throw new BaseException("消费者没有对应的师傅,无需配置选品!"); + }else { + workId = workList.get(0).getWorkerId(); + } + customerSelection.getDeptCategoryIds().forEach(selection->{ + customerSelection.setWorkId(workId); + customerSelection.setDeptCategoryId(selection); + customerSelectionService.insertCustomerSelection(customerSelection); + }); + return AjaxResult.success("新增成功"); }catch (Exception e){ return AjaxResult.error(e.getMessage()); } diff --git a/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerSelection.java b/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerSelection.java index a01e7e6d..17e0da00 100644 --- a/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerSelection.java +++ b/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerSelection.java @@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle; import com.ghy.common.annotation.Excel; import com.ghy.common.core.domain.BaseEntity; +import java.util.List; + /** * 消费者选品对象 customer_selection * @@ -34,10 +36,20 @@ public class CustomerSelection extends BaseEntity @Excel(name = "分公司类目id") private Long deptCategoryId; + private List deptCategoryIds; + /** 选品类型 1.选取 2.屏蔽 */ @Excel(name = "选品类型 1.选取 2.屏蔽") private Long selectionType; + public List getDeptCategoryIds() { + return deptCategoryIds; + } + + public void setDeptCategoryIds(List deptCategoryIds) { + this.deptCategoryIds = deptCategoryIds; + } + public void setId(String id) { this.id = id;