Compare commits
No commits in common. "2e96ee97fc51c60e26858aa758eb23dde2f973c5" and "0e94c5d24ec42cbef864629f1591cede00a46a39" have entirely different histories.
2e96ee97fc
...
0e94c5d24e
@ -1,7 +1,6 @@
|
|||||||
package com.suisung.mall.common.modules.message;
|
package com.suisung.mall.common.modules.message;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
@ -96,7 +95,5 @@ public class ShopMessageTemplate implements Serializable {
|
|||||||
@ApiModelProperty(value = "华为签名管理-通道号")
|
@ApiModelProperty(value = "华为签名管理-通道号")
|
||||||
private String message_tpl_sender;
|
private String message_tpl_sender;
|
||||||
|
|
||||||
// @ApiModelProperty(value = "微信通知(BOOL):0-禁用;1-启用")
|
|
||||||
// @TableField(exist = false)
|
|
||||||
// private Integer message_wechatxcx_enable;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ public class ShopWechatTplmsg implements Serializable {
|
|||||||
@ApiModelProperty(value = "模版标题")
|
@ApiModelProperty(value = "模版标题")
|
||||||
private String tplmsg_title;
|
private String tplmsg_title;
|
||||||
|
|
||||||
@ApiModelProperty(value = "模版类型(LIST):1-订单提醒; 2-支付提醒;3-发货提醒;4-活动通知")
|
@ApiModelProperty(value = "模版类型(LIST):1-订单提醒; 2-支付提醒;3-发货提醒")
|
||||||
private Integer tplmsg_type_id;
|
private Integer tplmsg_type_id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "微信消息模板标题")
|
@ApiModelProperty(value = "微信消息模板标题")
|
||||||
@ -65,6 +65,5 @@ public class ShopWechatTplmsg implements Serializable {
|
|||||||
@ApiModelProperty(value = "消息模板id:关联消息模板")
|
@ApiModelProperty(value = "消息模板id:关联消息模板")
|
||||||
private String message_id;
|
private String message_id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "微信公众号或者小程序跳转路径")
|
|
||||||
private String link_url;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,17 +91,5 @@ public class ShopMessageTemplateController extends BaseControllerImpl {
|
|||||||
return CommonResult.success(shopMessageTemplateService.remove(message_id));
|
return CommonResult.success(shopMessageTemplateService.remove(message_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 发送消息推送
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "消息模板表-编辑", notes = "消息模板表-编辑")
|
|
||||||
@RequestMapping(value = "/sendToXcxUserMessage", method = RequestMethod.POST)
|
|
||||||
public CommonResult sendToXcxUserMessage(@RequestParam(name = "userId") Integer userId) {
|
|
||||||
return shopMessageTemplateService.sendToXcxUserMessage(userId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,63 +0,0 @@
|
|||||||
package com.suisung.mall.shop.message.controller.mobile;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
|
||||||
import com.suisung.mall.common.domain.UserDto;
|
|
||||||
import com.suisung.mall.common.exception.ApiUserException;
|
|
||||||
import com.suisung.mall.common.modules.wechat.ShopWechatTplmsg;
|
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
|
||||||
import com.suisung.mall.common.utils.ContextUtil;
|
|
||||||
import com.suisung.mall.common.utils.I18nUtil;
|
|
||||||
import com.suisung.mall.shop.wechat.service.ShopWechatTplmsgService;
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* 消息模板表 前端控制器
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Xinze
|
|
||||||
* @since 2021-08-17
|
|
||||||
*/
|
|
||||||
@Api(tags = "消息模板表")
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/mobile/shop/shop-wechat-template")
|
|
||||||
public class ShopWechatTplmsgMolbieController extends BaseControllerImpl {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private ShopWechatTplmsgService shopWechatTplmsgService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 小程序模板列表查询
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@ApiOperation(value = "小程序模板列表查询", notes = "小程序模板列表查询")
|
|
||||||
@RequestMapping(value = "/xcxTplmList", method = RequestMethod.GET)
|
|
||||||
public CommonResult getWxXcxTplmList() {
|
|
||||||
UserDto user = ContextUtil.getCurrentUser();
|
|
||||||
if (user == null) {
|
|
||||||
throw new ApiUserException(I18nUtil._("用户信息异常!"));
|
|
||||||
}
|
|
||||||
QueryWrapper<ShopWechatTplmsg> wechatTplmsgQueryWrapper = new QueryWrapper<>();
|
|
||||||
wechatTplmsgQueryWrapper.select("tplmsg_tpl_id");
|
|
||||||
wechatTplmsgQueryWrapper.eq("tplmsg_type_id", 4);
|
|
||||||
List<ShopWechatTplmsg> shopWechatTplmsgList= shopWechatTplmsgService.list(wechatTplmsgQueryWrapper);
|
|
||||||
List<String> tempIdList = new ArrayList<>();
|
|
||||||
shopWechatTplmsgList.forEach(shopWechatTplmsg -> {
|
|
||||||
tempIdList.add(shopWechatTplmsg.getTplmsg_tpl_id());
|
|
||||||
});
|
|
||||||
return CommonResult.success(tempIdList);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
package com.suisung.mall.shop.message.service;
|
package com.suisung.mall.shop.message.service;
|
||||||
|
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
|
||||||
import com.suisung.mall.common.modules.message.ShopMessageTemplate;
|
import com.suisung.mall.common.modules.message.ShopMessageTemplate;
|
||||||
import com.suisung.mall.common.modules.wechat.ShopWechatTplmsg;
|
import com.suisung.mall.common.modules.wechat.ShopWechatTplmsg;
|
||||||
import com.suisung.mall.core.web.service.IBaseService;
|
import com.suisung.mall.core.web.service.IBaseService;
|
||||||
@ -44,5 +43,4 @@ public interface ShopMessageTemplateService extends IBaseService<ShopMessageTemp
|
|||||||
|
|
||||||
Integer aliyunSmsSend(List<String> mobiles, String tmplCode, Map<String,Object> tmplParams);
|
Integer aliyunSmsSend(List<String> mobiles, String tmplCode, Map<String,Object> tmplParams);
|
||||||
|
|
||||||
CommonResult sendToXcxUserMessage(Integer user_id);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import com.aliyuncs.exceptions.ClientException;
|
|||||||
import com.aliyuncs.profile.DefaultProfile;
|
import com.aliyuncs.profile.DefaultProfile;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.suisung.mall.common.api.BindCode;
|
import com.suisung.mall.common.api.BindCode;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
import com.suisung.mall.common.exception.ApiException;
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
import com.suisung.mall.common.feignService.AccountService;
|
import com.suisung.mall.common.feignService.AccountService;
|
||||||
@ -41,7 +40,6 @@ import com.suisung.mall.shop.components.push.GeTuiUtil;
|
|||||||
import com.suisung.mall.shop.message.mapper.ShopMessageTemplateMapper;
|
import com.suisung.mall.shop.message.mapper.ShopMessageTemplateMapper;
|
||||||
import com.suisung.mall.shop.message.service.ShopMessageTemplateService;
|
import com.suisung.mall.shop.message.service.ShopMessageTemplateService;
|
||||||
import com.suisung.mall.shop.message.vo.WxTelMsgPushVo;
|
import com.suisung.mall.shop.message.vo.WxTelMsgPushVo;
|
||||||
import com.suisung.mall.shop.message.vo.WxXcxMsgPushVo;
|
|
||||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||||
import com.suisung.mall.shop.wechat.service.ShopWechatTplmsgService;
|
import com.suisung.mall.shop.wechat.service.ShopWechatTplmsgService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -53,8 +51,6 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -265,7 +261,6 @@ public class ShopMessageTemplateServiceImpl extends BaseServiceImpl<ShopMessageT
|
|||||||
|
|
||||||
String[] activeProfiles = environment.getActiveProfiles();
|
String[] activeProfiles = environment.getActiveProfiles();
|
||||||
String activeProfile = activeProfiles[0];
|
String activeProfile = activeProfiles[0];
|
||||||
|
|
||||||
// 短信发送,生产环境才允许短信发送
|
// 短信发送,生产环境才允许短信发送
|
||||||
if (message_row.getMessage_sms_enable() > 0 && !user_setting.isEmpty() && activeProfile.equals("prod")) {
|
if (message_row.getMessage_sms_enable() > 0 && !user_setting.isEmpty() && activeProfile.equals("prod")) {
|
||||||
|
|
||||||
@ -668,109 +663,4 @@ public class ShopMessageTemplateServiceImpl extends BaseServiceImpl<ShopMessageT
|
|||||||
|
|
||||||
return successCnt;
|
return successCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommonResult sendToXcxUserMessage(Integer user_id) {
|
|
||||||
Map bind_row = accountService.getBind(user_id, BindCode.WEIXIN_XCX);
|
|
||||||
if(bind_row == null){
|
|
||||||
return CommonResult.failed("账号不存在");
|
|
||||||
}
|
|
||||||
if(bind_row.get("bind_openid")==null){
|
|
||||||
log.info("微信id不存在");
|
|
||||||
return CommonResult.failed("微信id不存在");
|
|
||||||
}
|
|
||||||
String open_id = (String) bind_row.get("bind_openid");
|
|
||||||
Map args=new HashMap();
|
|
||||||
String[] activeProfiles = environment.getActiveProfiles();
|
|
||||||
String activeProfile = activeProfiles[0];
|
|
||||||
//微信小程序订阅消息
|
|
||||||
args.put("evn",activeProfile);
|
|
||||||
//String open_id = Convert.toStr(user_setting.get("bind_openid"));
|
|
||||||
//从bind表中读取用户公众号openid
|
|
||||||
if (StrUtil.isNotEmpty(open_id)) {
|
|
||||||
String accessToken = accountService.getXcxAccessToken(true);
|
|
||||||
String url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=" + accessToken;
|
|
||||||
QueryWrapper<ShopWechatTplmsg> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("tplmsg_id", 1022);//todo 后期改为动态
|
|
||||||
ShopWechatTplmsg wechatTplmsg = shopWechatTplmsgService.getOne(queryWrapper);
|
|
||||||
ShopStoreBase shopStoreBase= shopStoreBaseService.get(wechatTplmsg.getStore_id());
|
|
||||||
args.put("storeName", shopStoreBase.getStore_name());
|
|
||||||
if (wechatTplmsg != null) {
|
|
||||||
String wechatTplData = getXcxWechatTplData(open_id, wechatTplmsg, args);
|
|
||||||
log.info(wechatTplData);
|
|
||||||
String result = WxHttpUtil.request(WxHttpUtil.MethodType.POST, WxHttpUtil.WxType.XCX, accessToken, url, null, wechatTplData);
|
|
||||||
JSONObject resultJson = JSONUtil.parseObj(result);
|
|
||||||
Integer errcode = Convert.toInt(resultJson.get("errcode"));
|
|
||||||
String errmsg = Convert.toStr(resultJson.get("errmsg"));
|
|
||||||
if (errcode != 0) {
|
|
||||||
log.error("微信公众号推送失败,失败原因:{}", errmsg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CommonResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取微信小程序模板数据
|
|
||||||
*
|
|
||||||
* @param open_id
|
|
||||||
* @param wechatTplmsg
|
|
||||||
* @param args
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getXcxWechatTplData(String open_id, ShopWechatTplmsg wechatTplmsg, Map args) {
|
|
||||||
WxXcxMsgPushVo wxXcxMsgPushVo = new WxXcxMsgPushVo();
|
|
||||||
wxXcxMsgPushVo.setTouser(open_id);
|
|
||||||
wxXcxMsgPushVo.setTemplate_id(wechatTplmsg.getTplmsg_tpl_id());
|
|
||||||
wxXcxMsgPushVo.setPage(wechatTplmsg.getLink_url());
|
|
||||||
|
|
||||||
String evn=Convert.toStr(args.get("evn"));
|
|
||||||
String storeName=Convert.toStr(args.get("storeName"));
|
|
||||||
String miniprogram_state="trial";//默认为体验版
|
|
||||||
if(evn.equals("prod")){
|
|
||||||
miniprogram_state="formal";
|
|
||||||
}
|
|
||||||
wxXcxMsgPushVo.setMiniprogram_state(miniprogram_state);
|
|
||||||
wxXcxMsgPushVo.setLang("zh_CN");
|
|
||||||
|
|
||||||
// 通用信息
|
|
||||||
WxXcxMsgPushVo.BaseValue BaseValue = new WxXcxMsgPushVo.BaseValue();
|
|
||||||
WxXcxMsgPushVo.DetailValue Thing1 = new WxXcxMsgPushVo.DetailValue();
|
|
||||||
Thing1.setValue(storeName);
|
|
||||||
BaseValue.setThing1(Thing1);//商家名称
|
|
||||||
|
|
||||||
WxXcxMsgPushVo.DetailValue phrase3 = new WxXcxMsgPushVo.DetailValue();//活动类型
|
|
||||||
WxXcxMsgPushVo.DetailValue amount4 = new WxXcxMsgPushVo.DetailValue();//商品价格
|
|
||||||
WxXcxMsgPushVo.DetailValue time6 = new WxXcxMsgPushVo.DetailValue();//活动时间
|
|
||||||
WxXcxMsgPushVo.DetailValue time9 = new WxXcxMsgPushVo.DetailValue();//活动截止
|
|
||||||
|
|
||||||
phrase3.setValue("秒杀特价");
|
|
||||||
BaseValue.setPhrase3(phrase3);
|
|
||||||
|
|
||||||
amount4.setValue("0.01元起");
|
|
||||||
BaseValue.setAmount4(amount4);
|
|
||||||
|
|
||||||
// 获取当前时间
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
|
|
||||||
// 加上12小时
|
|
||||||
LocalDateTime futureTime = now.plusHours(12);
|
|
||||||
|
|
||||||
// 格式化输出
|
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String formattedNow = now.format(formatter);
|
|
||||||
String formattedFuture = futureTime.format(formatter);
|
|
||||||
time6.setValue(formattedNow);
|
|
||||||
BaseValue.setTime6(time6);
|
|
||||||
time9.setValue(formattedFuture);
|
|
||||||
BaseValue.setTime9(time9);
|
|
||||||
|
|
||||||
wxXcxMsgPushVo.setData(BaseValue);
|
|
||||||
return JSON.toJSONString(wxXcxMsgPushVo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,55 +0,0 @@
|
|||||||
package com.suisung.mall.shop.message.vo;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class WxXcxMsgPushVo {
|
|
||||||
|
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String touser;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 2)
|
|
||||||
private String template_id;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 3)
|
|
||||||
private String page;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 5)
|
|
||||||
private BaseValue data;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 6)
|
|
||||||
private String miniprogram_state;//跳转小程序类型:developer为开发版;trial为体验版;formal为正式版;默认为正式版
|
|
||||||
|
|
||||||
@JSONField(ordinal = 7)
|
|
||||||
private String lang;//进入小程序查看”的语言类型,支持zh_CN(简体中文)、en_US(英文)、zh_HK(繁体中文)、zh_TW(繁体中文),默认为zh_CN
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class BaseValue {
|
|
||||||
|
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private DetailValue thing1;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 2)
|
|
||||||
private DetailValue phrase3;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 3)
|
|
||||||
private DetailValue amount4;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 4)
|
|
||||||
private DetailValue time6;
|
|
||||||
|
|
||||||
@JSONField(ordinal = 5)
|
|
||||||
private DetailValue time9;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public static class DetailValue {
|
|
||||||
@JSONField(ordinal = 1)
|
|
||||||
private String value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
alter table shop_wechat_tplmsg add column link_url varchar(500) comment '微信公众号或者小程序跳转路径' ;
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
INSERT INTO shop_wechat_tplmsg
|
|
||||||
(tplmsg_id, tplmsg_title, tplmsg_type_id, tplmsg_name, tplmsg_number, tplmsg_tpl_id, tplmsg_enable, tplmsg_is_buildin, tplmsg_remark, tplmsg_sort, store_id, message_id)
|
|
||||||
VALUES(1022, '秒杀活动', 4, '新活动通知', '9797', 'kiDj_hSF_ASwD-Dlgxnypi6IJBQZ12a-hEpd3zZ-Uxc', 1, 0, '活动秒杀', 50, 58, '0');
|
|
||||||
@ -1 +0,0 @@
|
|||||||
INSERT INTO `admin_base_protocol` (`ctl`, `met`, `db`, `rights_id`, `log`, `path`,`comment`) VALUES ('/mobile/shop/shop-wechat-template/xcxTplmList', 'index', 'master', '', '0', '/mobile/shop/shop-wechat-template/xcxTplmList','移动端查询模板接口');
|
|
||||||
Loading…
Reference in New Issue
Block a user