This commit is contained in:
周中平 2020-04-25 22:53:20 +08:00
parent dd83a2e9da
commit 6ec2a91921
68 changed files with 1907 additions and 1199 deletions

View File

@ -10,6 +10,17 @@
## 更新日志
### v1.1.41
```
新增:微信小程序订阅消息
修复多开小程序直播间同步ID问题
修复库存1下单后提示商品库存不足
修复拼团商品预览sku图片报错
优化:超管后台删除商家用户
注:本次更新须重新发布小程序
```
### v1.1.40
```
新增:微信小程序直播功能

View File

@ -5603,3 +5603,22 @@ INSERT INTO `yoshop_store_access` VALUES ('10460', '删除场次', 'apps.sharp.a
INSERT INTO `yoshop_store_access` VALUES ('10461', '基础设置', 'apps.sharp.setting/index', '10444', '125', '1564449650', '1564449650');
CREATE TABLE `yoshop_wxapp_live_room` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`room_id` int(11) unsigned NOT NULL COMMENT '直播间id',
`room_name` varchar(200) NOT NULL DEFAULT '' COMMENT '直播间名称',
`cover_img` varchar(255) DEFAULT '' COMMENT '分享卡片封面',
`share_img` varchar(255) DEFAULT '' COMMENT '直播间背景墙封面',
`anchor_name` varchar(30) NOT NULL DEFAULT '' COMMENT '主播昵称',
`start_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '开播时间',
`end_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '结束时间',
`live_status` tinyint(3) unsigned NOT NULL DEFAULT '102' COMMENT '直播状态(101: 直播中, 102: 未开始, 103: 已结束, 104: 禁播, 105: 暂停中, 106: 异常, 107: 已过期)',
`is_top` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '置顶状态(0未置顶 1已置顶)',
`is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '软删除(0未删除 1已删除)',
`wxapp_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '小程序id',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `room_id` (`room_id`)
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COMMENT='微信小程序直播间记录表';

View File

@ -0,0 +1,9 @@
ALTER TABLE `yoshop_wxapp_live_room`
ADD COLUMN `id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键id' FIRST ,
DROP PRIMARY KEY,
ADD PRIMARY KEY (`id`),
ADD INDEX `room_id` (`room_id`),
AUTO_INCREMENT=10001;

View File

@ -1,4 +1,23 @@

### v1.1.41 更新日志 ###
新增:微信小程序订阅消息
修复多开小程序直播间同步ID问题
修复库存1下单后提示商品库存不足
修复拼团商品预览sku图片报错
优化:超管后台删除商家用户
--------------------------------
注:本次更新须重新发布小程序
### v1.1.40 更新日志 ###
新增:微信小程序直播功能
优化:商品评价过滤无效内容
--------------------------------
注:本次更新须重新发布小程序
### v1.1.39 更新日志 ###
优化:后台菜单超出显示滚动条

View File

@ -56,7 +56,6 @@ class Store extends Controller
/**
* 添加小程序
* @return array|mixed
* @throws \think\exception\PDOException
*/
public function add()
{

View File

@ -90,7 +90,12 @@ class Wxapp extends WxappModel
*/
public function setDelete()
{
return $this->transaction(function () {
// 删除商家用户信息
(new StoreUser)->setDelete($this['wxapp_id']);
// 设置当前商城为已删除
return $this->save(['is_delete' => 1]);
});
}
}

View File

@ -139,518 +139,4 @@ class Access extends AccessModel
$this->buildData($defaultData);
}
/**
* 生成并写入默认数据
* @param $defaultData
* @param int $parent_id
*/
private function buildData(&$defaultData, $parent_id = 0)
{
foreach ($defaultData as $key => $item) {
// 保存数据
$model = new static;
$model->save([
'name' => $item['name'],
'url' => $item['url'],
'parent_id' => $parent_id,
'sort' => 100,
]);
if (isset($item['subset']) && !empty($item['subset'])) {
$this->buildData($item['subset'], $model['access_id']);
}
}
}
/**
* 默认权限数据
* @return array
*/
private function defaultData()
{
return [
[
'name' => '首页',
'url' => 'index/index'
],
[
'name' => '管理员',
'url' => 'store',
'subset' => [
[
'name' => '管理员管理',
'url' => 'store.user',
'subset' => [
[
'name' => '管理员列表',
'url' => 'store.user/index'
],
[
'name' => '添加管理员',
'url' => 'store.user/add'
],
[
'name' => '编辑管理员',
'url' => 'store.user/edit'
],
[
'name' => '删除管理员',
'url' => 'store.user/delete'
],
]
],
[
'name' => '角色管理',
'url' => 'store.role',
'subset' => [
[
'name' => '角色列表',
'url' => 'store.role/index'
],
[
'name' => '添加角色',
'url' => 'store.role/add'
],
[
'name' => '编辑角色',
'url' => 'store.role/edit'
],
[
'name' => '删除角色',
'url' => 'store.role/delete'
],
]
],
[
'name' => '权限管理',
'url' => 'store.access',
'subset' => [
[
'name' => '权限列表',
'url' => 'store.access/index'
],
[
'name' => '添加权限',
'url' => 'store.access/add'
],
[
'name' => '编辑权限',
'url' => 'store.access/edit'
],
[
'name' => '删除权限',
'url' => 'store.access/delete'
],
]
],
]
],
[
'name' => '商品管理',
'url' => 'goods',
'subset' => [
[
'name' => '商品管理',
'url' => 'goods',
'subset' => [
[
'name' => '商品列表',
'url' => 'goods/index',
],
[
'name' => '添加商品',
'url' => 'goods/add',
],
[
'name' => '编辑商品',
'url' => 'goods/edit',
],
[
'name' => '复制商品',
'url' => 'goods/copy',
],
[
'name' => '删除商品',
'url' => 'goods/delete',
],
[
'name' => '商品上下架',
'url' => 'goods/state',
],
]
],
[
'name' => '商品分类',
'url' => 'goods.category',
'subset' => [
[
'name' => '分类列表',
'url' => 'goods.category/index',
],
[
'name' => '添加分类',
'url' => 'goods.category/add',
],
[
'name' => '编辑分类',
'url' => 'goods.category/edit',
],
[
'name' => '删除分类',
'url' => 'goods.category/delete',
],
],
],
[
'name' => '商品评价',
'url' => 'goods.comment',
'subset' => [
[
'name' => '评价列表',
'url' => 'goods.comment/index',
],
[
'name' => '评价详情',
'url' => 'goods.comment/detail',
],
[
'name' => '删除评价',
'url' => 'goods.comment/delete',
],
],
],
]
],
[
'name' => '订单管理',
'url' => 'order',
'subset' => [
[
'name' => '订单列表',
'url' => '',
'subset' => [
[
'name' => '待发货',
'url' => 'order/delivery_list'
],
[
'name' => '待收货',
'url' => 'order/receipt_list'
],
[
'name' => '待付款',
'url' => 'order/pay_list'
],
[
'name' => '已完成',
'url' => 'order/complete_list'
],
[
'name' => '已取消',
'url' => 'order/cancel_list'
],
[
'name' => '全部订单',
'url' => 'order/all_list',
],
]
],
[
'name' => '订单详情',
'url' => '',
'subset' => [
[
'name' => '详情信息',
'url' => 'order/detail',
],
[
'name' => '确认发货',
'url' => 'order/delivery',
],
[
'name' => '修改订单价格',
'url' => 'order/updateprice',
],
]
],
[
'name' => '订单导出',
'url' => 'order.operate/export',
],
[
'name' => '批量发货',
'url' => 'order.operate/batchdelivery',
],
]
],
[
'name' => '用户管理',
'url' => 'user',
'subset' => [
[
'name' => '用户列表',
'url' => 'user/index'
],
[
'name' => '删除用户',
'url' => 'user/delete'
],
]
],
[
'name' => '营销设置',
'url' => 'market',
'subset' => [
[
'name' => '优惠券',
'url' => 'coupon',
'subset' => [
[
'name' => '优惠券列表',
'url' => 'market.coupon/index',
],
[
'name' => '新增优惠券',
'url' => 'market.coupon/add',
],
[
'name' => '编辑优惠券',
'url' => 'market.coupon/edit',
],
[
'name' => '删除优惠券',
'url' => 'market.coupon/delete',
],
[
'name' => '领取记录',
'url' => 'market.coupon/receive',
]
]
]
]
],
[
'name' => '小程序',
'url' => 'wxapp',
'subset' => [
[
'name' => '小程序设置',
'url' => 'wxapp/setting',
],
[
'name' => '页面管理',
'url' => 'wxapp.page',
'subset' => [
[
'name' => '页面设计',
'url' => '',
'subset' => [
[
'name' => '页面列表',
'url' => 'wxapp.page/index',
],
[
'name' => '新增页面',
'url' => 'wxapp.page/add',
],
[
'name' => '编辑页面',
'url' => 'wxapp.page/edit',
],
[
'name' => '设为首页',
'url' => 'wxapp.page/sethome',
],
]
],
[
'name' => '分类页模板',
'url' => 'wxapp.page/category',
],
[
'name' => '页面链接',
'url' => 'wxapp.page/links',
],
]
],
[
'name' => '帮助中心',
'url' => 'wxapp.help',
'subset' => [
[
'name' => '帮助列表',
'url' => 'wxapp.help/index',
],
[
'name' => '新增帮助',
'url' => 'wxapp.help/add',
],
[
'name' => '编辑帮助',
'url' => 'wxapp.help/edit',
],
[
'name' => '删除帮助',
'url' => 'wxapp.help/delete',
],
]
],
]
],
[
'name' => '应用中心',
'url' => 'apps',
'subset' => [
[
'name' => '分销中心',
'url' => 'apps.dealer',
'subset' => [
[
'name' => '入驻申请',
'url' => 'apps.dealer.apply',
'subset' => [
[
'name' => '申请列表',
'url' => 'apps.dealer.apply/index'
],
[
'name' => '分销商审核',
'url' => 'apps.dealer.apply/submit'
]
]
],
[
'name' => '分销商用户',
'url' => 'apps.dealer.user',
'subset' => [
[
'name' => '分销商列表',
'url' => 'apps.dealer.user/index',
],
[
'name' => '删除分销商',
'url' => 'apps.dealer.user/delete'
],
[
'name' => '分销商二维码',
'url' => 'apps.dealer.user/qrcode'
]
]
],
[
'name' => '分销订单',
'url' => 'apps.dealer.order/index',
],
[
'name' => '提现申请',
'url' => 'apps.dealer.withdraw',
'subset' => [
[
'name' => '申请列表',
'url' => 'apps.dealer.withdraw/index',
],
[
'name' => '提现审核',
'url' => 'apps.dealer.withdraw/submit'
],
[
'name' => '确认打款',
'url' => 'apps.dealer.withdraw/money'
]
]
],
[
'name' => '分销设置',
'url' => 'apps.dealer.setting/index',
],
[
'name' => '分销海报',
'url' => 'apps.dealer.setting/qrcode',
],
]
],
]
],
[
'name' => '设置',
'url' => 'setting',
'subset' => [
[
'name' => '商城设置',
'url' => 'setting/store',
],
[
'name' => '交易设置',
'url' => 'setting/trade',
],
[
'name' => '配送设置',
'url' => 'setting.delivery',
'subset' => [
[
'name' => '运费模板列表',
'url' => 'setting.delivery/index'
],
[
'name' => '新增运费模板',
'url' => 'setting.delivery/add'
],
[
'name' => '编辑运费模板',
'url' => 'setting.delivery/edit'
],
[
'name' => '删除运费模板',
'url' => 'setting.delivery/delete'
],
]
],
[
'name' => '物流公司',
'url' => 'setting.express',
'subset' => [
[
'name' => '物流公司列表',
'url' => 'setting.express/index'
],
[
'name' => '新增物流公司',
'url' => 'setting.express/add'
],
[
'name' => '编辑物流公司',
'url' => 'setting.express/edit'
],
[
'name' => '删除物流公司',
'url' => 'setting.express/delete'
],
]
],
[
'name' => '短信通知',
'url' => 'setting/sms',
],
[
'name' => '模板消息',
'url' => 'setting/tplmsg',
],
[
'name' => '上传设置',
'url' => 'setting/storage',
],
[
'name' => '其他',
'url' => '',
'subset' => [
[
'name' => '清理缓存',
'url' => 'setting.cache/clear',
],
]
]
]
],
];
}
}

