|
|
|
@@ -34,18 +34,12 @@ import java.util.List; |
|
|
|
public class WxScreenAdServiceImpl implements WxScreenAdService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private boolean isFmOpen; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxScreenAdMapper wxScreenAdMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxAppinfoService wxAppinfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FmOpenService openService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCouponChannelMapper wxCouponChannelMapper; |
|
|
|
|
|
|
|
@@ -89,15 +83,10 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { |
|
|
|
record.setId(idWorker.nextId()); |
|
|
|
record.setCreateDate(new Date()); |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
setQrcode(record); |
|
|
|
if (record.getQrcode() == null) |
|
|
|
return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED); |
|
|
|
|
|
|
|
wxScreenAdMapper.insertSelective(record); |
|
|
|
|
|
|
|
} else { |
|
|
|
record.setUpdateDate(new Date()); |
|
|
|
setQrcode(record); |
|
|
|
wxScreenAdMapper.updateByPrimaryKeySelective(record); |
|
|
|
} |
|
|
|
return new ResultData(); |
|
|
|
@@ -142,63 +131,4 @@ public class WxScreenAdServiceImpl implements WxScreenAdService { |
|
|
|
wxScreenAdMapper.updateStatusByCouponChannelId(wxScreenAd); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setQrcode(WxScreenAd record){ |
|
|
|
if (record.getTargetId() != null && |
|
|
|
record.getType() != null && |
|
|
|
record.getTenantId() != null) |
|
|
|
try { |
|
|
|
record.setQrcode(getQrcode(record.getTargetId(), |
|
|
|
record.getType().intValue(), |
|
|
|
record.getSubType().intValue(), |
|
|
|
wxAppinfoService.getCAppInfo(record.getTenantId()))); |
|
|
|
}catch (Exception e) { |
|
|
|
logger.error("QRCODE set Error:"+e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static int QRCODE_WIDTH = 280; |
|
|
|
private static String QRCODE_PAGE_HOME = "pages/index/index"; |
|
|
|
private static boolean QRCODE_AUTO_COLOR = false; |
|
|
|
private static boolean QRCODE_IS_HYALINE = true; |
|
|
|
//private static int QRCODE_LINCOLOR =; |
|
|
|
|
|
|
|
private static String QRCODE_JUMP_CMD_HOME = "JH"; |
|
|
|
private static String QRCODE_JUMP_CMD_COUPON = "JC"; |
|
|
|
private static String QRCODE_JUMP_CMD_GROUP = "JG"; |
|
|
|
private static String QRCODE_JUMP_CMD_CAMPGIN = "JB"; |
|
|
|
|
|
|
|
private byte[] getQrcode(Long id, int type, int subType, WxAppinfo appInfo) throws Exception { |
|
|
|
if(appInfo == null) { |
|
|
|
logger.error("QRCODE get error: appinfo is null"); |
|
|
|
return null; |
|
|
|
} |
|
|
|
WxMaService wxMaService = null; |
|
|
|
if(isFmOpen) { |
|
|
|
wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appInfo.getAppId()); |
|
|
|
} else { |
|
|
|
wxMaService = MaUtil.getWeappService(appInfo); |
|
|
|
} |
|
|
|
|
|
|
|
String scene = ""; |
|
|
|
if (EnumScreenAdType.COUPON.getCode().equals(type)) { |
|
|
|
if (EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode().equals(subType)) { |
|
|
|
scene = QRCODE_JUMP_CMD_GROUP + ":" + id.toString(); |
|
|
|
} else { |
|
|
|
scene = QRCODE_JUMP_CMD_COUPON + ":" + id.toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (EnumScreenAdType.CAMPAIGN.getCode().equals(type)) |
|
|
|
scene = QRCODE_JUMP_CMD_CAMPGIN+":"+id.toString(); |
|
|
|
else |
|
|
|
scene = QRCODE_JUMP_CMD_HOME+":"+"0"; |
|
|
|
|
|
|
|
try { |
|
|
|
return wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(scene, QRCODE_PAGE_HOME, QRCODE_WIDTH, QRCODE_AUTO_COLOR, null, QRCODE_IS_HYALINE); |
|
|
|
}catch (WxErrorException e) { |
|
|
|
logger.error("QRCODE get error: " + e.getMessage()); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |