| @@ -46,6 +46,15 @@ public class WxOpinionController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/getById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "问券调查--查询") | |||
| public ResultData getById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::getById"); | |||
| return new ResultData(wxOpinionService.getById(id)); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @@ -0,0 +1,41 @@ | |||
| package com.iformall.controller.rent; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.WxGooagooService; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Map; | |||
| /** | |||
| * | |||
| */ | |||
| @RestController | |||
| @RequestMapping("gooagoo") | |||
| public class WxGooagooController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxGooagooService wxGooagooService; | |||
| @ApiOperation("调取接口数据") | |||
| @PostMapping("/queryData") | |||
| @SystemControllerLog(description = "数据塔台-查询客流") | |||
| public ResultData queryData(@RequestBody Map<String,Object> params) { | |||
| logger.debug("[" + getIpAddr() + "] WxGooagooController::queryData"); | |||
| Object lowerMethod = params.get("lowerMethod"); | |||
| if(lowerMethod == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"lowerMethod不能为空"); | |||
| } | |||
| String requrl = lowerMethod.toString(); | |||
| params.remove("lowerMethod"); | |||
| return wxGooagooService.queryDataUrl(getTenantInfo(),requrl,params); | |||
| } | |||
| } | |||
| @@ -0,0 +1,20 @@ | |||
| CREATE TABLE `wx_third_party_config` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `type` tinyint(6) NOT NULL COMMENT '第三方类型,', | |||
| `app_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `app_key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `sign_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '加密key,', | |||
| `api_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `token` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, | |||
| `token_expired_time` datetime(0) DEFAULT NULL COMMENT 'token过期时间', | |||
| `user_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '登陆账号', | |||
| `password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '登陆密码', | |||
| `version` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '接口版本', | |||
| PRIMARY KEY (`id`) USING BTREE | |||
| ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; | |||
| ALTER TABLE `mallink`.`wx_third_party_config` | |||
| ADD COLUMN `tp_id` varchar(100) AFTER `version`; | |||
| @@ -41,6 +41,7 @@ public class WxOpinionController extends BaseController { | |||
| record = new WxOpinion(); | |||
| } | |||
| record.updateTenantInfo(getTenantInfo()); | |||
| record.setUserId(getMemberId()); | |||
| record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| final PageInfo<WxOpinion> page = wxOpinionService.listAsPage(record, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| @@ -74,4 +75,12 @@ public class WxOpinionController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/getById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData getById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxOpinionController::getById"); | |||
| return new ResultData(wxOpinionService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,175 +0,0 @@ | |||
| package com.iformall.utils; | |||
| import net.sourceforge.pinyin4j.PinyinHelper; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; | |||
| import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.util.ResourceUtils; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.*; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.ByteArrayInputStream; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.File; | |||
| import java.io.InputStream; | |||
| import java.time.LocalDateTime; | |||
| import java.time.format.DateTimeFormatter; | |||
| import java.util.Locale; | |||
| public class ImgIdeaUtil { | |||
| private static final Logger logger = LoggerFactory.getLogger(ImgIdeaUtil.class); | |||
| //模板图片 | |||
| private static final String imgTempPath = "imgTemp/gertificate.jpg"; | |||
| //字体路径 | |||
| private static final String fontPath = "opt/HWLS.TTF"; | |||
| /** | |||
| * 生成图片证书 | |||
| * @return | |||
| */ | |||
| public static byte[] imgGertificate(String name, String englishName, LocalDateTime date){ | |||
| if(StringUtils.isBlank(name)){ | |||
| logger.error("名字为空,无法生成证书"); | |||
| return null; | |||
| } | |||
| if(name.length() == 2){ | |||
| name = name.replaceAll("(\\S)", "$0 "); | |||
| } | |||
| if(StringUtils.isBlank(englishName)){ | |||
| englishName = getUpEname(name); | |||
| } | |||
| if(date == null){ | |||
| date = LocalDateTime.now(); | |||
| } | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dMMM yyyy", Locale.UK); | |||
| String dateFormat = date.format(formatter); | |||
| try { | |||
| InputStream backImgUrl = ClassLoader.getSystemResourceAsStream(imgTempPath); | |||
| //InputStream backImgUrl = ImgIdeaUtil.class.getClassLoader().getResourceAsStream(imgTempPath); | |||
| Font font = Font.createFont(Font.TRUETYPE_FONT, ResourceUtils.getFile("classpath:"+fontPath)); | |||
| BufferedImage backImg = ImageIO.read(backImgUrl); | |||
| Graphics g = backImg.getGraphics(); | |||
| //图片加中文名 | |||
| Font fTxtBottomName = font.deriveFont(Font.PLAIN, 170); | |||
| //Font fTxtBottomName = new Font("华文隶书", Font.PLAIN, 170); | |||
| FontMetrics metricsName = g.getFontMetrics(fTxtBottomName); | |||
| int xName = (backImg.getWidth() - metricsName.stringWidth(name)) / 2; | |||
| Color myColorTxtBottomName = Color.BLACK; //颜色 | |||
| g.setColor(myColorTxtBottomName); | |||
| g.setFont(fTxtBottomName); | |||
| g.drawString(name, xName , 1150);//g.drawString(文字, x 位置, y 位置); | |||
| //图片加英文名 | |||
| Font fTxtBottomEname = font.deriveFont(Font.PLAIN, 120); | |||
| //Font fTxtBottomEname = new Font("华文隶书", Font.PLAIN, 120); | |||
| FontMetrics metricsEname = g.getFontMetrics(fTxtBottomEname); | |||
| int xEname = (backImg.getWidth() - metricsEname.stringWidth(englishName)) / 2; | |||
| Color myColorTxtBottomEname = Color.BLACK; | |||
| g.setColor(myColorTxtBottomEname); | |||
| g.setFont(fTxtBottomEname); | |||
| g.drawString(englishName, xEname, 1300); | |||
| //图片加日期 | |||
| Font fTxtBottomDate = font.deriveFont(Font.PLAIN, 90); | |||
| //Font fTxtBottomDate = new Font("华文隶书", Font.PLAIN, 90); | |||
| Color myColorTxtBottomDate = Color.BLACK; | |||
| g.setColor(myColorTxtBottomDate); | |||
| g.setFont(fTxtBottomDate); | |||
| g.drawString(dateFormat, 440, 2100); | |||
| //调这个方法就是开始这个整合 (可以多张图片,多个文字整合成一张图片,只有把他们放在这方法里面就行) | |||
| g.dispose(); | |||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
| ImageIO.write(backImg, "png", out); | |||
| return out.toByteArray(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| logger.error("生成证书异常", e.getMessage()); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| * //姓、名的第一个字母需要为大写 | |||
| * @param name | |||
| * @return | |||
| */ | |||
| public static String getUpEname(String name) { | |||
| char[] strs = name.toCharArray(); | |||
| String newname = null; | |||
| if (strs.length == 2) { | |||
| newname = toUpCase(getEname("" + strs[0])) + " " + toUpCase(getEname("" + strs[1])); | |||
| } else if (strs.length == 3){ | |||
| newname = toUpCase(getEname("" + strs[0])) + " " | |||
| + toUpCase(getEname("" + strs[1] + strs[2])); | |||
| }else if (strs.length == 4){ | |||
| newname = toUpCase(getEname("" + strs[0] + strs[1])) + " " | |||
| + toUpCase(getEname("" + strs[2] + strs[3])); | |||
| } else{ | |||
| newname = toUpCase(getEname(name)); | |||
| } | |||
| return newname; | |||
| } | |||
| /** | |||
| * //将中文转换为英文 | |||
| * @param name | |||
| * @return | |||
| */ | |||
| public static String getEname(String name){ | |||
| HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat(); | |||
| pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); | |||
| pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | |||
| pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V); | |||
| String s = ""; | |||
| try { | |||
| s = PinyinHelper.toHanyuPinyinString(name, pyFormat, ""); | |||
| } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { | |||
| badHanyuPinyinOutputFormatCombination.printStackTrace(); | |||
| } | |||
| return s; | |||
| } | |||
| /** | |||
| * 首字母大写 | |||
| * @param str | |||
| * @return | |||
| */ | |||
| private static String toUpCase(String str) { | |||
| StringBuffer newstr = new StringBuffer(); | |||
| newstr.append((str.substring(0, 1)).toUpperCase()).append( | |||
| str.substring(1, str.length())); | |||
| return newstr.toString(); | |||
| } | |||
| // public static void main(String[] args) { | |||
| // String serverUploadImgUrl = "C:/Users/xiaohu/Desktop/img"; // 图片保存路径 | |||
| // try { | |||
| // byte[] bytes = imgGertificate("郑方元", null, null); | |||
| // ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | |||
| // BufferedImage bi1 =ImageIO.read(bais); | |||
| // | |||
| // ImageIO.write(bi1, "png", new File(serverUploadImgUrl+"/0.png")); | |||
| // | |||
| // } catch (Exception e) { | |||
| // e.printStackTrace(); | |||
| // } | |||
| // System.out.println("结束"); | |||
| // } | |||
| } | |||
| @@ -597,6 +597,14 @@ public enum ErrorCode{ | |||
| QUESTION_USER_NOT(61006, "答题参数错误!"), | |||
| QUESTION_USER_LINE(61007, "已经参与!"), | |||
| QUESTION_NOT_START(61008, "问卷未开始"), | |||
| QUESTION_END(61009, "问卷已结束"), | |||
| /** | |||
| * 数衍信息 | |||
| */ | |||
| GOOAGOO_INFO_NOT_FOUND(62001,"数衍信息未找到"), | |||
| GOOAGOO_OPEN_FAIL(62002,"数衍信息请求失败"), | |||
| ; | |||
| @@ -0,0 +1,50 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_third_party_config") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxThirdPartyConfig extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="appId") | |||
| private String appId; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="appKey") | |||
| private String appKey; | |||
| @io.swagger.annotations.ApiModelProperty(value="加密key",name="signKey") | |||
| private String signKey; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="apiUrl") | |||
| private String apiUrl; | |||
| @io.swagger.annotations.ApiModelProperty(value="token",name="token") | |||
| private String token; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="tokenExpiredTime") | |||
| private Date tokenExpiredTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆username",name="userName") | |||
| private String userName; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆password",name="password") | |||
| private String password; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="version") | |||
| private String version; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="tpId") | |||
| private String tpId; | |||
| } | |||
| @@ -27,7 +27,7 @@ public enum EnumScoreType { | |||
| SIGN_IN_FTDAY(19, "连续签到14天"), | |||
| SIGN_IN_TEDAY(20, "连续签到28天"), | |||
| QUESTION_ADD_CREDIT(21, "游戏奖励积分"), | |||
| QUESTION_ADD_CREDIT(21, "问卷奖励积分"), | |||
| ; | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumThirdPartyConfigType { | |||
| GOOAGOO(5, "数衍科技"), | |||
| ; | |||
| public static EnumThirdPartyConfigType getEnum(Integer code) { | |||
| for (EnumThirdPartyConfigType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumThirdPartyConfigType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxThirdPartyConfig; | |||
| import java.util.List; | |||
| public interface WxThirdPartyConfigMapper extends CommonMapper<WxThirdPartyConfig, Long> { | |||
| List<WxThirdPartyConfig> findList(WxThirdPartyConfig config); | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import java.util.Map; | |||
| public interface WxGooagooService { | |||
| ResultData queryDataUrl(TenantEntity tenantInfo, String url, Map<String, Object> params); | |||
| } | |||
| @@ -871,7 +871,12 @@ public class DataTowerServiceImpl implements DataTowerService { | |||
| logger.info("bid:"+wiWideInfo.getWiwideId()+",newdata:"+data); | |||
| if (data == null) | |||
| return null; | |||
| token = (String) JSONObject.parseObject(data).get("data"); | |||
| try{ | |||
| token = (String) JSONObject.parseObject(data).get("data"); | |||
| }catch (Exception e){ | |||
| logger.error("getWiwideToken--"+e.getMessage()); | |||
| return null; | |||
| } | |||
| updateToken(wiWideInfo, token); | |||
| // } | |||
| logger.info("返回的token:"+token); | |||
| @@ -7,16 +7,14 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxActivity; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxActivityMapper; | |||
| import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.mapper.WxCouponChannelMapper; | |||
| import com.iformall.mapper.WxQuestionOneselfMapper; | |||
| import com.iformall.service.QrCodeService; | |||
| import com.iformall.service.WxCampaignService; | |||
| import com.iformall.service.WxCouponService; | |||
| @@ -58,6 +56,9 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| @Autowired | |||
| WxActivityMapper wxActivityMapper; | |||
| @Autowired | |||
| WxQuestionOneselfMapper wxQuestionOneselfMapper; | |||
| @Override | |||
| public PageInfo<WxCampaign> listAsPage(WxCampaign record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCampaignMapper.findList(record)); | |||
| @@ -111,8 +112,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| if (wxCampaign.getProduceType() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceType不能为空"); | |||
| } | |||
| if (wxCampaign.getProduceType().equals(EnumCampaignProductType.ACTIVITY_JOIN.getCode()) | |||
| && wxCampaign.getProduceId() == null) { | |||
| if (wxCampaign.getProduceId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(wxCampaign.getPagePath())) { | |||
| @@ -151,8 +151,7 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| if (wxCampaign.getProduceType() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceType不能为空"); | |||
| } | |||
| if (wxCampaign.getProduceType().equals(EnumCampaignProductType.ACTIVITY_JOIN.getCode()) | |||
| && wxCampaign.getProduceId() == null) { | |||
| if (wxCampaign.getProduceId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "produceId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(wxCampaign.getPagePath())) { | |||
| @@ -180,17 +179,39 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| wxCampaignMapper.updateById(wxCampaign); | |||
| if (wxCampaign.getType().equals(EnumCampaignType.PAGEPATH.getCode())) { | |||
| WxCampaign campaign = wxCampaignMapper.selectById(wxCampaign.getId()); | |||
| WxActivity wxActivity = new WxActivity(); | |||
| wxActivity.setId(campaign.getProduceId()); | |||
| wxActivity.setStatus(wxCampaign.getStatus()); | |||
| wxActivity.setUpdateTime(new Date()); | |||
| wxActivityMapper.updateById(wxActivity); | |||
| this.updateOtherStatus(campaign.getProduceId(),campaign.getStatus(),campaign.getProduceType()); | |||
| } | |||
| //type 为固定格式才会有券的信息 才会有投放的问题 | |||
| couponInject(wxCampaign); | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| private void updateOtherStatus(Long produceId, Integer status,Integer produceType) { | |||
| if(produceType.equals(EnumCampaignProductType.ACTIVITY_JOIN.getCode())){ | |||
| WxActivity wxActivity = new WxActivity(); | |||
| wxActivity.setId(produceId); | |||
| if (status.equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())){ | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_CAMPAIGN.getCode()); | |||
| } | |||
| if(status.equals(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode())){ | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_ONLINE.getCode()); | |||
| } | |||
| wxActivity.setUpdateTime(new Date()); | |||
| wxActivityMapper.updateById(wxActivity); | |||
| }else if(produceType.equals(EnumCampaignProductType.QUESTION_ONESEL.getCode())){ | |||
| WxQuestionOneself wxQuestionOneself = new WxQuestionOneself(); | |||
| wxQuestionOneself.setId(produceId); | |||
| if (status.equals(EnumCampaignStatus.STATUS_THROW_IN.getCode())){ | |||
| wxQuestionOneself.setStatus(EnumActivityStatus.INJECT_CAMPAIGN.getCode()); | |||
| } | |||
| if(status.equals(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode())){ | |||
| wxQuestionOneself.setStatus(EnumActivityStatus.INJECT_ONLINE.getCode()); | |||
| } | |||
| wxQuestionOneself.setUpdateDate(new Date()); | |||
| wxQuestionOneselfMapper.updateById(wxQuestionOneself); | |||
| } | |||
| } | |||
| public void couponInject(WxCampaign wxCampaign) { | |||
| wxCampaign = wxCampaignMapper.selectById(wxCampaign.getId()); | |||
| if (wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| @@ -444,6 +444,10 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| return signinMonthCredit(record,EnumScoreType.SIGN_IN_TEDAY); | |||
| } | |||
| if (record.getCreditType() == EnumScoreType.QUESTION_ADD_CREDIT.getCode()) { | |||
| return record.getCreditNum(); | |||
| } | |||
| return 0; | |||
| } | |||
| @@ -0,0 +1,96 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.druid.support.json.JSONUtils; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxThirdPartyConfig; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumThirdPartyConfigType; | |||
| import com.iformall.mapper.WxThirdPartyConfigMapper; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.HttpUtil; | |||
| import com.iformall.utils.gooagoo.SignUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import java.util.*; | |||
| /** | |||
| */ | |||
| @Service | |||
| public class WxGooagooServiceImpl implements WxGooagooService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final String method = "gogo.open.auto.routing"; | |||
| private final String v = "1.0"; | |||
| @Autowired | |||
| WxThirdPartyConfigMapper wxThirdPartyConfigMapper; | |||
| /** | |||
| * @param tenantEntity | |||
| * @param url | |||
| * @param params | |||
| * @return | |||
| */ | |||
| @Override | |||
| public ResultData queryDataUrl(TenantEntity tenantEntity, String url, Map<String, Object> params) { | |||
| WxThirdPartyConfig configQ = new WxThirdPartyConfig(); | |||
| configQ.updateTenantInfo(tenantEntity); | |||
| configQ.setType(EnumThirdPartyConfigType.GOOAGOO.getCode()); | |||
| configQ.setVersion(v); | |||
| WxThirdPartyConfig config = wxThirdPartyConfigMapper.selectOne(new QueryWrapper<>(configQ)); | |||
| if(config == null){ | |||
| return new ResultData(ErrorCode.GOOAGOO_INFO_NOT_FOUND); | |||
| } | |||
| Map<String,String> paramMap = this.getParamMap(config); | |||
| paramMap.put("lowerMethod",url); | |||
| List<String> sl = new ArrayList<>(); | |||
| sl.add(config.getTpId()); | |||
| params.put("shopIds", sl); | |||
| paramMap.put("data", JSONUtils.toJSONString(params)); | |||
| String sign= SignUtils.sign(config.getSignKey(),paramMap); | |||
| paramMap.put("sign",sign); | |||
| String res = HttpUtil.doPost(config.getApiUrl(), paramMap); | |||
| JSONObject result = JSONObject.parseObject(res); | |||
| logger.info("GOOAGOO_RESULT{}"+result.toJSONString()); | |||
| if (result == null) | |||
| return new ResultData(ErrorCode.GOOAGOO_INFO_NOT_FOUND); | |||
| if ("OPEN_SUCCESS".equals(result.getString("rescode"))){ | |||
| return new ResultData(Result.SUCCESS,result.getString("resmsg"), | |||
| result.get("data")); | |||
| // result.getJSONArray("data")); | |||
| } else{ | |||
| return new ResultData(ErrorCode.GOOAGOO_OPEN_FAIL,result.getString("resmsg")); | |||
| } | |||
| } | |||
| private Map<String,String> getParamMap(WxThirdPartyConfig config){ | |||
| Map<String,String> map = new HashMap<>(); | |||
| map.put("appId",config.getAppId()); | |||
| map.put("appKey",config.getAppKey()); | |||
| map.put("method",method); | |||
| map.put("timestamp", DateUtils.getSystemTime("yyyyMMDDHHmmss")); | |||
| map.put("messageFormat","json"); | |||
| map.put("v",v); | |||
| map.put("signMethod","MD5"); | |||
| return map; | |||
| } | |||
| } | |||
| @@ -144,7 +144,13 @@ public class WxQuestionOneselfUserServiceImpl implements WxQuestionOneselfUserSe | |||
| wxQuestionOneselfMapper.updateCountUser(record.getQuestionId()); | |||
| WxQuestionOneself wxQuestionOneself = wxQuestionOneselfMapper.selectById(record.getQuestionId()); | |||
| if(wxQuestionOneself.getRewardCredit() != null && wxQuestionOneself.getRewardCredit() >= 0){ | |||
| if(now.before(wxQuestionOneself.getStartDate())){ | |||
| throw new MallinkException(ErrorCode.QUESTION_NOT_START); | |||
| } | |||
| if(now.after(wxQuestionOneself.getEndDate())){ | |||
| throw new MallinkException(ErrorCode.QUESTION_END); | |||
| } | |||
| if(wxQuestionOneself.getRewardCredit() != null && wxQuestionOneself.getRewardCredit() > 0){ | |||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | |||
| wxCreditHistory.setTenantId(record.getFinalTenantId()); | |||
| wxCreditHistory.setCUserId(record.getUserId()); | |||
| @@ -179,7 +185,7 @@ public class WxQuestionOneselfUserServiceImpl implements WxQuestionOneselfUserSe | |||
| WxQuestionOneselfTopic topicQ = new WxQuestionOneselfTopic(); | |||
| topicQ.updateTenantInfo(record); | |||
| topicQ.setQuestionId(record.getId()); | |||
| topicQ.setQuestionId(record.getQuestionId()); | |||
| List<WxQuestionOneselfTopic> topicList = wxQuestionOneselfTopicMapper.findList(topicQ); | |||
| if(topicList != null && topicList.size() > 0){ | |||
| @@ -205,9 +211,10 @@ public class WxQuestionOneselfUserServiceImpl implements WxQuestionOneselfUserSe | |||
| map.put(log.getTopicId().toString(),log.getAnswerStr()); | |||
| } | |||
| } | |||
| dataList.add(map); | |||
| } | |||
| } | |||
| excelService.exportExcel(headList,dataList, null, "ceshi", "ceshi.xlsx", true,response ); | |||
| excelService.exportExcel(headList,dataList, null, "问卷", "问卷结果.xlsx", true,response ); | |||
| } | |||
| @Override | |||
| @@ -0,0 +1,78 @@ | |||
| package com.iformall.utils.gooagoo; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import java.security.MessageDigest; | |||
| import java.util.Arrays; | |||
| import java.util.Map; | |||
| public class SignUtils { | |||
| private final static Logger logger = LoggerFactory.getLogger(SignUtils.class); | |||
| public SignUtils() { | |||
| } | |||
| public static String sign(String appSecret, Map<String, String> form) { | |||
| return getSign(appSecret, form, (String)form.get("signMethod")); | |||
| } | |||
| public static String getSign(String appSecret, Map<String, String> params, String signMethod) { | |||
| String[] keys = (String[])params.keySet().toArray(new String[0]); | |||
| Arrays.sort(keys); | |||
| StringBuilder signStr = new StringBuilder(); | |||
| String[] var5 = keys; | |||
| int var6 = keys.length; | |||
| for(int var7 = 0; var7 < var6; ++var7) { | |||
| String key = var5[var7]; | |||
| String value = (String)params.get(key); | |||
| if (value != null && !"".equals(value)) { | |||
| signStr.append(key).append("=").append(value).append("&"); | |||
| } | |||
| } | |||
| signStr.append("key=").append(appSecret); | |||
| logger.info("服务端的签名之前的字符串:" + signStr.toString()); | |||
| if ("MD5".equals(signMethod)) { | |||
| return getMD5(signStr.toString()); | |||
| } else { | |||
| return getSHA(signStr.toString()); | |||
| } | |||
| } | |||
| public static String getSHA(String str) { | |||
| return encrypt(str, "SHA"); | |||
| } | |||
| public static String getMD5(String str) { | |||
| return encrypt(str, "MD5"); | |||
| } | |||
| private static String encrypt(String str, String algorithm) { | |||
| try { | |||
| MessageDigest md = MessageDigest.getInstance(algorithm); | |||
| md.update(str.getBytes("UTF-8")); | |||
| byte[] digest = md.digest(); | |||
| StringBuffer hexstr = new StringBuffer(); | |||
| String shaHex = ""; | |||
| for(int i = 0; i < digest.length; ++i) { | |||
| shaHex = Integer.toHexString(digest[i] & 255); | |||
| if (shaHex.length() < 2) { | |||
| hexstr.append(0); | |||
| } | |||
| hexstr.append(shaHex); | |||
| } | |||
| return hexstr.toString().toUpperCase(); | |||
| } catch (Exception var7) { | |||
| var7.printStackTrace(); | |||
| // throw new Exception(var7); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -7,7 +7,7 @@ | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||
| <result column="liaison_man" jdbcType="VARCHAR" property="liaisonMan"/> | |||
| <result column="liaison_sex" jdbcType="TINYINT" property="liaisonrSex"/> | |||
| <result column="liaison_sex" jdbcType="TINYINT" property="liaisonSex"/> | |||
| <result column="liaison_phone" jdbcType="VARCHAR" property="liaisonPhone"/> | |||
| <result column="liaison_email" jdbcType="VARCHAR" property="liaisonEmail"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| @@ -55,7 +55,6 @@ | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| <if test=" null == sortColumns">order by </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxQuestionOneselfLog" resultMap="BaseResultMap"> | |||
| @@ -0,0 +1,72 @@ | |||
| <?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.WxThirdPartyConfigMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxThirdPartyConfig"> | |||
| <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="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="app_id" jdbcType="VARCHAR" property="appId"/> | |||
| <result column="app_key" jdbcType="VARCHAR" property="appKey"/> | |||
| <result column="sign_key" jdbcType="VARCHAR" property="signKey"/> | |||
| <result column="api_url" jdbcType="VARCHAR" property="apiUrl"/> | |||
| <result column="token" jdbcType="VARCHAR" property="token"/> | |||
| <result column="token_expired_time" jdbcType="TIMESTAMP" property="tokenExpiredTime"/> | |||
| <result column="user_name" jdbcType="VARCHAR" property="userName"/> | |||
| <result column="password" jdbcType="VARCHAR" property="password"/> | |||
| <result column="version" jdbcType="VARCHAR" property="version"/> | |||
| <result column="tp_id" jdbcType="VARCHAR" property="tpId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`type`,`app_id`,`app_key`,`sign_key`,`api_url`, `token`,`token_expired_time`,`user_name`,`password`,`version`,`tp_id` | |||
| </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 != type "> | |||
| and `type` = #{type} | |||
| </if> | |||
| <if test=" null != version and '' != version"> | |||
| and `version` = #{version} | |||
| </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.WxThirdPartyConfig" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_third_party_config | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <update id="updateToken" parameterType="com.iformall.domain.po.WxThirdPartyConfig"> | |||
| update wx_third_party_config set token=#{token},token_expired_time=#{tokenExpiredTime} where id=#{id} | |||
| </update> | |||
| <update id="updateSercret" parameterType="com.iformall.domain.po.WxThirdPartyConfig"> | |||
| update wx_third_party_config set app_id=#{appId},app_key=#{appKey} where id=#{id} | |||
| </update> | |||
| </mapper> | |||