|
@@ -8,6 +8,7 @@ import com.iamberry.wechat.core.entity.product.ProductColor;
|
|
import com.iamberry.wechat.face.agentInfo.AgentInfoService;
|
|
import com.iamberry.wechat.face.agentInfo.AgentInfoService;
|
|
import com.iamberry.wechat.face.porduct.ProductColorService;
|
|
import com.iamberry.wechat.face.porduct.ProductColorService;
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
import com.iamberry.wechat.tools.ResultInfo;
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -71,18 +73,152 @@ public class AdminAgentToothHandler {
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
Map<String,Object> map = new HashMap<String,Object>();
|
|
ProductColor productColor = new ProductColor();
|
|
ProductColor productColor = new ProductColor();
|
|
productColor.setPage(null);
|
|
productColor.setPage(null);
|
|
|
|
+ //查询产品颜色集合
|
|
List<ProductColor> colorList = productColorService.selectProductColorList(productColor);
|
|
List<ProductColor> colorList = productColorService.selectProductColorList(productColor);
|
|
- if (colorList == null || colorList.size() <= 0) {
|
|
|
|
|
|
+ AgentTooth agent = new AgentTooth();
|
|
|
|
+ agent.setAgentStatus(1);
|
|
|
|
+ //查询代理商集合
|
|
|
|
+ List<AgentTooth> agentList = agentInfoService.listAgentTooth(agent);
|
|
|
|
+ map.put("colorList",colorList);
|
|
|
|
+ map.put("agentList",agentList);
|
|
|
|
+ msg.setData(map);
|
|
|
|
+ msg.setStatus(true);
|
|
|
|
+ msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/add_agent_config")
|
|
|
|
+ public ResultMsg addAgentConfig(HttpServletRequest request) throws Exception {
|
|
|
|
+ ResultMsg msg = new ResultMsg();
|
|
|
|
+ String productColor = request.getParameter("productColor");
|
|
|
|
+ String agentId = request.getParameter("sel_agent");
|
|
|
|
+ if (!StringUtils.isNotEmpty(productColor)) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ msg.setMessage("您没有输入优惠价请重新输入!");
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isNotEmpty(agentId)) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
msg.setStatus(false);
|
|
msg.setStatus(false);
|
|
|
|
+ msg.setMessage("您没有选择代理商,请选择!");
|
|
}
|
|
}
|
|
|
|
+ //拆分产品id和金额
|
|
|
|
+ String[] productPrice = productColor.split(",");
|
|
|
|
+ List<AgentConfig> list = new ArrayList<AgentConfig>();
|
|
|
|
+ for (int i = 0;i < productPrice.length;i++) {
|
|
|
|
+ String[] color = productPrice[i].split(":");
|
|
|
|
+ AgentConfig config = new AgentConfig();
|
|
|
|
+ config.setAgentId(Integer.parseInt(agentId));
|
|
|
|
+ config.setColorId(Integer.parseInt(color[0]));
|
|
|
|
+ config.setConfigAmount(Integer.parseInt(color[1]));
|
|
|
|
+ config.setConfigStatus(1);
|
|
|
|
+ list.add(config);
|
|
|
|
+ }
|
|
|
|
+ int num = agentInfoService.addAgentConfigList(list);
|
|
|
|
+ if (num > 0) {
|
|
|
|
+ msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
|
+ msg.setStatus(true);
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setMessage("添加代理商优惠价失败!");
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @RequestMapping("/_update_agent_config")
|
|
|
|
+ public ModelAndView updateAgentConfig(HttpServletRequest request) throws Exception {
|
|
|
|
+ String configId = request.getParameter("configId");
|
|
|
|
+ ModelAndView mv = new ModelAndView("admin/agentInfo/updateAgentConfig");
|
|
|
|
+ mv.addObject("configId",configId);
|
|
|
|
+ return mv;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/get_agent_config_By_Id")
|
|
|
|
+ public ResultMsg getAgentConfigById(HttpServletRequest request) throws Exception{
|
|
|
|
+ ResultMsg msg = new ResultMsg();
|
|
|
|
+ Map<String,Object> map = new HashMap<String,Object>();
|
|
|
|
+ String configId = request.getParameter("configId");
|
|
|
|
+ if (!StringUtils.isNotEmpty(configId)) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ msg.setMessage("该配置信息不存在!");
|
|
|
|
+ }
|
|
|
|
+ AgentConfig config = new AgentConfig();
|
|
|
|
+ config.setConfigId(Integer.parseInt(configId));
|
|
|
|
+ config.setPage(null);
|
|
|
|
+ //查询代理商配置金额集合
|
|
|
|
+ List<AgentConfig> configList = agentInfoService.listAgentConfig(config);
|
|
|
|
+
|
|
|
|
+ ProductColor productColor = new ProductColor();
|
|
|
|
+ productColor.setPage(null);
|
|
|
|
+ //查询产品颜色集合
|
|
|
|
+ List<ProductColor> colorList = productColorService.selectProductColorList(productColor);
|
|
AgentTooth agent = new AgentTooth();
|
|
AgentTooth agent = new AgentTooth();
|
|
agent.setAgentStatus(1);
|
|
agent.setAgentStatus(1);
|
|
|
|
+ //查询代理商集合
|
|
List<AgentTooth> agentList = agentInfoService.listAgentTooth(agent);
|
|
List<AgentTooth> agentList = agentInfoService.listAgentTooth(agent);
|
|
map.put("colorList",colorList);
|
|
map.put("colorList",colorList);
|
|
map.put("agentList",agentList);
|
|
map.put("agentList",agentList);
|
|
|
|
+ map.put("config",configList.get(0));
|
|
msg.setData(map);
|
|
msg.setData(map);
|
|
- msg.setStatus(true);
|
|
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
|
+ msg.setStatus(true);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/update_agent_config")
|
|
|
|
+ public ResultMsg updateAgentConfig(HttpServletRequest request,AgentConfig config) throws Exception{
|
|
|
|
+ ResultMsg msg = new ResultMsg();
|
|
|
|
+ if (!StringUtils.isNotEmpty(config.getConfigId().toString())) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ msg.setMessage("修改代理商优惠价配置失败!");
|
|
|
|
+ }
|
|
|
|
+ //修改代理商优惠价配置信息
|
|
|
|
+ int num = agentInfoService.updateAgentConfig(config);
|
|
|
|
+ if (num > 0) {
|
|
|
|
+ msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
|
+ msg.setStatus(true);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ }
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/update_agent_config_status")
|
|
|
|
+ public ResultMsg updateAgentConfigStatus(HttpServletRequest request) throws Exception {
|
|
|
|
+ ResultMsg msg = new ResultMsg();
|
|
|
|
+ String configId = request.getParameter("configId");
|
|
|
|
+ String configStatus = request.getParameter("configStatus");
|
|
|
|
+ AgentConfig config = new AgentConfig();
|
|
|
|
+ if (!StringUtils.isNotEmpty(configId)) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ if (!StringUtils.isNotEmpty(configStatus)) {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ config.setConfigId(Integer.parseInt(configId));
|
|
|
|
+ config.setConfigStatus(Integer.parseInt(configStatus));
|
|
|
|
+ //修改代理商优惠价配置信息
|
|
|
|
+ int num = agentInfoService.updateAgentConfig(config);
|
|
|
|
+ if (num > 0) {
|
|
|
|
+ msg.setResultCode(ResultInfo.SUCCESSCODE);
|
|
|
|
+ msg.setStatus(true);
|
|
|
|
+ } else {
|
|
|
|
+ msg.setResultCode(ResultInfo.ERRORCODE);
|
|
|
|
+ msg.setStatus(false);
|
|
|
|
+ }
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|