From eec7e789a87863c25d92c10ad5dfc22ad80c448d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 14 七月 2020 12:36:48 +0800
Subject: [PATCH] 系统区分BUG修复

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java |  414 ++++++++++++++++++++++++++++++----------------------------
 1 files changed, 212 insertions(+), 202 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
index 5550823..411894c 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
@@ -7,6 +7,7 @@
 
 import javax.annotation.Resource;
 
+import com.yeshi.fanli.util.SystemInfoUtil;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.yeshi.utils.JsonUtil;
@@ -46,235 +47,244 @@
 @RequestMapping("api/apph5/v1/coupon")
 public class AppH5CouponController {
 
-	@Resource
-	private QualityGoodsService qualityGoodsService;
+    @Resource
+    private QualityGoodsService qualityGoodsService;
 
-	@Resource
-	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+    @Resource
+    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
-	@Resource
-	private UserInfoService userInfoService;
+    @Resource
+    private UserInfoService userInfoService;
 
-	@Resource
-	private UserSystemCouponService userSystemCouponService;
+    @Resource
+    private UserSystemCouponService userSystemCouponService;
 
-	@Resource
-	private UserInfoExtraService userInfoExtraService;
+    @Resource
+    private UserInfoExtraService userInfoExtraService;
 
-	@Resource
-	private UserVIPInfoService userVIPInfoService;
+    @Resource
+    private UserVIPInfoService userVIPInfoService;
 
-	@Resource
-	private FreeGoodsCouponService freeGoodsCouponService;
+    @Resource
+    private FreeGoodsCouponService freeGoodsCouponService;
 
-	@Resource
-	private TearcherService tearcherService;
+    @Resource
+    private TearcherService tearcherService;
 
-	@RequestMapping("getMianDanGoodsList")
-	public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
-		List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
-		if (listQuery == null || listQuery.size() == 0) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
-			return;
-		}
+    @RequestMapping("getMianDanGoodsList")
+    public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) {
+        if (acceptData.getSystem() == null)
+            acceptData.setSystem(SystemInfoUtil.getSystem(acceptData));
 
-		List<Long> listGid = new ArrayList<Long>();
-		for (QualityFactory qualityFactory : listQuery) {
-			TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
-			if (taoBaoGoodsBrief == null) {
-				continue;
-			}
-			listGid.add(taoBaoGoodsBrief.getAuctionId());
-		}
+        List<QualityFactory> listQuery = qualityGoodsService.listFreeGoods((page - 1) * pageSize, pageSize);
+        if (listQuery == null || listQuery.size() == 0) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "娌℃湁鏇村浜�"));
+            return;
+        }
 
