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 new file mode 100644 index 00000000..7ae3332c --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerSelectionController.java @@ -0,0 +1,179 @@ +package com.ghy.web.controller.customer; + +import java.util.List; + +import com.ghy.common.exception.base.BaseException; +import com.ghy.customer.domain.Customer; +import com.ghy.customer.domain.CustomerSelection; +import com.ghy.customer.service.CustomerService; +import com.ghy.customer.service.ICustomerSelectionService; +import com.ghy.worker.domain.Worker; +import com.ghy.worker.service.WorkerService; +import com.huifu.adapay.core.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; +import com.ghy.common.annotation.Log; +import com.ghy.common.enums.BusinessType; +import com.ghy.common.core.controller.BaseController; +import com.ghy.common.core.domain.AjaxResult; +import com.ghy.common.utils.poi.ExcelUtil; +import com.ghy.common.core.page.TableDataInfo; + +/** + * 消费者选品Controller + * + * @author clunt + * @date 2023-01-15 + */ +@Controller +@RequestMapping("/customer/selection") +public class CustomerSelectionController extends BaseController +{ + private String prefix = "customer/selection"; + + @Autowired + private ICustomerSelectionService customerSelectionService; + + @Autowired + private CustomerService customerService; + + @Autowired + private WorkerService workerService; + + @GetMapping() + public String selection() + { + return prefix + "/selection"; + } + + /** + * 查询消费者选品列表 + */ + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(CustomerSelection customerSelection) + { + startPage(); + List list = customerSelectionService.selectCustomerSelectionList(customerSelection); + return getDataTable(list); + } + + /** + * App查询消费者选品列表 + */ + @PostMapping("/app/list") + @ResponseBody + public TableDataInfo appList(@RequestBody CustomerSelection customerSelection) + { + startPage(); + List list = customerSelectionService.selectCustomerSelectionList(customerSelection); + return getDataTable(list); + } + + + /** + * 导出消费者选品列表 + */ + @Log(title = "消费者选品", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(CustomerSelection customerSelection) + { + List list = customerSelectionService.selectCustomerSelectionList(customerSelection); + ExcelUtil util = new ExcelUtil(CustomerSelection.class); + return util.exportExcel(list, "消费者选品数据"); + } + + /** + * 新增消费者选品 + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存消费者选品 + */ + @Log(title = "消费者选品", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(CustomerSelection customerSelection) + { + return toAjax(customerSelectionService.insertCustomerSelection(customerSelection)); + } + + /** + * 新增保存消费者选品 + */ + @PostMapping("/app/add") + @ResponseBody + public AjaxResult appAddSave(@RequestBody List 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("不能一个都不选哦!"); + } + }catch (Exception e){ + return AjaxResult.error(e.getMessage()); + } + } + + /** + * 修改消费者选品 + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") String id, ModelMap mmap) + { + CustomerSelection customerSelection = customerSelectionService.selectCustomerSelectionById(id); + mmap.put("customerSelection", customerSelection); + return prefix + "/edit"; + } + + /** + * 修改保存消费者选品 + */ + @Log(title = "消费者选品", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(CustomerSelection customerSelection) + { + return toAjax(customerSelectionService.updateCustomerSelection(customerSelection)); + } + + /** + * 删除消费者选品 + */ + @Log(title = "消费者选品", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(customerSelectionService.deleteCustomerSelectionByIds(ids)); + } +} 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 new file mode 100644 index 00000000..a01e7e6d --- /dev/null +++ b/ghy-custom/src/main/java/com/ghy/customer/domain/CustomerSelection.java @@ -0,0 +1,112 @@ +package com.ghy.customer.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ghy.common.annotation.Excel; +import com.ghy.common.core.domain.BaseEntity; + +/** + * 消费者选品对象 customer_selection + * + * @author clunt + * @date 2023-01-15 + */ +public class CustomerSelection extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private String id; + + /** 师傅id */ + @Excel(name = "师傅id") + private Long workId; + + /** 分公司id */ + @Excel(name = "分公司id") + private Long deptId; + + /** 消费者id */ + @Excel(name = "消费者id") + private Long customerId; + + /** 分公司类目id */ + @Excel(name = "分公司类目id") + private Long deptCategoryId; + + /** 选品类型 1.选取 2.屏蔽 */ + @Excel(name = "选品类型 1.选取 2.屏蔽") + private Long selectionType; + + public void setId(String id) + { + this.id = id; + } + + public String getId() + { + return id; + } + public void setWorkId(Long workId) + { + this.workId = workId; + } + + public Long getWorkId() + { + return workId; + } + public void setDeptId(Long deptId) + { + this.deptId = deptId; + } + + public Long getDeptId() + { + return deptId; + } + public void setCustomerId(Long customerId) + { + this.customerId = customerId; + } + + public Long getCustomerId() + { + return customerId; + } + public void setDeptCategoryId(Long deptCategoryId) + { + this.deptCategoryId = deptCategoryId; + } + + public Long getDeptCategoryId() + { + return deptCategoryId; + } + public void setSelectionType(Long selectionType) + { + this.selectionType = selectionType; + } + + public Long getSelectionType() + { + return selectionType; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("workId", getWorkId()) + .append("deptId", getDeptId()) + .append("customerId", getCustomerId()) + .append("deptCategoryId", getDeptCategoryId()) + .append("selectionType", getSelectionType()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerSelectionMapper.java b/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerSelectionMapper.java new file mode 100644 index 00000000..dcaf80d1 --- /dev/null +++ b/ghy-custom/src/main/java/com/ghy/customer/mapper/CustomerSelectionMapper.java @@ -0,0 +1,62 @@ +package com.ghy.customer.mapper; + +import com.ghy.customer.domain.CustomerSelection; + +import java.util.List; + +/** + * 消费者选品Mapper接口 + * + * @author clunt + * @date 2023-01-15 + */ +public interface CustomerSelectionMapper +{ + /** + * 查询消费者选品 + * + * @param id 消费者选品主键 + * @return 消费者选品 + */ + public CustomerSelection selectCustomerSelectionById(String id); + + /** + * 查询消费者选品列表 + * + * @param customerSelection 消费者选品 + * @return 消费者选品集合 + */ + public List selectCustomerSelectionList(CustomerSelection customerSelection); + + /** + * 新增消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + public int insertCustomerSelection(CustomerSelection customerSelection); + + /** + * 修改消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + public int updateCustomerSelection(CustomerSelection customerSelection); + + /** + * 删除消费者选品 + * + * @param id 消费者选品主键 + * @return 结果 + */ + public int deleteCustomerSelectionById(String id); + + /** + * 批量删除消费者选品 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteCustomerSelectionByIds(String[] ids); +} \ No newline at end of file diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/ICustomerSelectionService.java b/ghy-custom/src/main/java/com/ghy/customer/service/ICustomerSelectionService.java new file mode 100644 index 00000000..7839bee7 --- /dev/null +++ b/ghy-custom/src/main/java/com/ghy/customer/service/ICustomerSelectionService.java @@ -0,0 +1,62 @@ +package com.ghy.customer.service; + +import com.ghy.customer.domain.CustomerSelection; + +import java.util.List; + +/** + * 消费者选品Service接口 + * + * @author clunt + * @date 2023-01-15 + */ +public interface ICustomerSelectionService +{ + /** + * 查询消费者选品 + * + * @param id 消费者选品主键 + * @return 消费者选品 + */ + public CustomerSelection selectCustomerSelectionById(String id); + + /** + * 查询消费者选品列表 + * + * @param customerSelection 消费者选品 + * @return 消费者选品集合 + */ + public List selectCustomerSelectionList(CustomerSelection customerSelection); + + /** + * 新增消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + public int insertCustomerSelection(CustomerSelection customerSelection); + + /** + * 修改消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + public int updateCustomerSelection(CustomerSelection customerSelection); + + /** + * 批量删除消费者选品 + * + * @param ids 需要删除的消费者选品主键集合 + * @return 结果 + */ + public int deleteCustomerSelectionByIds(String ids); + + /** + * 删除消费者选品信息 + * + * @param id 消费者选品主键 + * @return 结果 + */ + public int deleteCustomerSelectionById(String id); +} diff --git a/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerSelectionServiceImpl.java b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerSelectionServiceImpl.java new file mode 100644 index 00000000..248292d5 --- /dev/null +++ b/ghy-custom/src/main/java/com/ghy/customer/service/impl/CustomerSelectionServiceImpl.java @@ -0,0 +1,97 @@ +package com.ghy.customer.service.impl; + +import java.util.List; +import com.ghy.common.utils.DateUtils; +import com.ghy.customer.domain.CustomerSelection; +import com.ghy.customer.mapper.CustomerSelectionMapper; +import com.ghy.customer.service.ICustomerSelectionService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ghy.common.core.text.Convert; + +/** + * 消费者选品Service业务层处理 + * + * @author clunt + * @date 2023-01-15 + */ +@Service +public class CustomerSelectionServiceImpl implements ICustomerSelectionService +{ + @Autowired + private CustomerSelectionMapper customerSelectionMapper; + + /** + * 查询消费者选品 + * + * @param id 消费者选品主键 + * @return 消费者选品 + */ + @Override + public CustomerSelection selectCustomerSelectionById(String id) + { + return customerSelectionMapper.selectCustomerSelectionById(id); + } + + /** + * 查询消费者选品列表 + * + * @param customerSelection 消费者选品 + * @return 消费者选品 + */ + @Override + public List selectCustomerSelectionList(CustomerSelection customerSelection) + { + return customerSelectionMapper.selectCustomerSelectionList(customerSelection); + } + + /** + * 新增消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + @Override + public int insertCustomerSelection(CustomerSelection customerSelection) + { + customerSelection.setCreateTime(DateUtils.getNowDate()); + return customerSelectionMapper.insertCustomerSelection(customerSelection); + } + + /** + * 修改消费者选品 + * + * @param customerSelection 消费者选品 + * @return 结果 + */ + @Override + public int updateCustomerSelection(CustomerSelection customerSelection) + { + customerSelection.setUpdateTime(DateUtils.getNowDate()); + return customerSelectionMapper.updateCustomerSelection(customerSelection); + } + + /** + * 批量删除消费者选品 + * + * @param ids 需要删除的消费者选品主键 + * @return 结果 + */ + @Override + public int deleteCustomerSelectionByIds(String ids) + { + return customerSelectionMapper.deleteCustomerSelectionByIds(Convert.toStrArray(ids)); + } + + /** + * 删除消费者选品信息 + * + * @param id 消费者选品主键 + * @return 结果 + */ + @Override + public int deleteCustomerSelectionById(String id) + { + return customerSelectionMapper.deleteCustomerSelectionById(id); + } +} diff --git a/ghy-custom/src/main/resources/mapper/customer/CustomerSelectionMapper.xml b/ghy-custom/src/main/resources/mapper/customer/CustomerSelectionMapper.xml new file mode 100644 index 00000000..b389fa3e --- /dev/null +++ b/ghy-custom/src/main/resources/mapper/customer/CustomerSelectionMapper.xml @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + select id, work_id, dept_id, customer_id, dept_category_id, selection_type, create_by, create_time, update_by, update_time, remark from customer_selection + + + + + + + + insert into customer_selection + + work_id, + dept_id, + customer_id, + dept_category_id, + selection_type, + create_by, + create_time, + update_by, + update_time, + remark, + + + #{workId}, + #{deptId}, + #{customerId}, + #{deptCategoryId}, + #{selectionType}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + #{remark}, + + + + + update customer_selection + + work_id = #{workId}, + dept_id = #{deptId}, + customer_id = #{customerId}, + dept_category_id = #{deptCategoryId}, + selection_type = #{selectionType}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + remark = #{remark}, + + where id = #{id} + + + + delete from customer_selection where id = #{id} + + + + delete from customer_selection where id in + + #{id} + + + + \ No newline at end of file diff --git a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java index 86e8ce15..d6c92635 100644 --- a/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java +++ b/ghy-framework/src/main/java/com/ghy/framework/config/ShiroConfig.java @@ -288,6 +288,7 @@ public class ShiroConfig filterChainDefinitionMap.put("/adapay/**", "anon"); filterChainDefinitionMap.put("/system/area/**", "anon"); filterChainDefinitionMap.put("/customer/address/**", "anon"); + filterChainDefinitionMap.put("/customer/selection/app/**", "anon"); filterChainDefinitionMap.put("/jim/**", "anon"); filterChainDefinitionMap.put("/MP_verify_bRFuvYpyQ4WLr0on.txt", "anon"); // 对静态资源设置匿名访问