|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.aliyun.oss.OSS;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fuint.common.bean.H5SceneInfo;
|
|
|
import com.fuint.common.bean.WxPayBean;
|
|
|
import com.fuint.common.dto.OrderDto;
|
|
@@ -38,7 +39,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import weixin.popular.util.JsonUtil;
|
|
|
-
|
|
|
import javax.crypto.Cipher;
|
|
|
import javax.crypto.spec.IvParameterSpec;
|
|
|
import javax.crypto.spec.SecretKeySpec;
|
|
@@ -112,8 +112,8 @@ public class WeixinServiceImpl implements WeixinService {
|
|
|
* */
|
|
|
@Override
|
|
|
public String getAccessToken(Integer merchantId, boolean useCache) throws BusinessCheckException {
|
|
|
- String wxAppId = env.getProperty("wxpay.appId");
|
|
|
- String wxAppSecret = env.getProperty("wxpay.appSecret");
|
|
|
+ String wxAppId = env.getProperty("weixin.official.appId");
|
|
|
+ String wxAppSecret = env.getProperty("weixin.official.appSecret");
|
|
|
String tokenKey = FUINT_ACCESS_TOKEN_PRE;
|
|
|
if (merchantId != null && merchantId > 0) {
|
|
|
MtMerchant mtMerchant = merchantService.queryMerchantById(merchantId);
|
|
@@ -521,7 +521,7 @@ public class WeixinServiceImpl implements WeixinService {
|
|
|
logger.info("WeixinService sendSubscribeMessage response={}", response);
|
|
|
JSONObject json = (JSONObject) JSONObject.parse(response);
|
|
|
if (json.get("errcode").toString().equals("40001")) {
|
|
|
- getAccessToken(merchantId, false);
|
|
|
+ getAccessToken(merchantId, true);
|
|
|
logger.error("发送订阅消息出错error1:" + json.get("errcode").toString());
|
|
|
return false;
|
|
|
} else if (!json.get("errcode").toString().equals("0")) {
|
|
@@ -681,20 +681,64 @@ public class WeixinServiceImpl implements WeixinService {
|
|
|
* 开通微信卡券
|
|
|
*
|
|
|
* @param merchantId 商户ID
|
|
|
- * @param storeId 店铺ID
|
|
|
* @return
|
|
|
* */
|
|
|
@Override
|
|
|
- public String createWxCard(Integer merchantId, Integer storeId) {
|
|
|
+ public String createWxCard(Integer merchantId) {
|
|
|
String cardId = "";
|
|
|
try {
|
|
|
String accessToken = getAccessToken(merchantId, true);
|
|
|
- String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken;
|
|
|
- String reqDataJson = "";
|
|
|
+ String url = "https://api.weixin.qq.com/card/create?access_token=" + accessToken;
|
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
- params.put("access_token", accessToken);
|
|
|
- reqDataJson = JsonUtil.toJSONString(params);
|
|
|
+ Map<String, Object> card = new HashMap<>();
|
|
|
+ card.put("card_type", "MEMBER_CARD");
|
|
|
+ Map<String, Object> memberCard = new HashMap<>();
|
|
|
+ memberCard.put("background_pic_url", null);
|
|
|
+
|
|
|
+ // baseInfo
|
|
|
+ Map<String, Object> baseInfo = new HashMap<>();
|
|
|
+ baseInfo.put("logo_url", "");
|
|
|
+ baseInfo.put("brand_name", "小隅安");
|
|
|
+ baseInfo.put("code_type", "CODE_TYPE_TEXT");
|
|
|
+ baseInfo.put("title", "小隅安会员卡");
|
|
|
+ baseInfo.put("color", "Color010");
|
|
|
+ baseInfo.put("notice", "使用时向服务员出示此券");
|
|
|
+ baseInfo.put("service_phone", "0898-88888888");
|
|
|
+ baseInfo.put("description", "不可与其他优惠同享");
|
|
|
+ Map<String, Object> dateInfo = new HashMap<>();
|
|
|
+ dateInfo.put("type", "DATE_TYPE_PERMANENT");
|
|
|
+ baseInfo.put("date_info", dateInfo);
|
|
|
+ Map<String, Object> sku = new HashMap<>();
|
|
|
+ sku.put("quantity", 50000000);
|
|
|
+ baseInfo.put("sku", sku);
|
|
|
+ baseInfo.put("get_limit", 3);
|
|
|
+ baseInfo.put("use_custom_code", false);
|
|
|
+ baseInfo.put("bind_openid", false);
|
|
|
+ baseInfo.put("can_give_friend", false);
|
|
|
+ baseInfo.put("location_id_list", null);
|
|
|
+ baseInfo.put("custom_url_name", "立即使用");
|
|
|
+ baseInfo.put("custom_url", "https://www.fuint.cn/h5/");
|
|
|
+ baseInfo.put("custom_url_sub_title", "6个汉字tips");
|
|
|
+ baseInfo.put("promotion_url_name", "营销入口");
|
|
|
+ baseInfo.put("promotion_url", "https://www.fuint.cn/h5/");
|
|
|
+ baseInfo.put("need_push_on_view", true);
|
|
|
+ memberCard.put("base_info", baseInfo);
|
|
|
+
|
|
|
+ // 特权说明
|
|
|
+ memberCard.put("prerogative", "会员卡特权说明,限制1024汉字。");
|
|
|
+ // 自动激活
|
|
|
+ memberCard.put("auto_activate", true);
|
|
|
+ memberCard.put("supply_bonus", true);
|
|
|
+ memberCard.put("bonus_url", "https://www.fuint.cn/h5/");
|
|
|
+ memberCard.put("supply_balance", false);
|
|
|
+ memberCard.put("balance_url", "https://www.fuint.cn/h5/");
|
|
|
+
|
|
|
+ card.put("member_card", memberCard);
|
|
|
+ params.put("card", card);
|
|
|
+
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ String reqDataJson = mapper.writeValueAsString(params);
|
|
|
|
|
|
String response = HttpRESTDataClient.requestPost(url, "application/json; charset=utf-8", reqDataJson);
|
|
|
logger.error("开通微信卡券接口返回:{}", response);
|