-		// API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
-		List<TaoBaoGoodsBrief> listTaoKeGoods = null;
-		try {
-			listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
-		} catch (TaoKeApiException e) {
-			e.printStackTrace();
-		} catch (TaobaoGoodsDownException e) {
-			e.printStackTrace();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
+        List<Long> listGid = new ArrayList<Long>();
+        for (QualityFactory qualityFactory : listQuery) {
+            TaoBaoGoodsBrief taoBaoGoodsBrief = qualityFactory.getTaoBaoGoodsBrief();
+            if (taoBaoGoodsBrief == null) {
+                continue;
+            }
+            listGid.add(taoBaoGoodsBrief.getAuctionId());
+        }
 
-		JSONArray array = new JSONArray();
-		Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
-				.excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
+        // API缃戠粶鎺ュ彛楠岃瘉鏄惁鍦ㄥ敭
+        List<TaoBaoGoodsBrief> listTaoKeGoods = null;
+        try {
+            listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
+        } catch (TaoKeApiException e) {
+            e.printStackTrace();
+        } catch (TaobaoGoodsDownException e) {
+            e.printStackTrace();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
 
-		ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
-				acceptData.getVersion(), UserLevelEnum.daRen,acceptData.getSystem());
-		/* 閬嶅巻鍒楄〃鏁版嵁 */
-		for (QualityFactory selectionGoods : listQuery) {
+        JSONArray array = new JSONArray();
+        Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
+                .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
 
-			TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
+        ConfigParamsDTO configParamsDTO = orderHongBaoMoneyComputeService.getShowComputeRate(acceptData.getPlatform(),
+                acceptData.getVersion(), UserLevelEnum.daRen, acceptData.getSystem());
+        /* 閬嶅巻鍒楄〃鏁版嵁 */
+        for (QualityFactory selectionGoods : listQuery) {
 
-			if (taoBaoGoodsBrief == null) {
-				continue;
-			}
+            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
 
-			if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
-				boolean stateSale = false; // 榛樿鍋滃敭
-				Long goodsId = taoBaoGoodsBrief.getAuctionId();
-				for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
-					Long auctionId = taoKeGoods.getAuctionId();
-					if (goodsId == auctionId || goodsId.equals(auctionId)) {
-						stateSale = true; // 鍦ㄥ敭
-						break;
-					}
-				}
+            if (taoBaoGoodsBrief == null) {
+                continue;
+            }
 
-				if (!stateSale) {
-					continue;
-				}
-			}
+            if (listTaoKeGoods != null && listTaoKeGoods.size() > 0) {
+                boolean stateSale = false; // 榛樿鍋滃敭
+                Long goodsId = taoBaoGoodsBrief.getAuctionId();
+                for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
+                    Long auctionId = taoKeGoods.getAuctionId();
+                    if (goodsId == auctionId || goodsId.equals(auctionId)) {
+                        stateSale = true; // 鍦ㄥ敭
+                        break;
+                    }
+                }
 
-			BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
-			if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
-				continue; // 鍒稿悗浠峰ぇ浜�10
-			}
-			GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO);
-			array.add(gson.toJson(detailVO));
-		}
-		JSONObject data = new JSONObject();
-		data.put("goodsList", array);
-		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-	}
+                if (!stateSale) {
+                    continue;
+                }
+            }
 
-	@RequestMapping("getMianDanInfo")
-	public void getMianDanInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
-		if (uid == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
-			return;
-		}
-		// 鑾峰彇鐢ㄦ埛淇℃伅
-		UserInfo user = userInfoService.getUserById(uid);
-		if (user == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
-			return;
-		}
-		// 鑾峰彇鍏嶅崟鍒告暟閲�
-		long couponCount = userSystemCouponService.countUsableFreeCouponForBuy(uid);
-		JSONObject userJson = new JSONObject();
-		userJson.put("nickName", user.getNickName());
-		userJson.put("portrait", user.getPortrait());
-		userJson.put("id", user.getId());
+            BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
+            if (couplePrice.compareTo(new BigDecimal("9.9")) == 1) {
+                continue; // 鍒稿悗浠峰ぇ浜�10
+            }
+            GoodsDetailVO detailVO = GoodsDetailVOFactory.convertTaoBao(taoBaoGoodsBrief, configParamsDTO);
+            array.add(gson.toJson(detailVO));
+        }
+        JSONObject data = new JSONObject();
+        data.put("goodsList", array);
+        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+    }
 
-		JSONObject data = new JSONObject();
-		data.put("user", userJson);
-		data.put("couponCount", couponCount);
-		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-	}
+    @RequestMapping("getMianDanInfo")
+    public void getMianDanInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
+        if (acceptData.getSystem() == null)
+            acceptData.setSystem(SystemInfoUtil.getSystem(acceptData));
+        if (uid == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+            return;
+        }
+        // 鑾峰彇鐢ㄦ埛淇℃伅
+        UserInfo user = userInfoService.getUserById(uid);
+        if (user == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
+            return;
+        }
+        // 鑾峰彇鍏嶅崟鍒告暟閲�
+        long couponCount = userSystemCouponService.countUsableFreeCouponForBuy(uid);
+        JSONObject userJson = new JSONObject();
+        userJson.put("nickName", user.getNickName());
+        userJson.put("portrait", user.getPortrait());
+        userJson.put("id", user.getId());
 