View File

@ -2,6 +2,7 @@
namespace app\admin\model\store;
use app\common\exception\BaseException;
use app\common\model\store\User as StoreUserModel;
/**
@ -13,30 +14,55 @@ class User extends StoreUserModel
{
/**
* 新增商家用户记录
* @param $wxapp_id
* @param $data
* @param int $wxappId
* @param array $data
* @return bool|false|int
*/
public function add($wxapp_id, $data)
public function add($wxappId, $data)
{
return $this->save([
'user_name' => $data['user_name'],
'password' => yoshop_hash($data['password']),
'wxapp_id' => $wxapp_id,
'is_super' => 1,
'wxapp_id' => $wxappId,
]);
}
/**
* 商家用户登录
* @param $wxapp_id
* @param int $wxappId
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function login($wxapp_id)
public function login($wxappId)
{
// 验证用户名密码是否正确
$user = self::detail(['wxapp_id' => $wxapp_id], ['wxapp']);
// 获取获取商城超级管理员用户信息
$user = $this->getSuperStoreUser($wxappId);
if (empty($user)) {
throw new BaseException(['msg' => '超级管理员用户信息不存在']);
}
$this->loginState($user);
}
/**
* 获取获取商城超级管理员用户信息
* @param $wxappId
* @return User|null
* @throws \think\exception\DbException
*/
private function getSuperStoreUser($wxappId)
{
return static::detail(['wxapp_id' => $wxappId, 'is_super' => 1], ['wxapp']);
}
/**
* 删除小程序下的商家用户
* @param $wxappId
* @return false|int
*/
public function setDelete($wxappId)
{
return $this->save(['is_delete' => 1], ['wxapp_id' => $wxappId]);
}
}

View File

@ -79,7 +79,10 @@ class PaySuccess
private function onCommonEvent()
{
// 发送消息通知
(new MessageService)->payment($this->order, $this->orderType);
MessageService::send('order.payment', [
'order' => $this->order,
'order_type' => $this->orderType,
]);
// 小票打印
(new PrinterService)->printTicket($this->order, OrderStatusEnum::ORDER_PAYMENT);
}

View File

@ -13,13 +13,14 @@ use app\api\model\sharing\Setting as SettingModel;
class Setting extends Controller
{
/**
* 获取所有设置
* 获取拼团设置
* @return array
*/
public function getAll()
{
$basic = SettingModel::getItem('basic');
return $this->renderSuccess(['setting' => compact('basic')]);
// 获取拼团设置
$setting = SettingModel::getSetting();
return $this->renderSuccess(compact('setting'));
}
}

View File

@ -32,7 +32,6 @@ class Apply extends Controller
* @param string $mobile
* @return array
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function submit($name = '', $mobile = '')
{

View File

@ -47,7 +47,7 @@ class Withdraw extends Controller
$formData = json_decode(htmlspecialchars_decode($data), true);
$model = new WithdrawModel;
if ($model->submit($this->dealer, $formData)) {
return $this->renderSuccess([], '申请提现成功');
return $this->renderSuccess([], '提现申请已提交成功,请等待审核');
}
return $this->renderError($model->getError() ?: '提交失败');
}

View File

@ -3,10 +3,9 @@
namespace app\api\controller\wxapp;
use app\api\controller\Controller;
use app\api\model\wxapp\Formid as FormidModel;
/**
* form_id 管理
* form_id 管理 (已废弃)
* Class Formid
* @package app\api\controller\wxapp
*/
@ -17,20 +16,10 @@ class Formid extends Controller
* (因微信模板消息已下线所以formId取消不再收集)
* @param $formId
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function save($formId)
{
return $this->renderSuccess();
// if (!$user = $this->getUser(false)) {
// return $this->renderSuccess();
// }
// if (FormidModel::add($user['user_id'], $formId)) {
// return $this->renderSuccess();
// }
// return $this->renderError();
}
}

View File

@ -0,0 +1,25 @@
<?php
namespace app\api\controller\wxapp;
use app\api\controller\Controller;
use app\api\model\Setting as SettingModel;
/**
* 微信小程序订阅消息
* Class Submsg
* @package app\api\controller\wxapp
*/
class Submsg extends Controller
{
/**
* 获取订阅消息配置
* @return array
*/
public function setting()
{
$setting = SettingModel::getSubmsg();
return $this->renderSuccess(compact('setting'));
}
}

View File

@ -20,4 +20,18 @@ class Setting extends SettingModel
return static::getItem('points')['points_name'];
}
/**
* 获取微信订阅消息设置
*/
public static function getSubmsg()
{
$data = [];
foreach (static::getItem('submsg') as $groupName => $group) {
foreach ($group as $itemName => $item) {
$data[$groupName][$itemName]['template_id'] = $item['template_id'];
}
}
return $data;
}
}

View File

@ -2,14 +2,15 @@
namespace app\api\model\sharing;
use app\common\model\sharing\Setting as SettingModel;
use app\api\model\Setting as SettingModel;
use app\common\model\sharing\Setting as SharingSettingModel;
/**
* 拼团设置模型
* Class Setting
* @package app\api\model\sharing
*/
class Setting extends SettingModel
class Setting extends SharingSettingModel
{
/**
* 隐藏字段
@ -19,4 +20,19 @@ class Setting extends SettingModel
'update_time',
];
public static function getSetting()
{
// 订阅消息
$submsgList = [];
foreach (SettingModel::getItem('submsg')['sharing'] as $key => $item) {
$submsgList[$key] = $item['template_id'];
}
return [
// 基础设置
'basic' => static::getItem('basic'),
// 订阅消息
'order_submsg' => $submsgList,
];
}
}

View File

@ -300,8 +300,6 @@ class Checkout
{
// 系统支持的配送方式 (后台设置)
$deliveryType = SettingModel::getItem('store')['delivery_type'];
// 积分设置
$pointsSetting = SettingModel::getItem('points');
return [
// 配送类型
'delivery' => $this->param['delivery'] > 0 ? $this->param['delivery'] : $deliveryType[0],
@ -326,15 +324,32 @@ class Checkout
// 支付方式
'pay_type' => $this->param['pay_type'],
// 系统设置
'setting' => [
'setting' => $this->getSetting(),
// 记忆的自提联系方式
'last_extract' => UserService::getLastExtract($this->user['user_id']),
];
}
/**
* 获取订单页面中使用到的系统设置
* @return array
*/
private function getSetting()
{
// 系统支持的配送方式 (后台设置)
$deliveryType = SettingModel::getItem('store')['delivery_type'];
// 积分设置
$pointsSetting = SettingModel::getItem('points');
// 订阅消息
$orderSubMsgList = [];
foreach (SettingModel::getItem('submsg')['order'] as $item) {
!empty($item['template_id']) && $orderSubMsgList[] = $item['template_id'];
}
return [
'delivery' => $deliveryType, // 支持的配送方式
'points_name' => $pointsSetting['points_name'], // 积分名称
'points_describe' => $pointsSetting['describe'], // 积分说明
],
// 记忆的自提联系方式
'last_extract' => UserService::getLastExtract($this->user['user_id']),
// todo: delete - 兼容处理
'deliverySetting' => $deliveryType,
'order_submsg' => $orderSubMsgList, // 订阅消息
];
}

View File

@ -299,8 +299,6 @@ class Checkout
{
// 系统支持的配送方式 (后台设置)
$deliveryType = SettingModel::getItem('store')['delivery_type'];
// 积分设置
$pointsSetting = SettingModel::getItem('points');
return [
// 订单类型
'order_type' => $this->param['order_type'],
@ -327,11 +325,7 @@ class Checkout
// 支付方式
'pay_type' => $this->param['pay_type'],
// 系统设置
'setting' => [
'delivery' => $deliveryType, // 支持的配送方式
'points_name' => $pointsSetting['points_name'], // 积分名称
'points_describe' => $pointsSetting['describe'], // 积分说明
],
'setting' => $this->getSetting(),
// 记忆的自提联系方式
'last_extract' => UserService::getLastExtract($this->user['user_id']),
// todo: 兼容处理
@ -339,6 +333,29 @@ class Checkout
];
}
/**
* 获取订单页面中使用到的系统设置
* @return array
*/
private function getSetting()
{
// 系统支持的配送方式 (后台设置)
$deliveryType = SettingModel::getItem('store')['delivery_type'];
// 积分设置
$pointsSetting = SettingModel::getItem('points');
// 订阅消息
$orderSubMsgList = [];
foreach (SettingModel::getItem('submsg')['order'] as $item) {
!empty($item['template_id']) && $orderSubMsgList[] = $item['template_id'];
}
return [
'delivery' => $deliveryType, // 支持的配送方式
'points_name' => $pointsSetting['points_name'], // 积分名称
'points_describe' => $pointsSetting['describe'], // 积分说明
'order_submsg' => $orderSubMsgList, // 订阅消息
];
}
/**
* 当前用户可用的优惠券列表
* @param $orderTotalPrice

View File

@ -346,3 +346,17 @@ function filter_emoji($text)
// 如需支持emoji表情, 需将mysql的编码改为utf8mb4
return preg_replace('/[\xf0-\xf7].{3}/', '', $text);
}
/**
* 根据指定长度截取字符串
* @param $str
* @param int $length
* @return bool|string
*/
function str_substr($str, $length = 30)
{
if (strlen($str) > $length) {
$str = mb_substr($str, 0, $length);
}
return $str;
}

View File

@ -18,8 +18,8 @@ class Setting extends EnumBasics
// 短信通知
const SMS = 'sms';
// 模板消息
const TPL_MSG = 'tplMsg';
// // 模板消息
// const TPL_MSG = 'tplMsg';
// 上传设置
const STORAGE = 'storage';
@ -36,6 +36,9 @@ class Setting extends EnumBasics
// 积分设置
const POINTS = 'points';
// 订阅消息设置
const SUBMSG = 'submsg';
/**
* 获取订单类型值
* @return array
@ -55,10 +58,10 @@ class Setting extends EnumBasics
'value' => self::SMS,
'describe' => '短信通知',
],
self::TPL_MSG => [
'value' => self::TPL_MSG,
'describe' => '模板消息',
],
// self::TPL_MSG => [
// 'value' => self::TPL_MSG,
// 'describe' => '模板消息',
// ],
self::STORAGE => [
'value' => self::STORAGE,
'describe' => '上传设置',
@ -79,6 +82,10 @@ class Setting extends EnumBasics
'value' => self::POINTS,
'describe' => '积分设置',
],
self::SUBMSG => [
'value' => self::SUBMSG,
'describe' => '小程序订阅消息',
],
];
}

View File

@ -0,0 +1,45 @@
<?php
namespace app\common\enum\dealer;
use app\common\enum\EnumBasics;
/**
* 枚举类:分销商入驻审核状态
* Class ApplyStatus
* @package app\common\enum\dealer
*/
class ApplyStatus extends EnumBasics
{
// 待审核
const AUDIT_WAIT = 10;
// 审核通过
const AUDIT_PASS = 20;
// 驳回
const AUDIT_REJECT = 30;
/**
* 获取枚举类型值
* @return array
*/
public static function data()
{
return [
self::AUDIT_WAIT => [
'name' => '待审核',
'value' => self::AUDIT_WAIT,
],
self::AUDIT_PASS => [
'name' => '审核通过',
'value' => self::AUDIT_PASS,
],
self::AUDIT_REJECT => [
'name' => '驳回',
'value' => self::AUDIT_REJECT,
],
];
}
}

View File

