wangxiaoming 7 éve
szülő
commit
7ab06b8670

+ 10 - 0
tooth-common-core/src/main/java/com/iamberry/wechat/core/entity/product/Product.java

@@ -49,6 +49,8 @@ public class Product implements java.io.Serializable{
 	private Date beginDate;			//页面显示  开始时间
 	private Date endDate;				//页面显示  结束时间
 
+	private Integer configAmount;  //代理商的采购价
+
 	public Integer getColorId() {
 		return colorId;
 	}
@@ -257,6 +259,14 @@ public class Product implements java.io.Serializable{
 		this.page = page;
 	}
 
+	public Integer getConfigAmount() {
+		return configAmount;
+	}
+
+	public void setConfigAmount(Integer configAmount) {
+		this.configAmount = configAmount;
+	}
+
 	@Override
 	public String toString() {
 		return "Product [productId=" + productId + ", productName="

+ 14 - 0
tooth-wechat-interface/src/main/java/com/iamberry/wechat/face/agentInfo/AgentInfoService.java

@@ -23,4 +23,18 @@ public interface AgentInfoService {
      * @return
      */
     List<AgentTooth> listAgentTooth(AgentTooth agentTooth);
+
+    /**
+     * 查询代理商
+     * @param agentTooth
+     * @return
+     */
+    AgentTooth getAgentTooth(AgentTooth agentTooth);
+
+    /**
+     * 查询代理商配置
+     * @param config
+     * @return
+     */
+    AgentConfig getAgentConfig(AgentConfig config);
 }

+ 10 - 0
tooth-wechat-interface/src/main/java/com/iamberry/wechat/face/agentInfo/AgentOrderService.java

@@ -0,0 +1,10 @@
+package com.iamberry.wechat.face.agentInfo;
+
+/**
+ * 采购&订单
+ */
+public interface AgentOrderService {
+
+    
+
+}

+ 10 - 0
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/agentInfo/AgentInfoServiceImpl.java

@@ -27,4 +27,14 @@ public class AgentInfoServiceImpl implements AgentInfoService {
     public List<AgentTooth> listAgentTooth(AgentTooth agentTooth) {
         return agentInfoMapper.listAgentTooth(agentTooth);
     }
+
+    @Override
+    public AgentTooth getAgentTooth(AgentTooth agentTooth) {
+        return agentInfoMapper.getAgentTooth(agentTooth);
+    }
+
+    @Override
+    public AgentConfig getAgentConfig(AgentConfig config) {
+        return agentInfoMapper.getAgentConfig(config);
+    }
 }

+ 14 - 0
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/AgentInfoMapper.java

@@ -23,4 +23,18 @@ public interface AgentInfoMapper {
      * @return
      */
     List<AgentTooth> listAgentTooth(AgentTooth agentTooth);
+
+    /**
+     * 查询代理商
+     * @param agentTooth
+     * @return
+     */
+    AgentTooth getAgentTooth(AgentTooth agentTooth);
+
+    /**
+     * 查询代理商配置
+     * @param config
+     * @return
+     */
+    AgentConfig getAgentConfig(AgentConfig config);
 }

+ 33 - 0
tooth-wechat-service/src/main/java/com/iamberry/wechat/service/mapper/agentInfoMapper.xml

@@ -47,4 +47,37 @@
             LIMIT ${page.recordBegin},${page.pageSize}
         </if>
     </select>
+
+    <!-- 查询代理商配置金额 -->
+    <select id="getAgentConfig" parameterType="AgentConfig" resultType="AgentConfig">
+        select
+        <include refid="agentConfig"/>
+        from
+        tb_iamberry_agent_config
+        <where>
+            <if test="agentId !=null and agentId !=''">
+                agent_id = #{agentId}
+            </if>
+            <if test="colorId !=null and colorId !=''">
+                AND color_id = #{colorId}
+            </if>
+        </where>
+    </select>
+
+    <!-- 查询代理商配置金额 -->
+    <select id="getAgentTooth" parameterType="AgentTooth" resultType="AgentTooth">
+        SELECT
+        <include refid="agentInfo"/>
+        FROM
+        tb_iamberry_agent_agentinfo
+        <where>
+            <if test="agentOpenid !=null and agentOpenid !=''">
+                agent_openid = #{agentOpenid}
+            </if>
+            <if test="agentId !=null and agentId !=''">
+                AND  agent_id = #{agentId}
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 63 - 0
tooth-wechat-web/src/main/java/com/iamberry/wechat/handles/agentInfo/AgentOrderHandler.java

@@ -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;
+    }
+
+}