|
@@ -21,6 +21,8 @@ import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.common.utils.ip.IpUtils;
|
|
|
import com.zhongzheng.modules.alisms.service.IAliSmsService;
|
|
|
import com.zhongzheng.modules.course.bo.SectionWatchPerBo;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
+import com.zhongzheng.modules.goods.vo.GoodsVo;
|
|
|
import com.zhongzheng.modules.user.bo.UserWxFollowAddBo;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
@@ -29,6 +31,7 @@ import com.zhongzheng.modules.user.service.IUserService;
|
|
|
import com.zhongzheng.modules.user.service.IUserWxFollowService;
|
|
|
import com.zhongzheng.modules.wx.bo.TemplatData;
|
|
|
import com.zhongzheng.modules.wx.bo.WxLoginBody;
|
|
|
+import com.zhongzheng.modules.wx.bo.WxShareGoodsBo;
|
|
|
import com.zhongzheng.modules.wx.service.IWxLoginService;
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
import org.slf4j.Logger;
|
|
@@ -140,6 +143,9 @@ public class WxLoginService implements IWxLoginService {
|
|
|
@Autowired
|
|
|
private IUserWxFollowService iUserWxFollowService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
+
|
|
|
|
|
|
public Map<String, String> test_login() {
|
|
|
String unionId = "oQ2yp56PgQ-PfwN4vxTZhR5eTpzk";
|
|
@@ -928,6 +934,51 @@ public class WxLoginService implements IWxLoginService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String shareGoodsCode(WxShareGoodsBo bo) {
|
|
|
+ GoodsVo goodsVo = iGoodsService.queryById(bo.getGoodsId());
|
|
|
+ if(Validator.isEmpty(goodsVo)){
|
|
|
+ throw new CustomException("商品ID错误");
|
|
|
+ }
|
|
|
+ StringBuilder sceneParam = new StringBuilder();
|
|
|
+ String pageUrl = "";
|
|
|
+
|
|
|
+ String wxGzhAccessToken = getWxSmallAccessToken();
|
|
|
+ String param = String.format(small_wxEnCodeParam, wxGzhAccessToken);
|
|
|
+ String url = small_wxEnCodeUrl + "?" + param;
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+
|
|
|
+ if(goodsVo.getGoodsType()==2){
|
|
|
+ pageUrl = "pages2/bank/detail";
|
|
|
+ sceneParam.append("id=").append(goodsVo.getGoodsId()).append("&");
|
|
|
+ sceneParam.append("sc=").append(bo.getShareCode());
|
|
|
+ }
|
|
|
+ if(goodsVo.getGoodsType()==1||goodsVo.getGoodsType()==6){
|
|
|
+ pageUrl = "pages3/course/detail";
|
|
|
+ sceneParam.append("id=").append(goodsVo.getGoodsId()).append("&");
|
|
|
+ sceneParam.append("goodsType=").append(goodsVo.getGoodsType()).append("&");
|
|
|
+ sceneParam.append("sc=").append(bo.getShareCode());
|
|
|
+ }
|
|
|
+ System.out.println(pageUrl);
|
|
|
+ System.out.println(sceneParam.toString());
|
|
|
+ obj.put("page", pageUrl);
|
|
|
+ obj.put("scene",sceneParam.toString());
|
|
|
+ obj.put("env_version",enCodeVersion);
|
|
|
+ String result = HttpUtils.sendPost(url, obj);
|
|
|
+ List<String> codes = Arrays.asList("40001", "42001");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
+ if(ObjectUtils.isNotNull(jsonObject.get("errcode")) && codes.contains(jsonObject.get("errcode").toString())){
|
|
|
+ //微信access_token 过期或者失效,刷新access_token
|
|
|
+ String key = "WX_SMALL_ACCESS_TOKEN";
|
|
|
+ redisCache.deleteObject(key);
|
|
|
+ String wxGzhAccessTokenTo = getWxSmallAccessToken();
|
|
|
+ String paramTo = String.format(small_wxEnCodeParam, wxGzhAccessTokenTo);
|
|
|
+ String urlTo = small_wxEnCodeUrl + "?" + paramTo;
|
|
|
+ return HttpUtils.sendPost(urlTo, obj);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public Boolean subGzh(String openId) {
|
|
|
String unionId = getWxGzhUserCgiInfo(openId);
|
|
|
if (Validator.isNotEmpty(unionId)) {
|