@ -0,0 +1,52 @@
<?php
namespace app\common\enum\dealer\withdraw;
use app\common\enum\EnumBasics;
/**
* 枚举类:分销商提现审核状态
* Class ApplyStatus
* @package app\common\enum\dealer\withdraw
*/
class ApplyStatus extends EnumBasics
{
// 待审核
const AUDIT_WAIT = 10;
// 审核通过
const AUDIT_PASS = 20;
// 驳回
const AUDIT_REJECT = 30;
// 已打款
const AUDIT_PAID = 40;
/**
* 获取枚举类型值
* @return array
*/
public static function data()
{
return [
self::AUDIT_WAIT => [
'name' => '待审核',
'value' => self::AUDIT_WAIT,
],
self::AUDIT_PASS => [
'name' => '审核通过',
'value' => self::AUDIT_PASS,
],
self::AUDIT_REJECT => [
'name' => '驳回',
'value' => self::AUDIT_REJECT,
],
self::AUDIT_PAID => [
'name' => '已打款',
'value' => self::AUDIT_PAID,
],
];
}
}

View File

@ -0,0 +1,51 @@
<?php
namespace app\common\enum\sharing;
use app\common\enum\EnumBasics;
/**
* 拼团拼单状态
* Class ActiveStatus
* @package app\common\enum\sharing
*/
class ActiveStatus extends EnumBasics
{
// 未拼单
const ACTIVE_STATE_NORMAL = 0;
// 拼单中
const ACTIVE_STATE_BEGIN = 10;
// 拼单成功
const ACTIVE_STATE_SUCCESS = 20;
// 拼单失败
const ACTIVE_STATE_FAIL = 30;
/**
* 获取枚举数据
* @return array
*/
public static function data()
{
return [
self::ACTIVE_STATE_NORMAL => [
'name' => '未拼单',
'value' => self::ACTIVE_STATE_NORMAL,
],
self::ACTIVE_STATE_BEGIN => [
'name' => '拼单中',
'value' => self::ACTIVE_STATE_BEGIN,
],
self::ACTIVE_STATE_SUCCESS => [
'name' => '拼单成功',
'value' => self::ACTIVE_STATE_SUCCESS,
],
self::ACTIVE_STATE_FAIL => [
'name' => '拼单失败',
'value' => self::ACTIVE_STATE_FAIL,
],
];
}
}

View File

