选品广场接口
This commit is contained in:
parent
e2112b4a5f
commit
fb6e657848
|
|
@ -113,32 +113,28 @@ public class CustomerSelectionController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PostMapping("/app/add")
|
@PostMapping("/app/add")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult appAddSave(@RequestBody List<CustomerSelection> customerSelection)
|
public AjaxResult appAddSave(@RequestBody CustomerSelection customerSelection)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if(!CollectionUtils.isEmpty(customerSelection)){
|
Customer customer = customerService.selectByCustomerId(customerSelection.getCustomerId());
|
||||||
CustomerSelection checkOne = customerSelection.get(0);
|
if(StringUtil.isEmpty(customer.getPhone())){
|
||||||
Customer customer = customerService.selectByCustomerId(checkOne.getCustomerId());
|
throw new BaseException("手机号为空,无法关联师傅!");
|
||||||
if(StringUtil.isEmpty(customer.getPhone())){
|
|
||||||
throw new BaseException("手机号为空,无法关联师傅!");
|
|
||||||
}
|
|
||||||
Worker worker = new Worker();
|
|
||||||
worker.setPhone(customer.getPhone());
|
|
||||||
Long workId;
|
|
||||||
List<Worker> 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("不能一个都不选哦!");
|
|
||||||
}
|
}
|
||||||
|
Worker worker = new Worker();
|
||||||
|
worker.setPhone(customer.getPhone());
|
||||||
|
Long workId;
|
||||||
|
List<Worker> 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){
|
}catch (Exception e){
|
||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ghy.common.annotation.Excel;
|
import com.ghy.common.annotation.Excel;
|
||||||
import com.ghy.common.core.domain.BaseEntity;
|
import com.ghy.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消费者选品对象 customer_selection
|
* 消费者选品对象 customer_selection
|
||||||
*
|
*
|
||||||
|
|
@ -34,10 +36,20 @@ public class CustomerSelection extends BaseEntity
|
||||||
@Excel(name = "分公司类目id")
|
@Excel(name = "分公司类目id")
|
||||||
private Long deptCategoryId;
|
private Long deptCategoryId;
|
||||||
|
|
||||||
|
private List<Long> deptCategoryIds;
|
||||||
|
|
||||||
/** 选品类型 1.选取 2.屏蔽 */
|
/** 选品类型 1.选取 2.屏蔽 */
|
||||||
@Excel(name = "选品类型 1.选取 2.屏蔽")
|
@Excel(name = "选品类型 1.选取 2.屏蔽")
|
||||||
private Long selectionType;
|
private Long selectionType;
|
||||||
|
|
||||||
|
public List<Long> getDeptCategoryIds() {
|
||||||
|
return deptCategoryIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeptCategoryIds(List<Long> deptCategoryIds) {
|
||||||
|
this.deptCategoryIds = deptCategoryIds;
|
||||||
|
}
|
||||||
|
|
||||||
public void setId(String id)
|
public void setId(String id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue