mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-12 19:12:49 +00:00
格式化事件代码
This commit is contained in:
parent
0b2e0f103e
commit
d236a9da93
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace crmeb\subscribes;
|
namespace crmeb\subscribes;
|
||||||
|
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 素材消息事件
|
* 素材消息事件
|
||||||
* Class MaterialSubscribe
|
* Class MaterialSubscribe
|
||||||
@ -21,7 +23,7 @@ class MaterialSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onWechatMaterialAfter($event)
|
public function onWechatMaterialAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$type) = $event;
|
list($data, $type) = $event;
|
||||||
$data['type'] = $type;
|
$data['type'] = $type;
|
||||||
$data['add_time'] = time();
|
$data['add_time'] = time();
|
||||||
$data['temporary'] = 0;
|
$data['temporary'] = 0;
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace crmeb\subscribes;
|
namespace crmeb\subscribes;
|
||||||
|
|
||||||
use app\admin\model\wechat\WechatMessage;
|
use app\admin\model\wechat\WechatMessage;
|
||||||
@ -31,18 +32,19 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onAdminNewPush($event)
|
public function onAdminNewPush($event)
|
||||||
{
|
{
|
||||||
try{
|
try {
|
||||||
$data['ordernum'] = StoreOrder::where('paid',1)->where('status',0)
|
$data['ordernum'] = StoreOrder::where('paid', 1)->where('status', 0)
|
||||||
->where('shipping_type',1)->where('refund_status',0)
|
->where('shipping_type', 1)->where('refund_status', 0)
|
||||||
->where('is_del',0)->count();
|
->where('is_del', 0)->count();
|
||||||
$store_stock = sysConfig('store_stock');
|
$store_stock = sysConfig('store_stock');
|
||||||
if($store_stock < 0) $store_stock = 2;
|
if ($store_stock < 0) $store_stock = 2;
|
||||||
$data['inventory'] = StoreProduct::where('stock','<=',$store_stock)->where('is_show',1)->where('is_del',0)->count();//库存
|
$data['inventory'] = StoreProduct::where('stock', '<=', $store_stock)->where('is_show', 1)->where('is_del', 0)->count();//库存
|
||||||
$data['commentnum'] = StoreProductReply::where('is_reply',0)->count();
|
$data['commentnum'] = StoreProductReply::where('is_reply', 0)->count();
|
||||||
$data['reflectnum'] = UserExtract::where('status',0)->count();//提现
|
$data['reflectnum'] = UserExtract::where('status', 0)->count();//提现
|
||||||
$data['msgcount'] = intval($data['ordernum']) + intval($data['inventory']) + intval($data['commentnum']) + intval($data['reflectnum']);
|
$data['msgcount'] = intval($data['ordernum']) + intval($data['inventory']) + intval($data['commentnum']) + intval($data['reflectnum']);
|
||||||
ChannelService::instance()->send('ADMIN_NEW_PUSH',$data);
|
ChannelService::instance()->send('ADMIN_NEW_PUSH', $data);
|
||||||
}catch (\Exception $e){}
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,10 +57,10 @@ class MessageSubscribe
|
|||||||
WechatUser::saveUser($message->FromUserName);
|
WechatUser::saveUser($message->FromUserName);
|
||||||
|
|
||||||
$event = isset($message->Event) ?
|
$event = isset($message->Event) ?
|
||||||
$message->MsgType.(
|
$message->MsgType . (
|
||||||
$message->Event == 'subscribe' && isset($message->EventKey) ? '_scan' : ''
|
$message->Event == 'subscribe' && isset($message->EventKey) ? '_scan' : ''
|
||||||
).'_'.$message->Event : $message->MsgType;
|
) . '_' . $message->Event : $message->MsgType;
|
||||||
WechatMessage::setMessage(json_encode($message),$message->FromUserName,strtolower($event));
|
WechatMessage::setMessage(json_encode($message), $message->FromUserName, strtolower($event));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,21 +88,22 @@ class MessageSubscribe
|
|||||||
public function onShortMssageSend($event)
|
public function onShortMssageSend($event)
|
||||||
{
|
{
|
||||||
//$actions 可为数组
|
//$actions 可为数组
|
||||||
list($order_id,$actions) = $event;
|
list($order_id, $actions) = $event;
|
||||||
try{
|
try {
|
||||||
if(is_array($actions)){
|
if (is_array($actions)) {
|
||||||
foreach ($actions as $action){
|
foreach ($actions as $action) {
|
||||||
$actionName = 'MssageSend'.$action;
|
$actionName = 'MssageSend' . $action;
|
||||||
if(method_exists($this,$actionName)) $this->$actionName($order_id);
|
if (method_exists($this, $actionName)) $this->$actionName($order_id);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
$actionName = 'MssageSend'.$actions;
|
$actionName = 'MssageSend' . $actions;
|
||||||
if(method_exists($this,$actionName)) $this->$actionName($order_id);
|
if (method_exists($this, $actionName)) $this->$actionName($order_id);
|
||||||
}
|
}
|
||||||
}catch (\Exception $e){
|
} catch (\Exception $e) {
|
||||||
Log::error('短信下发事件发生系统错误,错误原因:'.$e->getMessage());
|
Log::error('短信下发事件发生系统错误,错误原因:' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送短信
|
* 发送短信
|
||||||
* @param boolean $switch 发送开关
|
* @param boolean $switch 发送开关
|
||||||
@ -109,9 +112,9 @@ class MessageSubscribe
|
|||||||
* @param int $template 模板编号
|
* @param int $template 模板编号
|
||||||
* @param string $logMsg 错误日志记录
|
* @param string $logMsg 错误日志记录
|
||||||
*/
|
*/
|
||||||
public function send($switch,$phone,array $data,$template,$logMsg='')
|
public function send($switch, $phone, array $data, $template, $logMsg = '')
|
||||||
{
|
{
|
||||||
if($switch && $phone){
|
if ($switch && $phone) {
|
||||||
$template = SMSService::getConstants($template);
|
$template = SMSService::getConstants($template);
|
||||||
$res = SMSService::send($phone, $template, $data);
|
$res = SMSService::send($phone, $template, $data);
|
||||||
if ($res['status'] == 400) Log::info($logMsg);
|
if ($res['status'] == 400) Log::info($logMsg);
|
||||||
@ -124,12 +127,12 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendPaySuccess($order_id)
|
public function MssageSendPaySuccess($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('lower_order_switch') ? true : false;
|
$switch = sysConfig('lower_order_switch') ? true : false;
|
||||||
//模板变量
|
//模板变量
|
||||||
$pay_price = $storeInfo->pay_price;
|
$pay_price = $storeInfo->pay_price;
|
||||||
$this->send($switch,$storeInfo->user_phone,compact('order_id','pay_price'),'PAY_SUCCESS_CODE','用户支付成功发送短信失败,订单号为:'.$order_id);
|
$this->send($switch, $storeInfo->user_phone, compact('order_id', 'pay_price'), 'PAY_SUCCESS_CODE', '用户支付成功发送短信失败,订单号为:' . $order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,13 +141,13 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendDeliver($order_id)
|
public function MssageSendDeliver($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>1])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 1])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('deliver_goods_switch') ? true : false;
|
$switch = sysConfig('deliver_goods_switch') ? true : false;
|
||||||
//模板变量
|
//模板变量
|
||||||
$nickname = User::where('uid',$storeInfo->uid)->value('nickname');
|
$nickname = User::where('uid', $storeInfo->uid)->value('nickname');
|
||||||
$store_name = StoreOrder::getProductTitle($storeInfo->cart_id);
|
$store_name = StoreOrder::getProductTitle($storeInfo->cart_id);
|
||||||
$this->send($switch,$storeInfo->user_phone,compact('order_id','store_name','nickname'),'DELIVER_GOODS_CODE','用户发货发送短信失败,订单号为:'.$order_id);
|
$this->send($switch, $storeInfo->user_phone, compact('order_id', 'store_name', 'nickname'), 'DELIVER_GOODS_CODE', '用户发货发送短信失败,订单号为:' . $order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -153,12 +156,12 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendReceiving($order_id)
|
public function MssageSendReceiving($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>2])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 2])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('confirm_take_over_switch') ? true : false;
|
$switch = sysConfig('confirm_take_over_switch') ? true : false;
|
||||||
//模板变量
|
//模板变量
|
||||||
$store_name = StoreOrder::getProductTitle($storeInfo->cart_id);
|
$store_name = StoreOrder::getProductTitle($storeInfo->cart_id);
|
||||||
$this->send($switch,$storeInfo->user_phone,compact('store_name','order_id'),'TAKE_DELIVERY_CODE','用户确认收货发送短信失败,订单号为:'.$order_id);
|
$this->send($switch, $storeInfo->user_phone, compact('store_name', 'order_id'), 'TAKE_DELIVERY_CODE', '用户确认收货发送短信失败,订单号为:' . $order_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,14 +170,14 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendAdminPlaceAnOrder($order_id)
|
public function MssageSendAdminPlaceAnOrder($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>0,'refund_status'=>0,'status'=>0])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 0, 'refund_status' => 0, 'status' => 0])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('admin_lower_order_switch') ? true : false;
|
$switch = sysConfig('admin_lower_order_switch') ? true : false;
|
||||||
$switch && $this->getAdminNoticeAuth(function ($userInfo) use($storeInfo) {
|
$switch && $this->getAdminNoticeAuth(function ($userInfo) use ($storeInfo) {
|
||||||
//模板变量
|
//模板变量
|
||||||
$admin_name = $userInfo->nickname;
|
$admin_name = $userInfo->nickname;
|
||||||
$order_id = $storeInfo->order_id;
|
$order_id = $storeInfo->order_id;
|
||||||
$this->send(true,$userInfo->phone,compact('admin_name','order_id'),'ADMIN_PLACE_ORDER_CODE','用户下单成功管理员发送短信通知失败,订单号为:'.$storeInfo->order_id);
|
$this->send(true, $userInfo->phone, compact('admin_name', 'order_id'), 'ADMIN_PLACE_ORDER_CODE', '用户下单成功管理员发送短信通知失败,订单号为:' . $storeInfo->order_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,14 +187,14 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendAdminPaySuccess($order_id)
|
public function MssageSendAdminPaySuccess($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>0])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 0])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('admin_pay_success_switch') ? true : false;
|
$switch = sysConfig('admin_pay_success_switch') ? true : false;
|
||||||
$switch && $this->getAdminNoticeAuth(function ($userInfo) use($storeInfo) {
|
$switch && $this->getAdminNoticeAuth(function ($userInfo) use ($storeInfo) {
|
||||||
//模板变量
|
//模板变量
|
||||||
$admin_name = $userInfo->nickname;
|
$admin_name = $userInfo->nickname;
|
||||||
$order_id = $storeInfo->order_id;
|
$order_id = $storeInfo->order_id;
|
||||||
$this->send(true,$userInfo->phone,compact('admin_name','order_id'),'ADMIN_PAY_SUCCESS_CODE','用户支付成功管理员发送短信通知失败,订单号为:'.$storeInfo->order_id);
|
$this->send(true, $userInfo->phone, compact('admin_name', 'order_id'), 'ADMIN_PAY_SUCCESS_CODE', '用户支付成功管理员发送短信通知失败,订单号为:' . $storeInfo->order_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,14 +204,14 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendAdminConfirmTakeOver($order_id)
|
public function MssageSendAdminConfirmTakeOver($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>2])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 2])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('admin_confirm_take_over_switch') ? true : false;
|
$switch = sysConfig('admin_confirm_take_over_switch') ? true : false;
|
||||||
$switch && $this->getAdminNoticeAuth(function ($userInfo) use($storeInfo) {
|
$switch && $this->getAdminNoticeAuth(function ($userInfo) use ($storeInfo) {
|
||||||
//模板变量
|
//模板变量
|
||||||
$admin_name = $userInfo->nickname;
|
$admin_name = $userInfo->nickname;
|
||||||
$order_id = $storeInfo->order_id;
|
$order_id = $storeInfo->order_id;
|
||||||
$this->send(true,$userInfo->phone,compact('admin_name','order_id'),'ADMIN_TAKE_DELIVERY_CODE','用户确认收货成功管理员发送短信通知失败,订单号为:'.$storeInfo->order_id);
|
$this->send(true, $userInfo->phone, compact('admin_name', 'order_id'), 'ADMIN_TAKE_DELIVERY_CODE', '用户确认收货成功管理员发送短信通知失败,订单号为:' . $storeInfo->order_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,16 +221,17 @@ class MessageSubscribe
|
|||||||
*/
|
*/
|
||||||
public function MssageSendAdminRefund($order_id)
|
public function MssageSendAdminRefund($order_id)
|
||||||
{
|
{
|
||||||
$storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>1])->find();
|
$storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 1])->find();
|
||||||
if(!$storeInfo) return;
|
if (!$storeInfo) return;
|
||||||
$switch = sysConfig('admin_refund_switch') ? true : false;
|
$switch = sysConfig('admin_refund_switch') ? true : false;
|
||||||
$switch && $this->getAdminNoticeAuth(function ($userInfo) use($storeInfo) {
|
$switch && $this->getAdminNoticeAuth(function ($userInfo) use ($storeInfo) {
|
||||||
//模板变量
|
//模板变量
|
||||||
$admin_name = $userInfo->nickname;
|
$admin_name = $userInfo->nickname;
|
||||||
$order_id = $storeInfo->order_id;
|
$order_id = $storeInfo->order_id;
|
||||||
$this->send(true,$userInfo->phone,compact('admin_name','order_id'),'ADMIN_RETURN_GOODS_CODE','用户退款管理员发送短信通知失败,订单号为:'.$storeInfo->order_id);
|
$this->send(true, $userInfo->phone, compact('admin_name', 'order_id'), 'ADMIN_RETURN_GOODS_CODE', '用户退款管理员发送短信通知失败,订单号为:' . $storeInfo->order_id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 提取管理员权限
|
* 提取管理员权限
|
||||||
* @param callable $callable 回调函数
|
* @param callable $callable 回调函数
|
||||||
@ -235,10 +239,10 @@ class MessageSubscribe
|
|||||||
public function getAdminNoticeAuth(callable $callable)
|
public function getAdminNoticeAuth(callable $callable)
|
||||||
{
|
{
|
||||||
$serviceOrderNotice = StoreService::getStoreServiceOrderNotice();
|
$serviceOrderNotice = StoreService::getStoreServiceOrderNotice();
|
||||||
if(count($serviceOrderNotice)) {
|
if (count($serviceOrderNotice)) {
|
||||||
foreach ($serviceOrderNotice as $uid) {
|
foreach ($serviceOrderNotice as $uid) {
|
||||||
$userInfo= User::where('uid',$uid)->field('phone,nickname')->find();
|
$userInfo = User::where('uid', $uid)->field('phone,nickname')->find();
|
||||||
if($userInfo && is_callable($callable)) $callable($userInfo);
|
if ($userInfo && is_callable($callable)) $callable($userInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,8 +41,8 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onStoreProductOrderDeliveryAfter($event)
|
public function onStoreProductOrderDeliveryAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$oid) = $event;
|
list($data, $oid) = $event;
|
||||||
AdminStoreOrder::orderPostageAfter($oid,$data);
|
AdminStoreOrder::orderPostageAfter($oid, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,8 +54,8 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onStoreProductOrderDeliveryGoodsAfter($event)
|
public function onStoreProductOrderDeliveryGoodsAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$oid) = $event;
|
list($data, $oid) = $event;
|
||||||
AdminStoreOrder::orderPostageAfter($oid,$data);
|
AdminStoreOrder::orderPostageAfter($oid, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,8 +64,8 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onStoreProductOrderRefundNAfter($event)
|
public function onStoreProductOrderRefundNAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$id) = $event;
|
list($data, $id) = $event;
|
||||||
AdminStoreOrder::refundNoPrieTemplate($id,$data);
|
AdminStoreOrder::refundNoPrieTemplate($id, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +84,7 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onStoreProductOrderEditAfter($event)
|
public function onStoreProductOrderEditAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$id) = $event;
|
list($data, $id) = $event;
|
||||||
//$data total_price 商品总价 pay_price 实际支付
|
//$data total_price 商品总价 pay_price 实际支付
|
||||||
//订单编号 $id
|
//订单编号 $id
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onStoreProductOrderDistributionAfter($event)
|
public function onStoreProductOrderDistributionAfter($event)
|
||||||
{
|
{
|
||||||
list($data,$id) = $event;
|
list($data, $id) = $event;
|
||||||
//$data 送货人姓名/快递公司 送货人电话/快递单号
|
//$data 送货人姓名/快递公司 送货人电话/快递单号
|
||||||
//订单编号 $id
|
//订单编号 $id
|
||||||
}
|
}
|
||||||
@ -125,16 +125,18 @@ class OrderSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onOrderPaySuccess($event)
|
public function onOrderPaySuccess($event)
|
||||||
{
|
{
|
||||||
list($order,$formId) = $event;
|
list($order, $formId) = $event;
|
||||||
//更新用户支付订单数量
|
//更新用户支付订单数量
|
||||||
User::bcInc($order['uid'], 'pay_count', 1, 'uid');
|
User::bcInc($order['uid'], 'pay_count', 1, 'uid');
|
||||||
//发送模版消息、客服消息、短信、小票打印给客户和管理员
|
//发送模版消息、客服消息、短信、小票打印给客户和管理员
|
||||||
NoticeRepositories::noticeOrderPaySuccess($order,$formId);
|
NoticeRepositories::noticeOrderPaySuccess($order, $formId);
|
||||||
//检测会员等级
|
//检测会员等级
|
||||||
event('UserLevelAfter', [$order['uid']]);
|
event('UserLevelAfter', [$order['uid']]);
|
||||||
|
|
||||||
|
try {
|
||||||
//向后台发送新订单消息
|
//向后台发送新订单消息
|
||||||
ChannelService::instance()->send('NEW_ORDER', ['order_id'=>$order['order_id']]);
|
ChannelService::instance()->send('NEW_ORDER', ['order_id' => $order['order_id']]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace crmeb\subscribes;
|
namespace crmeb\subscribes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,7 +31,8 @@ class ProductSubscribe
|
|||||||
* 用户操作产品添加事件 用户点赞产品 用户收藏产品
|
* 用户操作产品添加事件 用户点赞产品 用户收藏产品
|
||||||
* @param $event
|
* @param $event
|
||||||
*/
|
*/
|
||||||
public function onStoreProductUserOperationConfirmAfter($event){
|
public function onStoreProductUserOperationConfirmAfter($event)
|
||||||
|
{
|
||||||
list($category, $productId, $relationType, $uid) = $event;
|
list($category, $productId, $relationType, $uid) = $event;
|
||||||
//$category 产品类型
|
//$category 产品类型
|
||||||
//$productId 产品编号
|
//$productId 产品编号
|
||||||
@ -42,7 +44,8 @@ class ProductSubscribe
|
|||||||
* 用户操作产品取消事件 用户取消点赞产品 用户取消收藏产品
|
* 用户操作产品取消事件 用户取消点赞产品 用户取消收藏产品
|
||||||
* @param $event
|
* @param $event
|
||||||
*/
|
*/
|
||||||
public function onStoreProductUserOperationCancelAfter($event){
|
public function onStoreProductUserOperationCancelAfter($event)
|
||||||
|
{
|
||||||
list($category, $productId, $relationType, $uid) = $event;
|
list($category, $productId, $relationType, $uid) = $event;
|
||||||
//$category 产品类型
|
//$category 产品类型
|
||||||
//$productId 产品编号
|
//$productId 产品编号
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace crmeb\subscribes;
|
namespace crmeb\subscribes;
|
||||||
|
|
||||||
use app\admin\model\system\SystemAdmin;
|
use app\admin\model\system\SystemAdmin;
|
||||||
use app\admin\model\system\SystemLog;
|
use app\admin\model\system\SystemLog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后台系统事件
|
* 后台系统事件
|
||||||
* Class SystemSubscribe
|
* Class SystemSubscribe
|
||||||
@ -22,8 +24,8 @@ class SystemSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onAdminVisit($event)
|
public function onAdminVisit($event)
|
||||||
{
|
{
|
||||||
list($adminInfo,$type) = $event;
|
list($adminInfo, $type) = $event;
|
||||||
if(strtolower(app('request')->controller()) != 'index') SystemLog::adminVisit($adminInfo->id,$adminInfo->account,$type);
|
if (strtolower(app('request')->controller()) != 'index') SystemLog::adminVisit($adminInfo->id, $adminInfo->account, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,7 +35,7 @@ class SystemSubscribe
|
|||||||
public function onSystemAdminLoginAfter($event)
|
public function onSystemAdminLoginAfter($event)
|
||||||
{
|
{
|
||||||
list($adminInfo) = $event;
|
list($adminInfo) = $event;
|
||||||
SystemAdmin::edit(['last_ip'=>app('request')->ip(),'last_time'=>time()],$adminInfo['id']);
|
SystemAdmin::edit(['last_ip' => app('request')->ip(), 'last_time' => time()], $adminInfo['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace crmeb\subscribes;
|
namespace crmeb\subscribes;
|
||||||
|
|
||||||
use app\admin\model\system\SystemAttachment;
|
use app\admin\model\system\SystemAttachment;
|
||||||
@ -26,6 +27,7 @@ class TaskSubscribe
|
|||||||
public function onTask_2()
|
public function onTask_2()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 6秒钟执行的方法
|
* 6秒钟执行的方法
|
||||||
*/
|
*/
|
||||||
@ -45,14 +47,14 @@ class TaskSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onTask_30()
|
public function onTask_30()
|
||||||
{
|
{
|
||||||
try{
|
try {
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
|
StoreBargainUser::startBargainUserStatus();//批量修改砍价状态为 砍价失败
|
||||||
StoreOrder::orderUnpaidCancel();//订单未支付默认取消
|
StoreOrder::orderUnpaidCancel();//订单未支付默认取消
|
||||||
StoreOrder::startTakeOrder();//7天自动收货
|
StoreOrder::startTakeOrder();//7天自动收货
|
||||||
StorePink::statusPink();//拼团到期修改状态
|
StorePink::statusPink();//拼团到期修改状态
|
||||||
Db::commit();
|
Db::commit();
|
||||||
}catch (\Exception $e){
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -41,24 +41,24 @@ class UserSubscribe
|
|||||||
*/
|
*/
|
||||||
public function onWechatOauthAfter($event)
|
public function onWechatOauthAfter($event)
|
||||||
{
|
{
|
||||||
list($openid, $wechatInfo, $spreadId,$login_type) = $event;
|
list($openid, $wechatInfo, $spreadId, $login_type) = $event;
|
||||||
|
|
||||||
if (!User::be(['uid' => $spreadId])) $spreadId = 0;
|
if (!User::be(['uid' => $spreadId])) $spreadId = 0;
|
||||||
|
|
||||||
$wechatInfo['nickname'] = filterEmoji($wechatInfo['nickname']);
|
$wechatInfo['nickname'] = filterEmoji($wechatInfo['nickname']);
|
||||||
Cookie::set('is_login', 1);
|
Cookie::set('is_login', 1);
|
||||||
if (isset($wechatInfo['unionid']) && $wechatInfo['unionid'] != '' && ($uid = WechatUser::where('unionid', $wechatInfo['unionid'])->where('user_type','<>','h5')->value('uid'))) {
|
if (isset($wechatInfo['unionid']) && $wechatInfo['unionid'] != '' && ($uid = WechatUser::where('unionid', $wechatInfo['unionid'])->where('user_type', '<>', 'h5')->value('uid'))) {
|
||||||
WechatUser::edit($wechatInfo, $uid, 'uid');
|
WechatUser::edit($wechatInfo, $uid, 'uid');
|
||||||
if (!User::be(['uid' => $uid])) {
|
if (!User::be(['uid' => $uid])) {
|
||||||
$wechatInfo = WechatUser::where('uid', $uid)->find();
|
$wechatInfo = WechatUser::where('uid', $uid)->find();
|
||||||
User::setWechatUser($wechatInfo, $spreadId);
|
User::setWechatUser($wechatInfo, $spreadId);
|
||||||
} else {
|
} else {
|
||||||
if($login_type) $wechatInfo['login_type'] = $login_type;
|
if ($login_type) $wechatInfo['login_type'] = $login_type;
|
||||||
User::updateWechatUser($wechatInfo, $uid);
|
User::updateWechatUser($wechatInfo, $uid);
|
||||||
}
|
}
|
||||||
} else if ($uid = WechatUser::where(['openid' => $wechatInfo['openid']])->where('user_type','<>','h5')->value('uid')) {
|
} else if ($uid = WechatUser::where(['openid' => $wechatInfo['openid']])->where('user_type', '<>', 'h5')->value('uid')) {
|
||||||
WechatUser::edit($wechatInfo, $uid, 'uid');
|
WechatUser::edit($wechatInfo, $uid, 'uid');
|
||||||
if($login_type) $wechatInfo['login_type'] = $login_type;
|
if ($login_type) $wechatInfo['login_type'] = $login_type;
|
||||||
User::updateWechatUser($wechatInfo, $uid);
|
User::updateWechatUser($wechatInfo, $uid);
|
||||||
} else {
|
} else {
|
||||||
if (isset($wechatInfo['subscribe_scene'])) unset($wechatInfo['subscribe_scene']);
|
if (isset($wechatInfo['subscribe_scene'])) unset($wechatInfo['subscribe_scene']);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user