@ -25,7 +25,7 @@ class helper
}
/**
* 获取数组中指定的列
* 获取数组中指定的列 [支持多列]
* @param $source
* @param $columns
* @return array
@ -83,6 +83,21 @@ class helper
return $sum / 100;
}
/**
* 在二维数组中查找指定值
* @param array $array 二维数组
* @param string $searchIdx 查找的索引
* @param string $searchVal 查找的值
* @return bool
*/
public static function arraySearch($array, $searchIdx, $searchVal)
{
foreach ($array as $item) {
if ($item[$searchIdx] == $searchVal) return $item;
}
return false;
}
public static function setDataAttribute(&$source, $defaultData, $isArray = false)
{
if (!$isArray) $dataSource = [&$source]; else $dataSource = &$source;

View File

@ -123,6 +123,29 @@ class WxBase
return $result;
}
/**
* 模拟POST请求 [第二种方式, 用于兼容微信api]
* @param $url
* @param array $data
* @return mixed
*/
protected function post2($url, $data = [])
{
$header = [
'Content-Type: application/x-www-form-urlencoded'
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
/**
* 数组转json
* @param $data

View File

@ -0,0 +1,110 @@
<?php
namespace app\common\library\wechat;
/**
* 小程序订阅消息
* Class WxSubMsg
* @package app\common\library\wechat
*/
class WxSubMsg extends WxBase
{
/**
* 发送订阅消息
* @param $param
* @return bool
* @throws \app\common\exception\BaseException
*/
public function sendTemplateMessage($param)
{
// 微信接口url
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={$accessToken}";
// 构建请求
$params = [
'touser' => $param['touser'],
'template_id' => $param['template_id'],
'page' => $param['page'],
'data' => $param['data'],
];
$result = $this->post($url, $this->jsonEncode($params));
// 记录日志
$describe = '发送订阅消息';
$this->doLogs(compact('describe', 'url', 'params', 'result'));
// 返回结果
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ($response['errcode'] != 0) {
$this->error = $response['errmsg'];
return false;
}
return true;
}
/**
* 获取当前帐号下的模板列表
* @throws \app\common\exception\BaseException
*/
public function getTemplateList()
{
// 微信接口url
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate?access_token={$accessToken}";
// 执行post请求
$result = $this->get($url);
// 记录日志
$this->doLogs(['describe' => '获取当前帐号下的订阅消息模板列表', 'url' => $url, 'result' => $result]);
// 处理返回结果
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ($response['errcode'] != 0) {
$this->error = $response['errmsg'];
return false;
}
return $response;
}
/**
* 添加订阅消息模板
* [addTemplates 组合模板并添加至帐号下的个人模板库](订阅消息)
* @param int $tid 模板标题id
* @param array $kidList 模板关键词列表
* @param string $sceneDesc 服务场景描述
* @return bool
* @throws \app\common\exception\BaseException
*/
public function addTemplate($tid, $kidList, $sceneDesc)
{
// 微信接口url
$accessToken = $this->getAccessToken();
$url = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate?access_token={$accessToken}";
// 构建请求
$params = [
'tid' => $tid,
'kidList' => $kidList,
'sceneDesc' => $sceneDesc,
];
// 执行post请求
$result = $this->post2($url, $params);
// 记录日志
$this->doLogs(['describe' => '添加订阅消息模板', 'url' => $url, 'params' => $params, 'result' => $result]);
// 处理返回结果
$response = $this->jsonDecode($result);
if (!isset($response['errcode'])) {
$this->error = 'not found errcode';
return false;
}
if ($response['errcode'] != 0) {
$this->error = $response['errmsg'];
return false;
}
return $response;
}
}

View File

@ -3,7 +3,7 @@
namespace app\common\library\wechat;
/**
* 微信模板消息
* 微信模板消息 (废弃)
* Class WxTplMsg
* @package app\common\library\wechat
*/

View File

@ -3,6 +3,7 @@
namespace app\common\model;
use think\Cache;
use app\common\enum\Setting as SettingEnum;
use app\common\enum\DeliveryType as DeliveryTypeEnum;
/**
@ -98,6 +99,7 @@ class Setting extends BaseModel
public function defaultData($storeName = null)
{
return [
// 商城设置
'store' => [
'key' => 'store',
'describe' => '商城设置',
@ -113,6 +115,7 @@ class Setting extends BaseModel
]
],
],
// 交易设置
'trade' => [
'key' => 'trade',
'describe' => '交易设置',
@ -125,6 +128,7 @@ class Setting extends BaseModel
'freight_rule' => '10',
]
],
// 上传设置
'storage' => [
'key' => 'storage',
'describe' => '上传设置',
@ -154,6 +158,7 @@ class Setting extends BaseModel
]
],
],
// 短信通知
'sms' => [
'key' => 'sms',
'describe' => '短信通知',
@ -173,24 +178,26 @@ class Setting extends BaseModel
],
],
],
'tplMsg' => [
'key' => 'tplMsg',
'describe' => '模板消息',
'values' => [
'payment' => [
'is_enable' => '0',
'template_id' => '',
],
'delivery' => [
'is_enable' => '0',
'template_id' => '',
],
'refund' => [
'is_enable' => '0',
'template_id' => '',
],
],
],
// 模板消息
// 'tplMsg' => [
// 'key' => 'tplMsg',
// 'describe' => '模板消息',
// 'values' => [
// 'payment' => [
// 'is_enable' => '0',
// 'template_id' => '',
// ],
// 'delivery' => [
// 'is_enable' => '0',
// 'template_id' => '',
// ],
// 'refund' => [
// 'is_enable' => '0',
// 'template_id' => '',
// ],
// ],
// ],
// 小票打印机设置
'printer' => [
'key' => 'printer',
'describe' => '小票打印机设置',
@ -200,6 +207,7 @@ class Setting extends BaseModel
'order_status' => [], // 订单类型 10下单打印 20付款打印 30确认收货打印
],
],
// 满额包邮设置
'full_free' => [
'key' => 'full_free',
'describe' => '满额包邮设置',
@ -214,6 +222,7 @@ class Setting extends BaseModel
'notin_goods' => [], // 不参与包邮的商品 (商品id集)
],
],
// 用户充值设置
'recharge' => [
'key' => 'recharge',
'describe' => '用户充值设置',
@ -227,9 +236,10 @@ class Setting extends BaseModel
"4. 若有其它疑问可拨打客服电话400-000-1234", // 充值说明
],
],
'points' => [
'key' => 'points',
'describe' => '积分设置',
// 积分设置
SettingEnum::POINTS => [
'key' => SettingEnum::POINTS,
'describe' => SettingEnum::data()[SettingEnum::POINTS]['describe'],
'values' => [
'points_name' => '积分', // 积分名称自定义
'is_shopping_gift' => '0', // 是否开启购物送积分
@ -247,6 +257,64 @@ class Setting extends BaseModel
"d) 买家在完成该笔交易(订单状态为“已签收”)后才能得到此笔交易的相应积分,如购买商品参加店铺其他优惠,则优惠的金额部分不享受积分获取;",
],
],
// 订阅消息设置
SettingEnum::SUBMSG => [
'key' => SettingEnum::SUBMSG,
'describe' => SettingEnum::data()[SettingEnum::SUBMSG]['describe'],
'values' => [
// 订单消息
'order' => [
// 支付成功通知
'payment' => [
'template_id' => '',
'keywords' => ['character_string1', 'time2', 'amount4', 'thing3'],
'title' => '新订单提醒',
],
// 订单发货通知
'delivery' => [
'template_id' => '',
'keywords' => ['character_string1', 'thing2', 'name12', 'thing11', 'thing17'],
'title' => '订单发货通知',
],
// 售后状态通知
'refund' => [
'template_id' => '',
'keywords' => ['phrase1', 'thing6', 'character_string2', 'date3', 'thing4'],
'title' => '售后状态通知',
],
],
// 拼团消息
'sharing' => [
// 拼团进度通知
'active_status' => [
'template_id' => '',
'keywords' => ['thing1', 'amount5', 'number7', 'thing3', 'thing6'],
'title' => '拼团进度通知',
],
],
// 分销商消息
'dealer' => [
// 分销商入驻审核通知
'apply' => [
'template_id' => '',
'keywords' => ['date1', 'phrase2', 'date3', 'thing4'],
'title' => '代理商入驻审核通知',
],
// 提现成功通知
'withdraw_01' => [
'template_id' => '',
'keywords' => ['amount1', 'thing3', 'thing4'],
'title' => '提现成功通知',
],
// 提现失败通知
'withdraw_02' => [
'template_id' => '',
'keywords' => ['amount1', 'time3', 'thing4'],
'title' => '提现失败通知',
],
],
],
],
];
}

View File

@ -25,13 +25,13 @@ class Wxapp extends BaseModel
/**
* 获取小程序信息
* @param null $wxapp_id
* @param int|null $wxappId
* @return static|null
* @throws \think\exception\DbException
*/
public static function detail($wxapp_id = null)
public static function detail($wxappId = null)
{
return static::get($wxapp_id ?: []);
return static::get($wxappId ?: []);
}
/**

View File

@ -93,8 +93,6 @@ class Setting extends BaseModel
"每次砍价金额随机,可砍出最高商品日常价内的随机金额,参与好友越多越容易成功。\n\n" .
"以最终砍价后的优惠价格购买该商品,且用户须在活动时间结束之前进行支付购买,否则砍价商品价格将过期失效。\n\n" .
"商品库存有限,以前台展示的库存数量为准,先到先得。",
// 模板消息
'template_msg' => []
]
]
];

View File

@ -13,16 +13,6 @@ class Apply extends BaseModel
{
protected $name = 'dealer_apply';
/**
* 申请状态
* @var array
*/
public $applyStatus = [
10 => '待审核',
20 => '审核通过',
30 => '驳回',
];
/**
* 获取器:申请时间
* @param $value
@ -44,7 +34,7 @@ class Apply extends BaseModel
}
/**
* 关联推荐人
* 关联用户
* @return \think\model\relation\BelongsTo
*/
public function referee()
@ -53,6 +43,16 @@ class Apply extends BaseModel
->field(['user_id', 'nickName']);
}
/**
* 关联会员记录表
* @return \think\model\relation\BelongsTo
*/
public function user()
{
$module = self::getCalledModule() ?: 'common';
return $this->belongsTo("app\\{$module}\\model\\User");
}
/**
* 销商申请记录详情
* @param $where

View File

@ -348,14 +348,6 @@ class Setting extends BaseModel
'withdraw_apply' => self::$base_url . 'assets/api/dealer-bg.png',
],
],
'template_msg' => [
'key' => 'template_msg',
'describe' => '模板消息',
'values' => [
'apply_tpl' => '', // 分销商审核通知
'withdraw_tpl' => '', // 提现状态通知
]
],
'qrcode' => [
'key' => 'template_msg',
'describe' => '分销海报',

View File

@ -13,27 +13,6 @@ class Withdraw extends BaseModel
{
protected $name = 'dealer_withdraw';
/**
* 打款方式
* @var array
*/
public $payType = [
10 => '微信',
20 => '支付宝',
30 => '银行卡',
];
/**
* 申请状态
* @var array
*/
public $applyStatus = [
10 => '待审核',
20 => '审核通过',
30 => '驳回',
40 => '已打款',
];
/**
* 关联分销商用户表
* @return \think\model\relation\BelongsTo

View File

@ -5,6 +5,7 @@ namespace app\common\model\sharing;
use think\Hook;
use app\common\model\BaseModel;
use app\common\service\Message as MessageService;
use app\common\enum\sharing\ActiveStatus as ActiveStatusEnum;
/**
* 拼团拼单模型
@ -34,13 +35,7 @@ class Active extends BaseModel
*/
public function getStatusAttr($value)
{
$state = [
0 => '未拼单',
10 => '拼单中',
20 => '拼单成功',
30 => '拼单失败',
];
return ['text' => $state[$value], 'value' => $value];
return ['text' => ActiveStatusEnum::data()[$value]['name'], 'value' => $value];
}
/**
@ -157,13 +152,12 @@ class Active extends BaseModel
/**
* 更新拼单记录
* @param $user_id
* @param $order_id
* @param $userId
* @param $orderId
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function onUpdate($user_id, $order_id)
public function onUpdate($userId, $orderId)
{
// 验证当前拼单是否允许加入新成员
if (!$this->checkAllowJoin()) {
@ -172,8 +166,8 @@ class Active extends BaseModel
// 新增拼单成员记录
ActiveUsers::add([
'active_id' => $this['active_id'],
'order_id' => $order_id,
'user_id' => $user_id,
'order_id' => $orderId,
'user_id' => $userId,
'is_creator' => 0,
'wxapp_id' => $this['wxapp_id']
]);
@ -185,10 +179,13 @@ class Active extends BaseModel
'actual_people' => $actual_people,
'status' => $status
]);
// 拼单成功, 发送模板消息
// 拼单成功, 发送订阅消息
if ($status == 20) {
$model = static::detail($this['active_id']);
(new MessageService)->sharingActive($model, '拼团成功');
MessageService::send('sharing.active_status', [
'active' => $model,
'status' => ActiveStatusEnum::ACTIVE_STATE_SUCCESS,
]);
}
return true;
}

View File

@ -95,8 +95,6 @@ class Setting extends BaseModel
'rule_brief' => '好友拼单 · 人满发货 · 人不满退款',
// 拼团规则 详述
'rule_detail' => "开团:选择商品,点击“发起拼单”按钮,付款完成后即开团成功,就可以邀请小伙伴一起拼团啦;\n\n参团:进入朋友分享的页面,点击“立即参团”按钮,付款完成后参团成功,在有效时间内凑齐人数即成团,就可以等待收货喽;\n\n成团:在开团或参团成功后,点击“立即分享”将页面分享给好友,在有效时间内凑齐人数即成团,成团后商家开始发货;\n\n组团失败:在有效时间内未凑齐人数,即组团失败,组团失败后订单所付款将原路退回到支付账户。",
// 拼单状态模板消息id
'tpl_msg_id' => '',
]
]
];

View File

@ -2,351 +2,47 @@
namespace app\common\service;
//use app\common\model\User as UserModel;
use app\common\model\Wxapp as WxappModel;
use app\common\model\Setting as SettingModel;
//use app\common\model\dealer\Setting as DealerSettingModel;
//use app\common\model\sharing\Setting as SharingSettingModel;
//use app\common\service\wxapp\FormId as FormIdService;
use app\common\enum\OrderType as OrderTypeEnum;
use app\common\library\wechat\WxTplMsg;
use app\common\library\sms\Driver as SmsDriver;
/**
* 消息通知服务
* Class Message
* @package app\common\service
*/
class Message
class Message extends Basics
{
/**
* 订单支付成功后通知
* @param \think\Model $order
* @param int $orderType 订单类型 (10商城订单 20拼团订单)
* @return bool
// * @throws \app\common\exception\BaseException
* @throws \think\Exception
// * @throws \think\exception\DbException
* 场景列表
* [场景名称] => [场景类]
* @var array
*/
public function payment($order, $orderType = OrderTypeEnum::MASTER)
{
// // 1. 微信模板消息
// $template = SettingModel::getItem('tplMsg', $order['wxapp_id'])['payment'];
// if (!$template['is_enable'] || empty($template['template_id'])) {
// return false;
// }
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($order['user_id'])) {
// return false;
// }
// // 页面链接
// $urls = [
// OrderTypeEnum::MASTER => 'pages/order/detail',
// OrderTypeEnum::SHARING => 'pages/sharing/order/detail/detail',
// ];
// // 发送模板消息
// $status = $this->sendTemplateMessage($order['wxapp_id'], [
// 'touser' => $order['user']['open_id'],
// 'template_id' => $template['template_id'],
// 'page' => $urls[$orderType] . '?order_id=' . $order['order_id'],
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 订单编号
// 'keyword1' => $order['order_no'],
// // 支付时间
// 'keyword2' => date('Y-m-d H:i:s', $order['pay_time']),
// // 订单金额
// 'keyword3' => $order['pay_price'],
// // 商品名称
// 'keyword4' => $this->formatGoodsName($order['goods']),
// ]
// ]);
// // 标记formid已使用
// $status === true && FormIdService::setIsUsed($formId['id']);
private static $sceneList = [
// 订单支付成功
'order.payment' => 'app\common\service\message\order\Payment',
// 订单发货
'order.delivery' => 'app\common\service\message\order\Delivery',
// 订单退款
'order.refund' => 'app\common\service\message\order\Refund',
// 2. 商家短信通知
$smsConfig = SettingModel::getItem('sms', $order['wxapp_id']);
$SmsDriver = new SmsDriver($smsConfig);
return $SmsDriver->sendSms('order_pay', ['order_no' => $order['order_no']]);
}
// 拼团进度通知
'sharing.active_status' => 'app\common\service\message\sharing\ActiveStatus',
// 分销商入驻通知
'dealer.apply' => 'app\common\service\message\dealer\Apply',
// 分销商提现通知
'dealer.withdraw' => 'app\common\service\message\dealer\Withdraw',
];
/**
* 后台发货通知
* @param \think\Model $order
* @param int $orderType 订单类型 (10商城订单 20拼团订单)
* 发送消息通知
* @param string $sceneName 场景名称
* @param array $param 参数
* @return bool
// * @throws \app\common\exception\BaseException
// * @throws \think\Exception
// * @throws \think\exception\DbException
*/
public function delivery($order, $orderType = OrderTypeEnum::MASTER)
public static function send($sceneName, $param)
{
return true;
// // 微信模板消息
// $template = SettingModel::getItem('tplMsg', $order['wxapp_id'])['delivery'];
// if (!$template['is_enable'] || empty($template['template_id'])) {
// return false;
// }
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($order['user_id'])) {
// return false;
// }
// // 页面链接
// $urls = [
// OrderTypeEnum::MASTER => 'pages/order/detail',
// OrderTypeEnum::SHARING => 'pages/sharing/order/detail/detail',
// ];
// // 发送模板消息
// $status = $this->sendTemplateMessage($order['wxapp_id'], [
// 'touser' => $order['user']['open_id'],
// 'template_id' => $template['template_id'],
// 'page' => $urls[$orderType] . '?order_id=' . $order['order_id'],
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 订单编号
// 'keyword1' => $order['order_no'],
// // 商品信息
// 'keyword2' => $this->formatGoodsName($order['goods']),
// // 收货人
// 'keyword3' => $order['address']['name'],
// // 收货地址
// 'keyword4' => implode('', $order['address']['region']) . $order['address']['detail'],
// // 物流公司
// 'keyword5' => $order['express']['express_name'],
// // 物流单号
// 'keyword6' => $order['express_no'],
// ]
// ]);
// // 标记formid已使用
// $status === true && FormIdService::setIsUsed($formId['id']);
// return $status;
}
/**
* 后台售后单状态通知
* @param \think\Model $refund
* @param $order_no
* @param int $orderType 订单类型 (10商城订单 20拼团订单)
* @return bool
// * @throws \app\common\exception\BaseException
// * @throws \think\Exception
// * @throws \think\exception\DbException
*/
public function refund($refund, $order_no, $orderType = OrderTypeEnum::MASTER)
{
return true;
// // 微信模板消息
// $template = SettingModel::getItem('tplMsg', $refund['wxapp_id'])['refund'];
// if (!$template['is_enable'] || empty($template['template_id'])) {
// return false;
// }
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($refund['user_id'])) {
// return false;
// }
// // 页面链接
// $urls = [
// OrderTypeEnum::MASTER => 'pages/order/refund/index',
// OrderTypeEnum::SHARING => 'pages/sharing/order/refund/index',
// ];
// // 发送模板消息
// $status = $this->sendTemplateMessage($refund['wxapp_id'], [
// 'touser' => $refund['user']['open_id'],
// 'template_id' => $template['template_id'],
// 'page' => $urls[$orderType],
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 售后类型
// 'keyword1' => $refund['type']['text'],
// // 状态
// 'keyword2' => $refund['status']['text'],
// // 订单号
// 'keyword3' => $order_no,
// // 商品名称
// 'keyword4' => $refund['order_goods']['goods_name'],
// // 申请时间
// 'keyword5' => $refund['create_time'],
// // 申请原因
// 'keyword6' => $refund['apply_desc'],
// ]
// ]);
// // 标记formid已使用
// FormIdService::setIsUsed($formId['id']);
// return $status;
}
/**
* 拼团拼单状态通知
* @param \app\common\model\sharing\Active $active
* @param string $status_text
* @return bool
// * @throws \app\common\exception\BaseException
// * @throws \think\exception\DbException
*/
public function sharingActive($active, $status_text)
{
return true;
// // 微信模板消息
// $config = SharingSettingModel::getItem('basic', $active['wxapp_id']);
// if (empty($config['tpl_msg_id'])) {
// return false;
// }
// foreach ($active['users'] as $item) {
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($item['user']['user_id'])) {
// continue;
// }
// // 发送模板消息
// $this->sendTemplateMessage($active['wxapp_id'], [
// 'touser' => $item['user']['open_id'],
// 'template_id' => $config['tpl_msg_id'],
// 'page' => 'pages/sharing/active/index?active_id=' . $active['active_id'],
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 订单编号
// 'keyword1' => $item['sharing_order']['order_no'],
// // 商品名称
// 'keyword2' => $active['goods']['goods_name'],
// // 拼团价格
// 'keyword3' => $item['sharing_order']['pay_price'],
// // 拼团人数
// 'keyword4' => $active['people'],
// // 拼团时间
// 'keyword5' => $item['create_time'],
// // 拼团结果
// 'keyword6' => $status_text,
// ]
// ]);
// // 标记formid已使用
// FormIdService::setIsUsed($formId['id']);
// }
// return true;
}
/**
* 分销商提现审核通知
* @param \app\common\model\dealer\Withdraw $withdraw
* @return bool
// * @throws \app\common\exception\BaseException
// * @throws \think\exception\DbException
*/
public function withdraw($withdraw)
{
return true;
// // 模板消息id
// $template = DealerSettingModel::getItem('template_msg', $withdraw['wxapp_id']);
// if (empty($template['withdraw_tpl'])) {
// return false;
// }
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($withdraw['user_id'])) {
// return false;
// }
// // 获取用户信息
// $user = UserModel::detail($withdraw['user_id']);
// // 发送模板消息
// $remark = '无';
// if ($withdraw['apply_status'] == 30) {
// $remark = $withdraw['reject_reason'];
// }
// $status = $this->sendTemplateMessage($withdraw['wxapp_id'], [
// 'touser' => $user['open_id'],
// 'template_id' => $template['withdraw_tpl'],
// 'page' => 'pages/dealer/withdraw/list/list',
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 提现时间
// 'keyword1' => $withdraw['create_time'],
// // 提现方式
// 'keyword2' => $withdraw['pay_type']['text'],
// // 提现金额
// 'keyword3' => $withdraw['money'],
// // 提现状态
// 'keyword4' => $withdraw->applyStatus[$withdraw['apply_status']],
// // 备注
// 'keyword5' => $remark,
// ]
// ]);
// // 标记formid已使用
// FormIdService::setIsUsed($formId['id']);
// return $status;
}
/**
* 分销商入驻审核通知
* @param \app\common\model\dealer\Apply $dealer
* @return bool
// * @throws \app\common\exception\BaseException
// * @throws \think\exception\DbException
*/
public function dealer($dealer)
{
return true;
// // 模板消息id
// $template = DealerSettingModel::getItem('template_msg', $dealer['wxapp_id']);
// if (empty($template['apply_tpl'])) {
// return false;
// }
// // 获取可用的formid
// if (!$formId = FormIdService::getAvailableFormId($dealer['user_id'])) {
// return false;
// }
// // 获取用户信息
// $user = UserModel::detail($dealer['user_id']);
// // 发送模板消息
// $remark = '分销商入驻审核通知';
// if ($dealer['apply_status'] == 30) {
// $remark .= "\n\n驳回原因" . $dealer['reject_reason'];
// }
// $status = $this->sendTemplateMessage($dealer['wxapp_id'], [
// 'touser' => $user['open_id'],
// 'template_id' => $template['apply_tpl'],
// 'page' => 'pages/dealer/index/index',
// 'form_id' => $formId['form_id'],
// 'data' => [
// // 申请时间
// 'keyword1' => $dealer['apply_time'],
// // 审核状态
// 'keyword2' => $dealer->applyStatus[$dealer['apply_status']],
// // 审核时间
// 'keyword3' => $dealer['audit_time'],
// // 备注信息
// 'keyword4' => $remark,
// ]
// ]);
// // 标记formid已使用
// FormIdService::setIsUsed($formId['id']);
// return $status;
}
/**
* 发送模板消息
* @param $wxappId
* @param $params
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
private function sendTemplateMessage($wxappId, $params)
{
// 微信模板消息
$wxConfig = WxappModel::getWxappCache($wxappId);
$WxTplMsg = new WxTplMsg($wxConfig['app_id'], $wxConfig['app_secret']);
return $WxTplMsg->sendTemplateMessage($params);
}
/**
* 格式化商品名称
* @param $goodsData
* @return string
*/
private function formatGoodsName($goodsData)
{
$str = '';
foreach ($goodsData as $goods) {
$str .= $goods['goods_name'] . ' ';
}
return $str;
if (!isset(self::$sceneList[$sceneName]))
return false;
$className = self::$sceneList[$sceneName];
return class_exists($className) ? (new $className)->send($param) : false;
}
}

View File

@ -0,0 +1,71 @@
<?php
namespace app\common\service\message;
use app\common\model\Wxapp as WxappModel;
use app\common\model\Setting as SettingModel;
use app\common\library\sms\Driver as SmsDriver;
use app\common\library\wechat\WxSubMsg;
/**
* 消息通知服务[基类]
* Class Basics
* @package app\common\service\message
*/
abstract class Basics extends \app\common\service\Basics
{
// 参数列表
protected $param = [];
/**
* 发送消息通知
* @param array $param 参数
* @return mixed
*/
abstract public function send($param);
/**
* 发送短信提醒
* @param $msgType
* @param $templateParams
* @param $wxappId
* @return bool
* @throws \think\Exception
*/
protected function sendSms($msgType, $templateParams, $wxappId)
{
$smsConfig = SettingModel::getItem('sms', $wxappId);
return (new SmsDriver($smsConfig))->sendSms($msgType, $templateParams);
}
/**
* 发送微信订阅消息
* @param $wxappId
* @param $params
* @return mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
protected function sendWxSubMsg($wxappId, $params)
{
// 获取小程序配置
$wxConfig = WxappModel::getWxappCache($wxappId);
// 请求微信api执行发送
$WxSubMsg = new WxSubMsg($wxConfig['app_id'], $wxConfig['app_secret']);
return $WxSubMsg->sendTemplateMessage($params);
}
/**
* 字符串截取前20字符
* [用于兼容thing数据类型]
* @param $content
* @param int $length
* @return bool|string
*/
protected function getSubstr($content, $length = 20)
{
return str_substr($content, $length);
}
}

View File

@ -0,0 +1,90 @@
<?php
namespace app\common\service\message\dealer;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\dealer\ApplyStatus as ApplyStatusEnum;
/**
* 消息通知服务 [分销商入驻]
* Class Apply
* @package app\common\service\message\dealer
*/
class Apply extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'apply' => [], // 申请记录
'user' => [], // 用户信息
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
$applyInfo = $this->param['apply'];
$userInfo = $this->param['user'];
$wxappId = $applyInfo['wxapp_id'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $wxappId)['dealer']['apply'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg($wxappId, [
'touser' => $userInfo['open_id'],
'template_id' => $template['template_id'],
'page' => 'pages/dealer/index/index',
'data' => [
// 申请时间
$template['keywords'][0] => ['value' => $applyInfo['apply_time']],
// 审核状态
$template['keywords'][1] => ['value' => ApplyStatusEnum::data()[$applyInfo['apply_status']]['name']],
// 审核时间
$template['keywords'][2] => ['value' => $applyInfo['audit_time']],
// 备注信息
$template['keywords'][3] => ['value' => $this->getRemarkValue($applyInfo)],
]
]);
}
/**
* 备注信息
* @param $applyInfo
* @return string
*/
private function getRemarkValue($applyInfo)
{
$remark = '分销商入驻审核通知';
if ($applyInfo['apply_status'] == 30) {
$remark .= "\n驳回原因:{$applyInfo['reject_reason']}";
}
return $this->getSubstr($remark);
}
}

View File

@ -0,0 +1,122 @@
<?php
namespace app\common\service\message\dealer;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\dealer\withdraw\ApplyStatus as ApplyStatusEnum;
/**
* 消息通知服务 [分销商提现]
* Class Withdraw
* @package app\common\service\message\dealer
*/
class Withdraw extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'withdraw' => [], // 提现记录
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
$withdrawInfo = $this->param['withdraw'];
$userInfo = $this->param['user'];
$wxappId = $withdrawInfo['wxapp_id'];
// 根据提现状态获取对应的消息模板
$template = $this->getTemplateByStatus($withdrawInfo);
if ($template === false) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg($wxappId, [
'touser' => $userInfo['open_id'],
'template_id' => $template['template_id'],
'page' => 'pages/dealer/index/index',
'data' => $this->getTemplateData($withdrawInfo, $template)
]);
}
/**
* 生成消息内容
* @param $withdrawInfo
* @param $template
* @return array
*/
private function getTemplateData($withdrawInfo, $template)
{
if ($withdrawInfo['apply_status'] == ApplyStatusEnum::AUDIT_PASS) {
return [
// 提现金额
$template['keywords'][0] => ['value' => $withdrawInfo['money']],
// 打款方式
$template['keywords'][1] => ['value' => $withdrawInfo['pay_type']['text']],
// 打款原因
$template['keywords'][2] => ['value' => '分销商提现'],
];
}
if ($withdrawInfo['apply_status'] == ApplyStatusEnum::AUDIT_REJECT) {
return [
// 提现金额
$template['keywords'][0] => ['value' => $withdrawInfo['money']],
// 申请时间
$template['keywords'][1] => ['value' => $withdrawInfo['create_time']],
// 原因
$template['keywords'][2] => ['value' => $this->getSubstr($withdrawInfo['reject_reason'])],
];
}
return [];
}
/**
* 根据提现状态获取对应的消息模板
* @param $withdrawInfo
* @return bool
*/
private function getTemplateByStatus($withdrawInfo)
{
$wxappId = $withdrawInfo['wxapp_id'];
// 获取订阅消息配置
$templateGroup = SettingModel::getItem('submsg', $wxappId)['dealer'];
if (
$withdrawInfo['apply_status'] == ApplyStatusEnum::AUDIT_PASS
&& !empty($templateGroup['withdraw_01']['template_id'])
) {
return $templateGroup['withdraw_01'];
}
if (
$withdrawInfo['apply_status'] == ApplyStatusEnum::AUDIT_REJECT
&& !empty($templateGroup['withdraw_02']['template_id'])
) {
return $templateGroup['withdraw_02'];
}
return false;
}
}

View File

@ -0,0 +1,116 @@
<?php
namespace app\common\service\message\order;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\OrderType as OrderTypeEnum;
/**
* 消息通知服务 [订单发货]
* Class Delivery
* @package app\common\service\message\order
*/
class Delivery extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'order' => [],
'order_type' => OrderTypeEnum::MASTER,
];
/**
* 订单页面链接
* @var array
*/
private $pageUrl = [
OrderTypeEnum::MASTER => 'pages/order/detail',
OrderTypeEnum::SHARING => 'pages/sharing/order/detail/detail',
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
$orderInfo = $this->param['order'];
$orderType = $this->param['order_type'];
$wxappId = $orderInfo['wxapp_id'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $wxappId)['order']['delivery'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg($wxappId, [
'touser' => $orderInfo['user']['open_id'],
'template_id' => $template['template_id'],
'page' => "{$this->pageUrl[$orderType]}?order_id={$orderInfo['order_id']}",
'data' => [
// 订单号
$template['keywords'][0] => ['value' => $orderInfo['order_no']],
// 商品名称
$template['keywords'][1] => ['value' => $this->getFormatGoodsName($orderInfo['goods'])],
// 收货人
$template['keywords'][2] => ['value' => $orderInfo['address']['name']],
// 收货地址
$template['keywords'][3] => ['value' => $this->getFormatAddress($orderInfo)],
// 物流公司
$template['keywords'][4] => ['value' => $this->getFormatExpressName($orderInfo)],
]
]);
}
/**
* 格式化物流公司
* @param $orderInfo
* @return mixed
*/
private function getFormatExpressName($orderInfo)
{
return $this->getSubstr($orderInfo['express']['express_name']);
}
/**
* 格式化用户收货地址
* @param $orderInfo
* @return string
*/
private function getFormatAddress($orderInfo)
{
return implode('', $orderInfo['address']['region']) . $orderInfo['address']['detail'];
}
/**
* 格式化商品名称
* @param $goodsData
* @return string
*/
private function getFormatGoodsName($goodsData)
{
return $this->getSubstr($goodsData[0]['goods_name']);
}
}

View File