-	/**
-	 * 鑾峰彇杩斿埄濂栧姳鍒镐俊鎭�
-	 * 
-	 * @param acceptData
-	 * @param out
-	 * @param uid
-	 * @param callback
-	 */
-	@RequestMapping("getRewardCouponInfo")
-	public void getRewardCouponInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
-		if (uid == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
-			return;
-		}
-		// 鑾峰彇鐢ㄦ埛淇℃伅
-		UserInfo user = userInfoService.getUserById(uid);
-		if (user == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
-			return;
-		}
-		// 鑾峰彇鍏嶅崟鍒告暟閲�
-		long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
-		UserInfoExtra extraInfo = userInfoExtraService.getUserInfoExtra(uid);
-		long integralCount = extraInfo != null ? extraInfo.getGoldCoin() : 0L;
-		JSONObject userJson = new JSONObject();
-		userJson.put("nickName", user.getNickName());
-		userJson.put("portrait", user.getPortrait());
-		userJson.put("id", user.getId());
-		userJson.put("vip", userVIPInfoService.isVIP(user.getId()));
+        JSONObject data = new JSONObject();
+        data.put("user", userJson);
+        data.put("couponCount", couponCount);
+        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+    }
 
-		JSONObject data = new JSONObject();
-		data.put("user", userJson);
-		data.put("couponCount", couponCount);
-		data.put("integralCount", integralCount);
-		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-	}
+    /**
+     * 鑾峰彇杩斿埄濂栧姳鍒镐俊鎭�
+     *
+     * @param acceptData
+     * @param out
+     * @param uid
+     * @param callback
+     */
+    @RequestMapping("getRewardCouponInfo")
+    public void getRewardCouponInfo(AcceptData acceptData, PrintWriter out, Long uid, String callback) {
+        if (acceptData.getSystem() == null)
+            acceptData.setSystem(SystemInfoUtil.getSystem(acceptData));
+        if (uid == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+            return;
+        }
+        // 鑾峰彇鐢ㄦ埛淇℃伅
+        UserInfo user = userInfoService.getUserById(uid);
+        if (user == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
+            return;
+        }
+        // 鑾峰彇鍏嶅崟鍒告暟閲�
+        long couponCount = userSystemCouponService.countUsableRewardCoupon(uid);
+        UserInfoExtra extraInfo = userInfoExtraService.getUserInfoExtra(uid);
+        long integralCount = extraInfo != null ? extraInfo.getGoldCoin() : 0L;
+        JSONObject userJson = new JSONObject();
+        userJson.put("nickName", user.getNickName());
+        userJson.put("portrait", user.getPortrait());
+        userJson.put("id", user.getId());
+        userJson.put("vip", userVIPInfoService.isVIP(user.getId()));
 
-	/**
-	 * 鏂扮増鍏嶅崟鍟嗗搧鍒楄〃
-	 * 
-	 * @param acceptData
-	 * @param callback
-	 * @param page
-	 * @param goodsType
-	 * @param out
-	 */
-	@RequestMapping("getFreeGoodsList")
-	public void getFreeGoodsList(AcceptData acceptData, String callback, Long uid, int page, int goodsType,
-			PrintWriter out) {
-		if (uid == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
-			return;
-		}
+        JSONObject data = new JSONObject();
+        data.put("user", userJson);
+        data.put("couponCount", couponCount);
+        data.put("integralCount", integralCount);
+        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+    }
 
-		// 鑾峰彇鐢ㄦ埛淇℃伅
-		UserInfo user = userInfoService.getUserById(uid);
-		if (user == null) {
-			JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
-			return;
-		}
+    /**
+     * 鏂扮増鍏嶅崟鍟嗗搧鍒楄〃
+     *
+     * @param acceptData
+     * @param callback
+     * @param page
+     * @param goodsType
+     * @param out
+     */
+    @RequestMapping("getFreeGoodsList")
+    public void getFreeGoodsList(AcceptData acceptData, String callback, Long uid, int page, int goodsType,
+                                 PrintWriter out) {
+        if (acceptData.getSystem() == null)
+            acceptData.setSystem(SystemInfoUtil.getSystem(acceptData));
+        if (uid == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�"));
+            return;
+        }
 
-		String tearcherWX = null;
-		TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
-		if (tearcherInfo != null) {
-			tearcherWX = tearcherInfo.getWxID();
-		}
+        // 鑾峰彇鐢ㄦ埛淇℃伅
+        UserInfo user = userInfoService.getUserById(uid);
+        if (user == null) {
+            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"));
+            return;
+        }
 
-		// 鑾峰彇鍏嶅崟鍒告暟閲�
-		long couponNum = userSystemCouponService.countUsableFreeCouponForBuy(uid);
+        String tearcherWX = null;
+        TearcherInfo tearcherInfo = tearcherService.selectByUid(uid);
+        if (tearcherInfo != null) {
+            tearcherWX = tearcherInfo.getWxID();
+        }
 
-		JSONArray array = new JSONArray();
-		List<FreeGoodsCoupon> list = freeGoodsCouponService.listByType((page - 1) * Constant.PAGE_SIZE,
-				Constant.PAGE_SIZE, goodsType);
-		if (list != null && list.size() > 0) {
-			Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
-			for (FreeGoodsCoupon freeGoods : list) {
-				GoodsDetailVO goods = freeGoods.getGoods();
-				if (goods == null)
-					continue;
-			
-				// 瀹炰粯娆�0
-				OtherInfo otherInfo = goods.getOtherInfo();
-				if (otherInfo == null)
-					otherInfo = new OtherInfo();
-				otherInfo.setActualPay(BigDecimal.ZERO);
-				
-				// 琛ラ綈閲戦
-				if (goods.isHasCoupon()) {
-					otherInfo.setMendMoney(goods.getCouponPrice());
-				} else {
-					otherInfo.setMendMoney(goods.getZkPrice());
-				}
-				goods.setOtherInfo(otherInfo);
-				array.add(gson.toJson(goods));
-			}
-		}
+        // 鑾峰彇鍏嶅崟鍒告暟閲�
+        long couponNum = userSystemCouponService.countUsableFreeCouponForBuy(uid);
 
-		JSONObject userJson = new JSONObject();
-		userJson.put("nickName", user.getNickName());
-		userJson.put("portrait", user.getPortrait());
-		userJson.put("couponNum", couponNum);
-		userJson.put("tearcherWX", tearcherWX);
+        JSONArray array = new JSONArray();
+        List<FreeGoodsCoupon> list = freeGoodsCouponService.listByType((page - 1) * Constant.PAGE_SIZE,
+                Constant.PAGE_SIZE, goodsType);
+        if (list != null && list.size() > 0) {
+            Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder()).create();
+            for (FreeGoodsCoupon freeGoods : list) {
+                GoodsDetailVO goods = freeGoods.getGoods();
+                if (goods == null)
+                    continue;
 
-		JSONObject data = new JSONObject();
-		data.put("user", userJson);
-		data.put("count", freeGoodsCouponService.countByType(goodsType));
-		data.put("list", array);
-		JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
-	}
+                // 瀹炰粯娆�0
+                OtherInfo otherInfo = goods.getOtherInfo();
+                if (otherInfo == null)
+                    otherInfo = new OtherInfo();
+                otherInfo.setActualPay(BigDecimal.ZERO);
+
+                // 琛ラ綈閲戦
+                if (goods.isHasCoupon()) {
+                    otherInfo.setMendMoney(goods.getCouponPrice());
+                } else {
+                    otherInfo.setMendMoney(goods.getZkPrice());
+                }
+                goods.setOtherInfo(otherInfo);
+                array.add(gson.toJson(goods));
+            }
+        }
+
+        JSONObject userJson = new JSONObject();
+        userJson.put("nickName", user.getNickName());
+        userJson.put("portrait", user.getPortrait());
+        userJson.put("couponNum", couponNum);
+        userJson.put("tearcherWX", tearcherWX);
+
+        JSONObject data = new JSONObject();
+        data.put("user", userJson);
+        data.put("count", freeGoodsCouponService.countByType(goodsType));
+        data.put("list", array);
+        JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
+    }
 
 }
\ No newline at end of file

--
Gitblit v1.8.0