rk
6 小时以前 56fcde8c93a1a10bc50fac775e370a2db57f520e
server/dmmall_service/src/main/java/com/doumee/core/utils/Constants.java
@@ -1,15 +1,22 @@
package com.doumee.core.utils;
import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor;
import com.doumee.core.wx.WxMiniConfig;
import com.doumee.dao.business.model.Areas;
import io.swagger.annotations.ApiModelProperty;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Slf4j
public class Constants {
    public static final String[]  ALL_SPELL_LIST_FIRST = new String[]{"A", "B", "C", "D", "E", "F", "G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
@@ -77,6 +84,11 @@
    public static final String CASH_EXCHANGE_INTEGRAL_RATA = "CASH_EXCHANGE_INTEGRAL_RATA";//现金-积分兑换比例(1元可得到XXX积分)
    public static final String MAIL_CONFIG = "MAIL_CONFIG";
    public static final String FIRST_WEIGHT = "FIRST_WEIGHT";
    public static final String CONTINUE_WEIGHT = "CONTINUE_WEIGHT";
    public static final String FIRST_FEE = "FIRST_FEE";
    public static final String CONTINUE_FEE = "CONTINUE_FEE";
    public static final String INITIAL_ROLE = "INITIAL_ROLE";
@@ -132,6 +144,18 @@
    public static final String COFFEE_ARTICLE_BACKGROUND = "COFFEE_ARTICLE_BACKGROUND";
    public static final String TRANSFER_FILE = "TRANSFER_FILE";
    public static final String INVITE_RULE = "INVITE_RULE";
    public static final String INVITE_IMG = "INVITE_IMG";
    public static final String SHARES_FILE = "SHARES_FILE";
    public static final String INVITE_IMG_URL = "INVITE_IMG_URL";
    public interface RedisKeys {
@@ -873,7 +897,7 @@
        SHOP_ORDER(21,"消费返积分","会员${param}交易成功,获得${param1}积分",0,0),//${param}昵称-手机号
        SHOP_ORDER_CANCEL(22,"退单扣除","交易退款退回,消耗100积分",0,0),
        SHOP_ORDER_CANCEL(22,"订单取消退回","订单取消退回,退回${param}积分",0,0),
        SHOP_SYSTEM_RECHARGE(23,"积分发放","平台奖励,获得${param}积分",0,0),
        SHOP_SYSTEM_DEDUCT(24,"积分扣除","平台扣减,消耗${param}积分",0,0),
@@ -1176,6 +1200,7 @@
    public  enum UserActionType {
        CHANGE_SHOP(0, "经销商更换","由【${param1}】于【${param2}】,进行【经销商更换】" ),
        CHANGE_SALETYPE(1, "经销商更换销售模式","由【${param1}】于【${param2}】,进行【销售模式变更】" ),
        ;
        // 成员变量
@@ -1222,4 +1247,52 @@
            this.info = info;
        }
    }
    public static InputStream generateWxMiniImgStream(String scene, String page, boolean isUsePage) {
        //生成图片上传OSS
        Map<String,Object> body = new HashMap<>();
        // 场景码,与前端约定,最终是需要前端解析
        body.put("scene", scene);
        // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
        String env_version = "release";
        body.put("env_version", env_version);
        if(isUsePage){
            body.put("page", page);
        }
        //body.put("page", "pages/index/index");
        // 透明,根据你的场景自行设置body参数
        body.put("is_hyaline", true);
        try {
            WxMaCodeLineColor codeLineColor = new WxMaCodeLineColor("0","0","0");
            byte[]  bytes =  WxMiniConfig.wxMaService.getQrcodeService().createWxaCodeUnlimitBytes
                    (scene,null,false,env_version,300,false,codeLineColor,false);
            if (bytes !=null) {
                InputStream inputStream = new ByteArrayInputStream(bytes);
              /* ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    byte[] buffer = new byte[1024];
                    int len = -1;
                    while ((len = inputStream.read(buffer)) != -1) {
                        baos.write(buffer, 0, len);
                    }
                 System.out.println("data:mediatype;base64," + Base64.getEncoder().encodeToString(baos.toByteArray()));*/
                log.error("生成小程序码成功:============"+inputStream.available());
                return inputStream;
            }else{
                log.error("生成小程序码失败:============");
            }
        } catch (Exception e) {
            e.printStackTrace();
            log.error("生成小程序码失败:============"+e.getMessage());
        }
        return  null;
    }
    public static Integer getInviteCode(String inviteStr){
        if(StringUtils.isNotBlank(inviteStr)&&inviteStr.startsWith("m_")){
            return Integer.valueOf(inviteStr.replace("m_",""));
        }
        return null;
    }
}