@ -0,0 +1,107 @@
<?php
namespace app\common\service\message\order;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\OrderType as OrderTypeEnum;
/**
* 消息通知服务 [订单支付成功]
* Class Payment
* @package app\common\service\message\order
*/
class Payment extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'order' => [],
'order_type' => OrderTypeEnum::MASTER,
];
/**
* 订单页面链接
* @var array
*/
private $pageUrl = [
OrderTypeEnum::MASTER => 'pages/order/detail',
OrderTypeEnum::SHARING => 'pages/sharing/order/detail/detail',
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 短信通知商家
$this->onSendSms();
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 短信通知商家
* @return bool
* @throws \think\Exception
*/
private function onSendSms()
{
$orderInfo = $this->param['order'];
$wxappId = $orderInfo['wxapp_id'];
return $this->sendSms('order_pay', ['order_no' => $orderInfo['order_no']], $wxappId);
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
$orderInfo = $this->param['order'];
$orderType = $this->param['order_type'];
$wxappId = $orderInfo['wxapp_id'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $wxappId)['order']['payment'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg($wxappId, [
'touser' => $orderInfo['user']['open_id'],
'template_id' => $template['template_id'],
'page' => "{$this->pageUrl[$orderType]}?order_id={$orderInfo['order_id']}",
'data' => [
// 订单编号
$template['keywords'][0] => ['value' => $orderInfo['order_no']],
// 下单时间
$template['keywords'][1] => ['value' => format_time($orderInfo['pay_time'])],
// 订单金额
$template['keywords'][2] => ['value' => $orderInfo['pay_price']],
// 商品名称
$template['keywords'][3] => ['value' => $this->getFormatGoodsName($orderInfo['goods'])],
]
]);
}
/**
* 格式化商品名称
* @param $goodsData
* @return string
*/
private function getFormatGoodsName($goodsData)
{
return $this->getSubstr($goodsData[0]['goods_name']);
}
}

View File

@ -0,0 +1,89 @@
<?php
namespace app\common\service\message\order;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\OrderType as OrderTypeEnum;
/**
* 消息通知服务 [订单售后]
* Class Refund
* @package app\common\service\message\order
*/
class Refund extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'refund' => [], // 退款单信息
'order_no' => [], // 订单信息
'order_type' => OrderTypeEnum::MASTER, // 订单类型
];
/**
* 订单页面链接
* @var array
*/
private $pageUrl = [
OrderTypeEnum::MASTER => 'pages/order/refund/index',
OrderTypeEnum::SHARING => 'pages/sharing/order/refund/index',
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
$refundInfo = $this->param['refund'];
$orderNo = $this->param['order_no'];
$orderType = $this->param['order_type'];
$wxappId = $refundInfo['wxapp_id'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $wxappId)['order']['refund'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
return $this->sendWxSubMsg($wxappId, [
'touser' => $refundInfo['user']['open_id'],
'template_id' => $template['template_id'],
'page' => "{$this->pageUrl[$orderType]}",
'data' => [
// 售后类型
$template['keywords'][0] => ['value' => $refundInfo['type']['text']],
// 状态
$template['keywords'][1] => ['value' => $refundInfo['status']['text']],
// 订单编号
$template['keywords'][2] => ['value' => $orderNo],
// 申请时间
$template['keywords'][3] => ['value' => $refundInfo['create_time']],
// 申请原因
$template['keywords'][4] => ['value' => $this->getSubstr($refundInfo['apply_desc'])],
]
]);
}
}

View File

