|
@@ -0,0 +1,63 @@
|
|
|
|
+package com.iamberry.wechat.handles.agentInfo;
|
|
|
|
+
|
|
|
|
+import com.iamberry.wechat.core.entity.ResultMsg;
|
|
|
|
+import com.iamberry.wechat.core.entity.agentInfo.AgentConfig;
|
|
|
|
+import com.iamberry.wechat.core.entity.agentInfo.AgentTooth;
|
|
|
|
+import com.iamberry.wechat.core.entity.product.Product;
|
|
|
|
+import com.iamberry.wechat.face.agentInfo.AgentInfoService;
|
|
|
|
+import com.iamberry.wechat.face.cart.ProductInfoService;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 采购&订单
|
|
|
|
+ */
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping("/wechat/agentOrder")
|
|
|
|
+public class AgentOrderHandler {
|
|
|
|
+ @Autowired
|
|
|
|
+ private AgentInfoService agentInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ProductInfoService productInfoService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取采购信息
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping("/getProduce")
|
|
|
|
+ public ResultMsg getProduce(HttpServletRequest request){
|
|
|
|
+ ResultMsg rm = new ResultMsg();
|
|
|
|
+ //Member member = WechatUtils.getUserBySession(request);
|
|
|
|
+ //String agentOpenid = member.getUserOpenid();
|
|
|
|
+
|
|
|
|
+ String agentOpenid = "o-icasz5a10CfmJ_s-hvW-Ltqwtc";
|
|
|
|
+
|
|
|
|
+ AgentTooth agentTooth = new AgentTooth();
|
|
|
|
+ agentTooth.setAgentOpenid(agentOpenid);
|
|
|
|
+ agentTooth = agentInfoService.getAgentTooth(agentTooth);
|
|
|
|
+
|
|
|
|
+ Product product = new Product();
|
|
|
|
+ List<Product> productList = productInfoService.listSelectProduct(product);
|
|
|
|
+
|
|
|
|
+ for (Product pd : productList){
|
|
|
|
+ AgentConfig agentConfig = new AgentConfig();
|
|
|
|
+ agentConfig.setColorId(pd.getColorId());
|
|
|
|
+ agentConfig.setAgentId(agentTooth.getAgentId());
|
|
|
|
+ agentConfig = agentInfoService.getAgentConfig(agentConfig);
|
|
|
|
+ if(agentConfig != null && agentConfig.getConfigAmount() != null && agentConfig.getConfigAmount()!=0){
|
|
|
|
+ pd.setConfigAmount(agentConfig.getConfigAmount());
|
|
|
|
+ }else{
|
|
|
|
+ pd.setConfigAmount(pd.getProductDiscount());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ rm.setData(productList);
|
|
|
|
+ return rm;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|