| @@ -18,10 +18,10 @@ import com.iformall.service.sm.InviteCodeInfoService; | |||
| import com.iformall.service.sm.InviteCodeService; | |||
| import com.iformall.service.sm.UserConsumptionPackageService; | |||
| import com.iformall.service.sm.UserCreateVideoNumService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| import com.iformall.utils.PasswordHelper; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.iformall.sm.AiDigitalAvatarHelper; | |||
| import com.iformall.sm.ShareImgParam; | |||
| import com.iformall.sm.ShareImgResult; | |||
| import com.iformall.utils.*; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -64,6 +64,9 @@ public class MiniAppUserController extends BaseController { | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @Autowired | |||
| private UserBasicQrcodeService userBasicQrcodeService; | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @@ -235,4 +238,49 @@ public class MiniAppUserController extends BaseController { | |||
| return new ResultData(resultMap); | |||
| } | |||
| /** | |||
| * 获取二维码 | |||
| * | |||
| * @param map | |||
| * @return | |||
| */ | |||
| @PostMapping("/getUserQrcode") | |||
| @ApiOperation(value = "获取二维码", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||
| public ResultData getUserQrcode(@RequestBody Map<String, String> map) { | |||
| logger.info(map.toString()); | |||
| String appId = map.get("appId"); | |||
| String img = map.get("img"); | |||
| if(StringUtils.isBlank(appId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| try { | |||
| //获取用户二维码 | |||
| String qrCode = userBasicQrcodeService.getQrCode(getMemberId(), wxAppinfo.getProjectType(), wxAppinfo.getPlat()); | |||
| ShareImgParam param = new ShareImgParam(); | |||
| String imgBasic = Base64Util.imageUrlToBase64(img); | |||
| param.setImg(imgBasic); | |||
| String qrcodeBasic = Base64Util.imageUrlToBase64(qrCode); | |||
| param.setWatermark_img(qrcodeBasic); | |||
| ShareImgResult shareImg = AiDigitalAvatarHelper.createShareImg(param); | |||
| if(shareImg.isSuccess()){ | |||
| return new ResultData(shareImg.getImg()); | |||
| }else{ | |||
| return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED.getCode(),shareImg.getMsg()); | |||
| } | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| }catch (Exception e) { | |||
| this.logger.error(e.getMessage(), e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "user_basic_qrcode") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class UserBasicQrcode extends TenantEntity { | |||
| protected Long id; | |||
| private Long userId; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumProject",name="projectType") | |||
| private Integer projectType; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="plat") | |||
| private Integer plat; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="qrcode") | |||
| private String qrcode; | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.UserBasicQrcode; | |||
| import java.util.List; | |||
| public interface UserBasicQrcodeMapper extends CommonMapper<UserBasicQrcode, Long>{ | |||
| List<UserBasicQrcode> findList(UserBasicQrcode record); | |||
| } | |||
| @@ -5,6 +5,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.enums.EnumProject; | |||
| import com.iformall.exception.MallinkException; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| @@ -25,4 +26,16 @@ public interface QrCodeService { | |||
| int withText, String text1, String text2, | |||
| String name,EnumAppPlat plat); | |||
| /** | |||
| * 生成无限二维码 | |||
| * @param project | |||
| * @param plat | |||
| * @param pageUrl | |||
| * @param sceneParam | |||
| * @param name | |||
| * @param plat | |||
| * @return | |||
| */ | |||
| ResultData uploadQrcode(EnumProject project,EnumAppPlat plat,String pageUrl, String sceneParam,String name); | |||
| } | |||
| @@ -0,0 +1,7 @@ | |||
| package com.iformall.service; | |||
| public interface UserBasicQrcodeService { | |||
| String getQrCode(Long userId,Integer projectType,Integer plat); | |||
| } | |||
| @@ -9,6 +9,7 @@ import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumPayVersion; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.enums.EnumProject; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.file.aliyun.AliyunOSS; | |||
| import com.iformall.service.QrCodeService; | |||
| @@ -190,6 +191,31 @@ public class QrCodeServiceImpl implements QrCodeService { | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public ResultData uploadQrcode(EnumProject project, EnumAppPlat plat, String pageUrl, String sceneParam, String name) { | |||
| WxAppinfo appinfo = wxAppinfoService.getProjectCAppInfoFromRedis(project.getCode(),plat.getCode()); | |||
| if(appinfo == null){ | |||
| logger.error("生成二维码{}未找到对应的小程序"); | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND.getCode(),"未找到程序应用"); | |||
| } | |||
| try { | |||
| File codeFile = payServiceFactory.getQrcodeService(appinfo.getPlat()).getQrcode(appinfo, pageUrl, 1, sceneParam); | |||
| //上传 | |||
| ResultData data = aliyunOSS.uploadFile(null, ".png", new FileInputStream(codeFile)); | |||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||
| return data; | |||
| } catch (WxErrorException e) { | |||
| logger.error("获取二维码 error1" + e.getMessage()); | |||
| return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED.getCode(),e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("获取二维码 error2" + e); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| private void copyFileToDest(int withText, String text1, String text2, String destPath1, File dest, File codeFile) throws IOException { | |||
| if (withText == 1) { | |||
| File dest1 = new File(destPath1); | |||
| @@ -0,0 +1,68 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.UserBasicQrcode; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumProject; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.UserBasicQrcodeMapper; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.UserBasicQrcodeService; | |||
| import com.iformall.utils.Constant; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.Map; | |||
| @Service | |||
| @Slf4j | |||
| public class UserBasicQrcodeServiceImpl implements UserBasicQrcodeService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| UserBasicQrcodeMapper userBasicQrcodeMapper; | |||
| @Autowired | |||
| protected QrCodeService qrCodeService; | |||
| @Override | |||
| public String getQrCode(Long userId, Integer projectType, Integer platType) { | |||
| UserBasicQrcode qrcode = new UserBasicQrcode(); | |||
| qrcode.setUserId(userId); | |||
| qrcode.setProjectType(projectType); | |||
| qrcode.setPlat(platType); | |||
| UserBasicQrcode userBasicQrcode = userBasicQrcodeMapper.selectOne(new QueryWrapper<>(qrcode)); | |||
| if(userBasicQrcode != null){ | |||
| return userBasicQrcode.getQrcode(); | |||
| } | |||
| EnumProject project = EnumProject.getEnum(projectType); | |||
| EnumAppPlat plat = EnumAppPlat.getByCode(platType); | |||
| String pageUrl = Constant.sharePageUrl; | |||
| String param = "t:in_u:"+userId; | |||
| String name = project.getCode() + "-" + plat.getCode() + "-" + userId.toString(); | |||
| ResultData resultData = qrCodeService.uploadQrcode(project, plat, pageUrl, param, name); | |||
| if(ResultData.SUCCESS == resultData.code){ | |||
| Map<String, String> map = (Map) resultData.data; | |||
| String pathUrl = map.get("url"); | |||
| if(StringUtils.isBlank(pathUrl)){ | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| qrcode.setId(idWorker.nextId()); | |||
| qrcode.setQrcode(pathUrl); | |||
| userBasicQrcodeMapper.insert(qrcode); | |||
| return pathUrl; | |||
| }else{ | |||
| throw new MallinkException(resultData.code ,resultData.message); | |||
| } | |||
| } | |||
| } | |||
| @@ -49,6 +49,7 @@ public class PayServiceFactory { | |||
| private Map<String,PayAdapterService> payVendorServiceMap = null; | |||
| private Map<String,PayShareAdapterService> payVendorShareMap = null; | |||
| private Map<String,PayAdapterService> platQrcodeMap = null; | |||
| @Autowired | |||
| WxMiniAppPayAdapterService wxMiniAppPayService; | |||
| @@ -123,6 +124,15 @@ public class PayServiceFactory { | |||
| return qrcodeMap; | |||
| } | |||
| private Map<String,PayAdapterService> getPlatQrcodeMap() { | |||
| if (null == platQrcodeMap) { | |||
| platQrcodeMap = new ConcurrentHashMap<String,PayAdapterService>(); | |||
| platQrcodeMap.put(EnumAppPlat.WX.getCode()+"_", wxMiniAppPayV3AdapterService); | |||
| platQrcodeMap.put(EnumAppPlat.TOUTIAO.getCode()+"_",ttMiniAppPayService); | |||
| } | |||
| return platQrcodeMap; | |||
| } | |||
| private Map<String,PayAdapterService> getPayVendorServiceMap() { | |||
| if (null == payVendorServiceMap) { | |||
| payVendorServiceMap = new ConcurrentHashMap<String,PayAdapterService>(); | |||
| @@ -245,6 +255,14 @@ public class PayServiceFactory { | |||
| } | |||
| return service; | |||
| } | |||
| public PayAdapterService getQrcodeService(Integer type) throws MallinkException{ | |||
| PayAdapterService service = getPlatQrcodeMap().get(type+"_"); | |||
| if (null == service) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"payWay["+type+"] 二维码service未找到"); | |||
| } | |||
| return service; | |||
| } | |||
| public CDrivingPayService getCDrivingPayService(Integer type,Integer payVersion) throws MallinkException{ | |||
| PayAdapterService service = getServiceMap().get(type+"_"+payVersion); | |||
| @@ -240,6 +240,8 @@ public class UserDigitalAvatarOrderServiceImpl implements UserDigitalAvatarOrder | |||
| try{ | |||
| DigitalAvatarParam param = new DigitalAvatarParam(); | |||
| param.setBg_img(record.getDigitalAvatarSm()); | |||
| param.setNum_people(record.getDigitalAvatarType()); | |||
| if(EnumDigitalAvatarMouldType.persion_1.getCode().equals(record.getDigitalAvatarType())){ | |||
| String imgUrl1 = record.getUserImageList().get(0); | |||
| param.setImg_lift(Base64Util.imageUrlToBase64(imgUrl1)); | |||
| @@ -96,7 +96,6 @@ public class AiDigitalAvatarHelper { | |||
| result.setMsg("success"); | |||
| JSONObject data = jsonObject.getJSONObject("data"); | |||
| log.info("11111111111111"); | |||
| List<String> imgList = new ArrayList<>(); | |||
| imgList.add(data.getString("img_0")); | |||
| imgList.add(data.getString("img_1")); | |||
| @@ -11,6 +11,7 @@ import java.util.Map; | |||
| public class DigitalAvatarParam { | |||
| private String bg_img; | |||
| private Integer num_people; | |||
| private String img_lift; | |||
| private String img_middle; | |||
| private String img_right; | |||
| @@ -28,6 +28,8 @@ public class Constant { | |||
| public static final String indexPageUrl = "pages/index/index"; | |||
| public static final String sharePageUrl = "pages/login/index"; | |||
| // 1小时过期, | |||
| public final static int H_EXPIRE = 3600; | |||
| @@ -0,0 +1,47 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.UserBasicQrcodeMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.UserBasicQrcode"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="user_id" jdbcType="BIGINT" property="userId" /> | |||
| <result column="project_type" jdbcType="INTEGER" property="projecType" /> | |||
| <result column="plat" jdbcType="INTEGER" property="plat" /> | |||
| <result column="qrcode" jdbcType="VARCHAR" property="qrcode" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`, | |||
| `user_id`,`project_type`,`plat`,`qrcode` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> and `id` = #{id} </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != userId "> and `user_id` = #{userId} </if> | |||
| <if test=" null != projectType "> and `project_type` = #{projectType} </if> | |||
| <if test=" null != plat "> and `plat` = #{plat} </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.UserBasicQrcode" resultMap="BaseResultMap"> | |||
| select <include refid="allColumns" /> | |||
| from user_basic_qrcode | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||