@ -0,0 +1,82 @@
<?php
namespace app\common\service\message\sharing;
use app\common\service\message\Basics;
use app\common\model\Setting as SettingModel;
use app\common\enum\sharing\ActiveStatus as ActiveStatusEnum;
/**
* 消息通知服务 [拼团进度]
* Class ActiveStatus
* @package app\common\service\message\sharing
*/
class ActiveStatus extends Basics
{
/**
* 参数列表
* @var array
*/
protected $param = [
'active' => [], // 拼单详情
'status' => false, // 拼单状态
];
/**
* 发送消息通知
* @param array $param
* @return mixed|void
* @throws \think\Exception
*/
public function send($param)
{
// 记录参数
$this->param = $param;
// 微信订阅消息通知用户
$this->onSendWxSubMsg();
}
/**
* 微信订阅消息通知用户
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function onSendWxSubMsg()
{
// 拼单详情
$activeInfo = $this->param['active'];
$status = $this->param['status'];
$wxappId = $activeInfo['wxapp_id'];
// 获取订阅消息配置
$template = SettingModel::getItem('submsg', $wxappId)['sharing']['active_status'];
if (empty($template['template_id'])) {
return false;
}
// 发送订阅消息
foreach ($activeInfo['users'] as $item) {
$this->sendWxSubMsg($wxappId, [
'touser' => $item['user']['open_id'],
'template_id' => $template['template_id'],
'page' => "pages/sharing/active/index?active_id={$activeInfo['active_id']}",
'data' => [
// 拼团商品
$template['keywords'][0] => ['value' => str_substr($activeInfo['goods']['goods_name'], 20)],
// 拼团价格
$template['keywords'][1] => ['value' => $item['sharing_order']['pay_price']],
// 成团人数
$template['keywords'][2] => ['value' => $activeInfo['people']],
// 拼团进度
$template['keywords'][3] => ['value' => "已有{$activeInfo['actual_people']}人参与"],
// 温馨提示
$template['keywords'][4] => ['value' => ActiveStatusEnum::data()[$status]['name']],
]
]);
}
return true;
}
}

View File

@ -25,7 +25,7 @@ class Refund
* @throws \think\exception\DbException
* @throws \app\common\exception\BaseException
*/
public function execute(&$order, $money = null)
public function execute($order, $money = null)
{
// 退款金额,如不指定则默认为订单实付款金额
is_null($money) && $money = $order['pay_price'];

View File

@ -44,7 +44,7 @@ class Setting extends Controller
}
/**
* 模板消息
* 发送订阅消息
* @return mixed
* @throws \think\exception\DbException
*/

View File

@ -29,10 +29,8 @@ class Apply extends Controller
/**
* 分销商审核
* @param $apply_id
* @return array
* @throws \app\common\exception\BaseException
* @return array|bool
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function submit($apply_id)
{

View File

@ -33,7 +33,6 @@ class Withdraw extends Controller
* 提现审核
* @param $id
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function submit($id)
@ -65,6 +64,7 @@ class Withdraw extends Controller
* @param $id
* @return array|bool
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function wechat_pay($id)

View File

@ -49,7 +49,7 @@ class Room extends Controller
*/
public function settop($room_id, $is_top)
{
// 商品详情
// 直播间详情
$model = LiveRoomModel::detail($room_id);
if (!$model->setIsTop($is_top)) {
return $this->renderError('操作失败');

View File

@ -7,7 +7,7 @@ use app\store\model\wxapp\Formid as FormidModel;
use app\store\service\wxapp\Message as MessageService;
/**
* 消息推送
* 消息推送 (废弃)
* Class Push
* @package app\store\controller\market
*/
@ -17,6 +17,7 @@ class Push extends Controller
* 发送消息
* @return array|mixed
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function send()

View File

@ -0,0 +1,50 @@
<?php
namespace app\store\controller\wxapp;
use app\store\controller\Controller;
use app\store\model\Setting as SettingModel;
use app\store\service\wxapp\SubMsg as SubMsgService;
/**
* 小程序订阅消息设置
* Class Submsg
* @package app\store\controller\wxapp
*/
class Submsg extends Controller
{
/**
* 小程序订阅消息设置
* @return array|bool|mixed
* @throws \think\exception\DbException
*/
public function index()
{
if (!$this->request->isAjax()) {
$values = SettingModel::getItem('submsg');
return $this->fetch('index', compact('values'));
}
$model = new SettingModel;
if ($model->edit('submsg', $this->postData('submsg'))) {
return $this->renderSuccess('操作成功');
}
return $this->renderError($model->getError() ?: '操作失败');
}
/**
* 一键添加订阅消息
* @return array
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function shuttle()
{
$SubMsgService = new SubMsgService;
if ($SubMsgService->shuttle()) {
return $this->renderSuccess('操作成功');
}
return $this->renderError($SubMsgService->getError() ?: '操作失败');
}
}

View File

@ -360,6 +360,13 @@ return [
]
]
],
[
'name' => '订阅消息',
'index' => 'wxapp.submsg/index',
'uris' => [
'wxapp.submsg/index',
]
],
[
'name' => '帮助中心',
'index' => 'wxapp.help/index',
@ -607,15 +614,15 @@ return [
'name' => '短信通知',
'index' => 'setting/sms'
],
[
'name' => '模板消息',
'index' => 'setting/tplmsg',
'uris' => [
'setting/tplmsg',
'setting.help/tplmsg'
],
],
// [
// 'name' => '模板消息',
// 'index' => 'setting/tplmsg',
// 'uris' => [
// 'setting/tplmsg',
// 'setting.help/tplmsg'
//
// ],
// ],
[
'name' => '退货地址',
'index' => 'setting.address/index',

View File

@ -249,19 +249,17 @@ class Order extends OrderModel
/**
* 确认发货后发送消息通知
* @param array|\think\Collection $orderList
* @param $orderList
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function sendDeliveryMessage($orderList)
{
// 实例化消息通知服务类
$Service = new MessageService;
foreach ($orderList as $item) {
// 发送消息通知
$Service->delivery($item, OrderTypeEnum::MASTER);
foreach ($orderList as $item) {
MessageService::send('order.delivery', [
'order' => $item,
'order_type' => OrderTypeEnum::MASTER,
]);
}
return true;
}

View File

@ -59,7 +59,6 @@ class OrderRefund extends OrderRefundModel
* 商家审核
* @param $data
* @return bool
* @throws \think\exception\PDOException
*/
public function audit($data)
{
@ -71,8 +70,7 @@ class OrderRefund extends OrderRefundModel
$this->error = '请选择退货地址';
return false;
}
$this->startTrans();
try {
$this->transaction(function () use ($data) {
// 拒绝申请, 标记售后单状态为已拒绝
$data['is_agree'] == 20 && $data['status'] = 10;
// 同意换货申请, 标记售后单状态为已完成
@ -81,21 +79,18 @@ class OrderRefund extends OrderRefundModel
$this->allowField(true)->save($data);
// 同意售后申请, 记录退货地址
if ($data['is_agree'] == 10) {
$model = new OrderRefundAddress;
$model->add($this['order_refund_id'], $data['address_id']);
(new OrderRefundAddress)->add($this['order_refund_id'], $data['address_id']);
}
// 订单详情
$order = Order::detail($this['order_id']);
// 发送模板消息
(new MessageService)->refund(self::detail($this['order_refund_id']), $order['order_no'], OrderTypeEnum::MASTER);
// 事务提交
$this->commit();
// 发送消息通知
MessageService::send('order.refund', [
'refund' => $this, // 退款单信息
'order_no' => $order['order_no'], // 订单信息
'order_type' => OrderTypeEnum::MASTER, // 订单类型
]);
});
return true;
} catch (\Exception $e) {
$this->error = $e->getMessage();
$this->rollback();
return false;
}
}
/**
@ -126,8 +121,12 @@ class OrderRefund extends OrderRefundModel
}
// 执行原路退款
(new RefundService)->execute($order, $data['refund_money']);
// 发送模板消息
(new MessageService)->refund(self::detail($this['order_refund_id']), $order['order_no'], OrderTypeEnum::MASTER);
// 发送消息通知
MessageService::send('order.refund', [
'refund' => $this, // 退款单信息
'order_no' => $order['order_no'], // 订单信息
'order_type' => OrderTypeEnum::MASTER, // 订单类型
]);
});
return true;
}

View File

@ -2,8 +2,8 @@
namespace app\store\model;
use app\common\model\Wxapp as WxappModel;
use think\Cache;
use app\common\model\Wxapp as WxappModel;
/**
* 微信小程序模型
@ -65,40 +65,6 @@ class Wxapp extends WxappModel
return true;
}
/**
* 记录图片信息
* @param $wxapp_id
* @param $oldFileId
* @param $newFileName
* @param $fromType
* @return int|mixed
*/
private function uploadImage($wxapp_id, $oldFileId, $newFileName, $fromType)
{
// $UploadFile = new UploadFile;
$UploadFileUsed = new UploadFileUsed;
if ($oldFileId > 0) {
// 获取原图片path
$oldFileName = UploadFile::getFileName($oldFileId);
// 新文件与原来路径一致, 代表用户未修改, 不做更新
if ($newFileName === $oldFileName)
return $oldFileId;
// 删除原文件使用记录
$UploadFileUsed->remove('service', $oldFileId);
}
// 删除图片
if (empty($newFileName)) return 0;
// 查询新文件file_id
$fileId = UploadFile::getFildIdByName($newFileName);
// 添加文件使用记录
$UploadFileUsed->add([
'file_id' => $fileId,
'wxapp_id' => $wxapp_id,
'from_type' => $fromType
]);
return $fileId;
}
/**
* 删除wxapp缓存
* @return bool

View File

@ -3,7 +3,8 @@
namespace app\store\model\dealer;
use app\common\model\dealer\Apply as ApplyModel;
use app\common\service\Message;
use app\common\service\Message as MessageService;
use app\common\enum\dealer\ApplyStatus as ApplyStatusEnum;
/**
* 分销商入驻申请模型
@ -38,18 +39,15 @@ class Apply extends ApplyModel
* 分销商入驻审核
* @param $data
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function submit($data)
{
if ($data['apply_status'] == '30' && empty($data['reject_reason'])) {
if ($data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT && empty($data['reject_reason'])) {
$this->error = '请填写驳回原因';
return false;
}
$this->startTrans();
if ($data['apply_status'] == '20') {
$this->transaction(function () use ($data) {
if ($data['apply_status'] == ApplyStatusEnum::AUDIT_PASS) {
// 新增分销商用户
User::add($this['user_id'], [
'real_name' => $this['real_name'],
@ -60,9 +58,12 @@ class Apply extends ApplyModel
// 更新申请记录
$data['audit_time'] = time();
$this->allowField(true)->save($data);
// 发送模板消息
(new Message)->dealer($this);
$this->commit();
// 发送订阅消息
MessageService::send('dealer.apply', [
'apply' => $this, // 申请记录
'user' => $this['user'], // 用户信息
]);
});
return true;
}

View File

@ -25,7 +25,6 @@ class Setting extends SettingModel
'words' => '自定义文字',
'license' => '申请协议',
'background' => '页面背景图',
'template_msg' => '模板消息',
'qrcode' => '分销海报',
];

View File

@ -2,11 +2,13 @@
namespace app\store\model\dealer;
use app\common\service\Message;
use app\common\service\Order as OrderService;
use app\common\library\wechat\WxPay;
use app\store\model\User as UserModel;
use app\store\model\Wxapp as WxappModel;
use app\common\model\dealer\Withdraw as WithdrawModel;
use app\common\library\wechat\WxPay;
use app\common\service\Order as OrderService;
use app\common\service\Message as MessageService;
use app\common\enum\dealer\withdraw\ApplyStatus as ApplyStatusEnum;
/**
* 分销商提现明细模型
@ -32,7 +34,7 @@ class Withdraw extends WithdrawModel
*/
public function getPayTypeAttr($value)
{
return ['text' => $this->payType[$value], 'value' => $value];
return ['text' => ApplyStatusEnum::data()[$value]['name'], 'value' => $value];
}
/**
@ -68,34 +70,40 @@ class Withdraw extends WithdrawModel
* 分销商提现审核
* @param $data
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\exception\DbException
*/
public function submit($data)
{
if ($data['apply_status'] == '30' && empty($data['reject_reason'])) {
if (
$data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT
&& empty($data['reject_reason'])
) {
$this->error = '请填写驳回原因';
return false;
}
$this->transaction(function () use ($data) {
// 更新申请记录
$data['audit_time'] = time();
$this->allowField(true)->save($data);
// 提现驳回:解冻分销商资金
$data['apply_status'] == '30' && User::backFreezeMoney($this['user_id'], $this['money']);
// 发送模板消息
(new Message)->withdraw($this);
if ($data['apply_status'] == ApplyStatusEnum::AUDIT_REJECT) {
User::backFreezeMoney($this['user_id'], $this['money']);
}
// 发送消息通知
MessageService::send('dealer.withdraw', [
'withdraw' => $this,
'user' => UserModel::detail($this['user_id']),
]);
});
return true;
}
/**
* 确认已打款
* @return bool
* @throws \think\exception\PDOException
*/
public function money()
{
$this->startTrans();
try {
$this->transaction(function () {
// 更新申请状态
$this->allowField(true)->save([
'apply_status' => 40,
@ -110,24 +118,16 @@ class Withdraw extends WithdrawModel
'money' => -$this['money'],
'describe' => '申请提现',
]);
// 发送模板消息
(new Message)->withdraw($this);
// 事务提交
$this->commit();
});
return true;
} catch (\Exception $e) {
$this->error = $e->getMessage();
$this->rollback();
return false;
}
}
/**
* 分销商提现:微信支付企业付款
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
* @throws \think\exception\PDOException
*/
public function wechatPay()
{

View File

@ -183,7 +183,6 @@ class Order extends OrderModel
* 确认发货(单独订单)
* @param $data
* @return array|bool|false
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
* @throws \Exception
@ -262,19 +261,17 @@ class Order extends OrderModel
/**
* 确认发货后发送消息通知
* @param array|\think\Collection $orderList
* @param $orderList
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
private function sendDeliveryMessage($orderList)
{
// 实例化消息通知服务类
$Service = new MessageService;
foreach ($orderList as $item) {
// 发送消息通知
$Service->delivery($item, OrderTypeEnum::SHARING);
foreach ($orderList as $item) {
MessageService::send('order.delivery', [
'order' => $item,
'order_type' => OrderTypeEnum::SHARING,
]);
}
return true;
}

View File

@ -59,7 +59,6 @@ class OrderRefund extends OrderRefundModel
* 商家审核
* @param $data
* @return bool
* @throws \think\exception\PDOException
*/
public function audit($data)
{
@ -71,8 +70,7 @@ class OrderRefund extends OrderRefundModel
$this->error = '请选择退货地址';
return false;
}
$this->startTrans();
try {
$this->transaction(function ($data) {
// 拒绝申请, 标记售后单状态为已拒绝
$data['is_agree'] == 20 && $data['status'] = 10;
// 同意换货申请, 标记售后单状态为已完成
@ -81,21 +79,18 @@ class OrderRefund extends OrderRefundModel
$this->allowField(true)->save($data);
// 同意售后申请, 记录退货地址
if ($data['is_agree'] == 10) {
$model = new OrderRefundAddress;
$model->add($this['order_refund_id'], $data['address_id']);
(new OrderRefundAddress)->add($this['order_refund_id'], $data['address_id']);
}
// 订单详情
$order = Order::detail($this['order_id']);
// 发送模板消息
(new MessageService)->refund(static::detail($this['order_refund_id']), $order['order_no'], OrderTypeEnum::SHARING);
// 事务提交
$this->commit();
// 发送消息通知
MessageService::send('order.refund', [
'refund' => $this, // 退款单信息
'order_no' => $order['order_no'], // 订单信息
'order_type' => OrderTypeEnum::SHARING, // 订单类型
]);
});
return true;
} catch (\Exception $e) {
$this->error = $e->getMessage();
$this->rollback();
return false;
}
}
/**
@ -126,8 +121,12 @@ class OrderRefund extends OrderRefundModel
}
// 执行原路退款
(new RefundService)->execute($order, $data['refund_money']);
// 发送模板消息
(new MessageService)->refund(self::detail($this['order_refund_id']), $order['order_no'], OrderTypeEnum::SHARING);
// 发送消息通知
MessageService::send('order.refund', [
'refund' => $this, // 退款单信息
'order_no' => $order['order_no'], // 订单信息
'order_type' => OrderTypeEnum::SHARING, // 订单类型
]);
});
return true;
}

View File

@ -113,7 +113,7 @@ class LiveRoom extends LiveRoomModel
*/
private function getLocalRoomIds()
{
return $this->where('is_delete', '=', 0)->column('room_id');
return $this->where('is_delete', '=', 0)->column('room_id', 'id');
}
/**
@ -162,11 +162,14 @@ class LiveRoom extends LiveRoomModel
// 需要新增的直播间ID
$updatedLiveRoomIds = array_values(array_intersect($originRoomIds, $localRoomIds));
if (empty($updatedLiveRoomIds)) return true;
// 根据直播间id获取主键id
$idArr = $this->getLocalIdsByRoomIds($localRoomIds);
// 整理新增数据
$saveData = [];
foreach ($updatedLiveRoomIds as $roomId) {
$item = $originRoomList[$roomId];
$saveData[] = [
'id' => $idArr[$roomId],
'room_id' => $roomId,
'room_name' => $item['name'],
'cover_img' => $item['cover_img'],
@ -191,11 +194,30 @@ class LiveRoom extends LiveRoomModel
*/
private function refreshLiveRemove($localRoomIds, $originRoomIds)
{
// 需要新增的直播间ID
// 需要删除的直播间ID
$removedLiveRoomIds = array_values(array_diff($localRoomIds, $originRoomIds));
if (empty($removedLiveRoomIds)) return true;
// 根据直播间id获取主键id
$removedIds = $this->getLocalIdsByRoomIds($localRoomIds, $removedLiveRoomIds);
// 批量删除直播间
return self::destroy($removedLiveRoomIds);
return self::destroy(array_values($removedIds));
}
/**
* 根据直播间id获取主键id
* @param array $localRoomIds
* @param array $searchRoomIds
* @return array
*/
private function getLocalIdsByRoomIds($localRoomIds, $searchRoomIds = [])
{
$data = [];
foreach ($localRoomIds as $id => $roomId) {
if (empty($searchRoomIds) || in_array($roomId, $searchRoomIds)) {
$data[$roomId] = $id;
}
}
return $data;
}
}

View File

@ -80,8 +80,10 @@ class Auth
// 商家登录信息
$this->store = Session::get('yoshop_store');
// 当前用户信息
if (!empty($this->store)) {
$this->user = User::detail($this->store['user']['store_user_id']);
}
}
/**
* 私有化克隆方法
@ -117,6 +119,7 @@ class Auth
}
/**
* 验证url的权限
* @param string $url
* @return bool
* @throws \think\db\exception\DataNotFoundException
@ -126,7 +129,7 @@ class Auth
private function checkAccess($url)
{
// 超级管理员无需验证
if ($this->user['is_super']) {
if (!empty($this->user) && $this->user['is_super']) {
return true;
}
// 验证当前请求是否在白名单

View File

@ -8,7 +8,7 @@ use app\common\library\wechat\WxTplMsg;
use app\common\service\wxapp\FormId as FormIdService;
/**
* 推送模板消息服务类
* 推送模板消息服务类 (已废弃)
* Class Message
* @package app\store\service\wxapp
*/
@ -27,6 +27,7 @@ class Message
* 构造方法
* Message constructor.
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function __construct()

View File

@ -0,0 +1,194 @@
<?php
namespace app\store\service\wxapp;
use app\store\model\Wxapp as WxappModel;
use app\store\model\Setting as SettingModel;
use app\common\library\helper;
use app\common\service\Basics;
use app\common\library\wechat\WxSubMsg;
use app\common\exception\BaseException;
/**
* 小程序订阅消息服务类
* Class SubMsg
* @package app\store\service\wxapp
*/
class SubMsg extends Basics
{
/* @var $WxSubMsg WxSubMsg 小程序订阅消息api类 */
private $WxSubMsg;
/**
* 构造方法
* SubMsg constructor.
* @param null $wxappId
* @throws \app\common\exception\BaseException
* @throws \think\Exception
* @throws \think\exception\DbException
*/
public function __construct($wxappId = null)
{
// 小程序订阅消息api类
$wxConfig = WxappModel::getWxappCache($wxappId);
$this->WxSubMsg = new WxSubMsg($wxConfig['app_id'], $wxConfig['app_secret']);
}
/**
* 一键添加订阅消息
* @return bool
* @throws BaseException
* @throws \think\exception\DbException
*/
public function shuttle()
{
// 拉取我的模板列表
$myList = $this->getMyTemplateList();
// 筛选出未添加的模板
$addedList = $this->getNotAddedTemplates($myList);
// 批量添加订阅消息模板
$newList = $this->onBatchAdd($addedList);
// 全部模板列表
$tplList = array_merge($newList, $myList);
// 保存全部模板id
return $this->saveAll($tplList);
}
/**
* 保存全部模板id
* @param $tplList
* @return bool
* @throws \think\exception\DbException
*/
private function saveAll($tplList)
{
// 整理模板id
$data = SettingModel::getItem('submsg');
foreach ($data as &$group) {
foreach ($group as &$item) {
if (!isset($item['title'])) continue;
$tpl = helper::arraySearch($tplList, 'title', $item['title']);
$tpl != false && $item['template_id'] = $tpl['priTmplId'];
}
}
// 保存数据
return (new SettingModel)->edit('submsg', $data);
}
/**
* 批量添加订阅消息模板
* [并且记录返回的priTmplId]
* @param $newList
* @return array
* @throws BaseException
*/
private function onBatchAdd($newList)
{
foreach ($newList as &$item) {
// 请求微信api, 添加模板记录
$response = $this->WxSubMsg->addTemplate($item['tid'], $item['kidList'], $item['sceneDesc']);
if ($response === false) {
throw new BaseException(['msg' => "添加模板[{$item['sceneDesc']}]失败:" . $this->WxSubMsg->getError()]);
}
// 记录template_id
$item['priTmplId'] = $response['priTmplId'];
}
return $newList;
}
/**
* 筛选出未添加的模板
* @param $myList
* @return array
*/
private function getNotAddedTemplates($myList)
{
// 所有订阅消息模板列表
$templateLists = $this->getTemplates();
if (empty($myList)) return $templateLists;
// 整理未添加的
$data = [];
foreach ($templateLists as $item) {
if (helper::arraySearch($myList, 'title', $item['title']) === false) {
$data[] = $item;
}
}
return $data;
}
/**
* 所有订阅消息模板列表
* @return array
*/
private function getTemplates()
{
return [
// 支付成功通知
[
'tid' => 9344,
'title' => '新订单提醒',
'kidList' => [1, 2, 4, 3],
'sceneDesc' => '新订单提醒',
],
// 订单发货通知
[
'tid' => 855,
'title' => '订单发货通知',
'kidList' => [1, 2, 12, 11, 17],
'sceneDesc' => '订单发货通知',
],
// 售后状态通知
[
'tid' => 5049,
'title' => '售后状态通知',
'kidList' => [1, 6, 2, 3, 4],
'sceneDesc' => '售后状态通知',
],
// 拼团进度通知
[
'tid' => 5008,
'title' => '拼团进度通知',
'kidList' => [1, 5, 7, 3, 6],
'sceneDesc' => '拼团进度通知',
],
// 分销商入驻审核通知
[
'tid' => 4050,
'title' => '代理商入驻审核通知',
'kidList' => [1, 2, 3, 4],
'sceneDesc' => '分销商入驻审核通知',
],
// 提现成功通知
[
'tid' => 2001,
'title' => '提现成功通知',
'kidList' => [1, 3, 4],
'sceneDesc' => '提现成功通知',
],
// 提现失败通知
[
'tid' => 3173,
'title' => '提现失败通知',
'kidList' => [1, 3, 4],
'sceneDesc' => '提现失败通知',
],
];
}
/**
* 拉取我的模板列表
* @return mixed
* @throws BaseException
*/
private function getMyTemplateList()
{
$response = $this->WxSubMsg->getTemplateList();
if ($response === false) {
throw new BaseException(['msg' => '拉取模板列表失败:' . $this->WxSubMsg->getError()]);
}
return $response['data'];
}
}

View File

@ -13,7 +13,6 @@
<li><a href="#tab5">自定义文字</a></li>
<li><a href="#tab6">申请协议</a></li>
<li><a href="#tab7">页面背景图</a></li>
<li><a href="#tab8">模板消息</a></li>
</ul>
<div class="am-tabs-bd">
<div class="am-tab-panel am-active am-margin-top-lg" id="tab1">
@ -786,38 +785,6 @@
</div>
</div>
</div>
<div class="am-tab-panel am-margin-top-lg" id="tab8">
<div class="am-form-group">
<label class="am-u-sm-3 am-form-label form-require">
分销商入驻审核通知
</label>
<div class="am-u-sm-9">
<input type="text" class="tpl-form-input"
name="setting[template_msg][apply_tpl]"
placeholder="请填写模板消息ID"
value="<?= $data['template_msg']['values']['apply_tpl'] ?>">
<small>模板编号AT0674关键词 (申请时间、审核状态、审核时间、备注信息)</small>
<small class="am-margin-left-xs">
<a href="<?= url('store/setting.help/tplmsg') ?>" target="_blank">如何获取模板消息ID</a>
</small>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-form-label form-require">
提现状态通知
</label>
<div class="am-u-sm-9">
<input type="text" class="tpl-form-input"
name="setting[template_msg][withdraw_tpl]"
placeholder="请填写模板消息ID"
value="<?= $data['template_msg']['values']['withdraw_tpl'] ?>">
<small>模板编号AT0324关键词 (提现时间、提现方式、提现金额、提现状态、备注)</small>
<small class="am-margin-left-xs">
<a href="<?= url('store/setting.help/tplmsg') ?>" target="_blank">如何获取模板消息ID</a>
</small>
</div>
</div>
</div>
</div>
</div>
<div class="am-form-group">

View File

@ -87,22 +87,6 @@
</div>
</div>
<div class="widget-head am-cf">
<div class="widget-title am-fl">模板消息</div>
</div>
<div class="am-form-group am-padding-top-lg">
<label class="am-u-sm-3 am-form-label form-require"> 拼团拼单状态通知 </label>
<div class="am-u-sm-9">
<input type="text" class="tpl-form-input" name="basic[tpl_msg_id]"
placeholder="请填写模板消息ID" value="<?= $values['tpl_msg_id'] ?>">
<small>模板编号AT1814关键词 (订单编号、商品名称、拼团价格、拼团人数、拼团时间、拼团结果)</small>
<small class="am-margin-left-xs">
<a href="<?= url('store/setting.help/tplmsg') ?>"
target="_blank">如何获取模板消息ID</a>
</small>
</div>
</div>
<div class="am-form-group">
<div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
<button type="submit" class="j-submit am-btn am-btn-secondary">提交

View File

@ -0,0 +1,146 @@
<div class="row-content am-cf">
<div class="row">
<div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
<div class="widget am-cf">
<form id="my-form" class="am-form tpl-form-line-form" method="post">
<div class="widget-body">
<fieldset>
<div class="tips am-margin-top-sm">
<div class="pre">
<p class="">
1. 订阅消息仅支持小程序 "<strong>服装/鞋/箱包</strong>" 类目,请登录 "<a
href="https://mp.weixin.qq.com" target="_blank">小程序运营平台</a>",左侧菜单栏 "设置"
- "基本设置" - "服务类目" 中添加
</p>
<p class="am-padding-top-xs">2. 建议使用当前页面下方的 " <a href="#shuttle">一键添加</a>"
按钮,自动完成订阅消息模板的添加</p>
</div>
</div>
<div class="widget-head am-cf">
<div class="widget-title am-fl">订单消息通知</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 新订单提醒 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input" name="submsg[order][payment][template_id]"
value="<?= $values['order']['payment']['template_id'] ?>">
<div class="help-block">
<small>关键词:[订单编号、下单时间、订单金额、商品名称]</small>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 订单发货通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input"
name="submsg[order][delivery][template_id]"
value="<?= $values['order']['delivery']['template_id'] ?>">
<div class="help-block">
<small>关键词:[订单号、商品名称、收货人、收货地址、物流公司]</small>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 售后状态通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input" name="submsg[order][refund][template_id]"
value="<?= $values['order']['refund']['template_id'] ?>">
<div class="help-block">
<small>关键词:[售后类型、状态、订单编号、申请时间、申请原因]</small>
</div>
</div>
</div>
<div class="widget-head am-cf">
<div class="widget-title am-fl">拼团进度通知</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 拼团进度通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input"
name="submsg[sharing][active_status][template_id]"
value="<?= $values['sharing']['active_status']['template_id'] ?>">
<div class="help-block">
<small>关键词:[拼团商品、拼团价格、成团人数、拼团进度、温馨提示]</small>
</div>
</div>
</div>
<div class="widget-head am-cf">
<div class="widget-title am-fl">分销商消息通知</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 分销商入驻审核通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input" name="submsg[dealer][apply][template_id]"
value="<?= $values['dealer']['apply']['template_id'] ?>">
<div class="help-block">
<small>关键词:[申请时间、审核状态、审核时间、备注信息]</small>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 提现成功通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input"
name="submsg[dealer][withdraw_01][template_id]"
value="<?= $values['dealer']['withdraw_01']['template_id'] ?>">
<div class="help-block">
<small>关键词:[提现金额、打款方式、打款原因]</small>
</div>
</div>
</div>
<div class="am-form-group">
<label class="am-u-sm-3 am-u-lg-2 am-form-label form-require"> 提现失败通知 </label>
<div class="am-u-sm-9 am-u-md-6 am-u-lg-5 am-u-end">
<input type="text" class="tpl-form-input"
name="submsg[dealer][withdraw_02][template_id]"
value="<?= $values['dealer']['withdraw_02']['template_id'] ?>">
<div class="help-block">
<small>关键词:[提现金额、申请时间、原因]</small>
</div>
</div>
</div>
<div id="shuttle" class="am-form-group">
<div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
<button type="submit"
class="j-submit am-btn am-btn-sm am-btn-secondary am-margin-right-sm">保存
</button>
<button type="button" class="j-shuttle am-btn am-btn-sm am-btn-success">一键添加
</button>
</div>
</div>
</fieldset>
</div>
</form>
</div>
</div>
</div>
</div>
<script>
$(function () {
// 一键配置
$('.j-shuttle').on('click', function () {
var url = "<?= url('wxapp.submsg/shuttle') ?>";
var load = layer.load();
layer.confirm('该操作将自动为您的小程序添加订阅消息<br>请先确保 "订阅消息" - "我的模板" 中没有记录<br>确定添加吗?', {
title: '友情提示'
}, function (index) {
$.post(url, {}, function (result) {
result.code === 1 ? $.show_success(result.msg, result.url)
: $.show_error(result.msg);
layer.close(load);
});
layer.close(index);
});
});
/**
* 表单验证提交
* @type {*}
*/
$('#my-form').superForm();
});
</script>

View File

@ -3,10 +3,11 @@
namespace app\task\behavior\sharing;
use think\Cache;
use app\common\service\Message;
use app\task\model\sharing\Setting;
use app\task\model\sharing\Active as ActiveModel;
use app\task\model\sharing\Order as OrderModel;
use app\task\model\sharing\Active as ActiveModel;
use app\task\model\sharing\Setting as SettingModel;
use app\common\service\Message as MessageService;
use app\common\enum\sharing\ActiveStatus as ActiveStatusEnum;
/**
* 拼团订单行为管理
@ -35,7 +36,7 @@ class Active
if (!Cache::has('__task_space__sharing_active__' . $model::$wxapp_id)) {
try {
// 拼团设置
$config = Setting::getItem('basic');
$config = SettingModel::getItem('basic');
// 已过期的拼单更新状态(拼单失败)
$this->onUpdateActiveEnd();
// 更新拼团失败的订单并退款
@ -44,7 +45,7 @@ class Active
}
} catch (\Exception $e) {
}
Cache::set('__task_space__sharing_active__' . $model::$wxapp_id, time(), 10);
Cache::set('__task_space__sharing_active__' . $model::$wxapp_id, time(), 1);
}
return true;
}
@ -52,7 +53,6 @@ class Active
/**
* 已过期的拼单更新状态
* @return false|int
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
@ -70,10 +70,12 @@ class Active
$this->dologs('onSetActiveEnd', [
'activeIds' => json_encode($activeIds),
]);
// 发送拼团失败模板消息
$Message = new Message;
// 发送拼团失败订阅消息
foreach ($list as $item) {
$Message->sharingActive($item, '拼团失败');
MessageService::send('sharing.active_status', [
'active' => $item,
'status' => ActiveStatusEnum::ACTIVE_STATE_FAIL
]);
}
// 更新已过期状态
return $this->model->updateEndedStatus($activeIds);
@ -82,7 +84,6 @@ class Active
/**
* 更新拼团失败的订单并退款
* @return bool
* @throws \app\common\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException

View File

@ -1,3 +1,3 @@
{
"version": "1.1.40"
"version": "1.1.41"
}