diff --git a/crmeb/crmeb/subscribes/MaterialSubscribe.php b/crmeb/crmeb/subscribes/MaterialSubscribe.php index 20892216..c8fee047 100644 --- a/crmeb/crmeb/subscribes/MaterialSubscribe.php +++ b/crmeb/crmeb/subscribes/MaterialSubscribe.php @@ -1,7 +1,9 @@ where('status',0) - ->where('shipping_type',1)->where('refund_status',0) - ->where('is_del',0)->count(); + try { + $data['ordernum'] = StoreOrder::where('paid', 1)->where('status', 0) + ->where('shipping_type', 1)->where('refund_status', 0) + ->where('is_del', 0)->count(); $store_stock = sysConfig('store_stock'); - if($store_stock < 0) $store_stock = 2; - $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['reflectnum'] = UserExtract::where('status',0)->count();//提现 + if ($store_stock < 0) $store_stock = 2; + $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['reflectnum'] = UserExtract::where('status', 0)->count();//提现 $data['msgcount'] = intval($data['ordernum']) + intval($data['inventory']) + intval($data['commentnum']) + intval($data['reflectnum']); - ChannelService::instance()->send('ADMIN_NEW_PUSH',$data); - }catch (\Exception $e){} + ChannelService::instance()->send('ADMIN_NEW_PUSH', $data); + } catch (\Exception $e) { + } } /** @@ -55,10 +57,10 @@ class MessageSubscribe WechatUser::saveUser($message->FromUserName); $event = isset($message->Event) ? - $message->MsgType.( + $message->MsgType . ( $message->Event == 'subscribe' && isset($message->EventKey) ? '_scan' : '' - ).'_'.$message->Event : $message->MsgType; - WechatMessage::setMessage(json_encode($message),$message->FromUserName,strtolower($event)); + ) . '_' . $message->Event : $message->MsgType; + WechatMessage::setMessage(json_encode($message), $message->FromUserName, strtolower($event)); } /** @@ -86,21 +88,22 @@ class MessageSubscribe public function onShortMssageSend($event) { //$actions 可为数组 - list($order_id,$actions) = $event; - try{ - if(is_array($actions)){ - foreach ($actions as $action){ - $actionName = 'MssageSend'.$action; - if(method_exists($this,$actionName)) $this->$actionName($order_id); + list($order_id, $actions) = $event; + try { + if (is_array($actions)) { + foreach ($actions as $action) { + $actionName = 'MssageSend' . $action; + if (method_exists($this, $actionName)) $this->$actionName($order_id); } - }else{ - $actionName = 'MssageSend'.$actions; - if(method_exists($this,$actionName)) $this->$actionName($order_id); + } else { + $actionName = 'MssageSend' . $actions; + if (method_exists($this, $actionName)) $this->$actionName($order_id); } - }catch (\Exception $e){ - Log::error('短信下发事件发生系统错误,错误原因:'.$e->getMessage()); + } catch (\Exception $e) { + Log::error('短信下发事件发生系统错误,错误原因:' . $e->getMessage()); } } + /** * 发送短信 * @param boolean $switch 发送开关 @@ -109,9 +112,9 @@ class MessageSubscribe * @param int $template 模板编号 * @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); $res = SMSService::send($phone, $template, $data); if ($res['status'] == 400) Log::info($logMsg); @@ -124,12 +127,12 @@ class MessageSubscribe */ public function MssageSendPaySuccess($order_id) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0])->find(); + if (!$storeInfo) return; $switch = sysConfig('lower_order_switch') ? true : false; //模板变量 $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>1])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 1])->find(); + if (!$storeInfo) return; $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); - $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>2])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 2])->find(); + if (!$storeInfo) return; $switch = sysConfig('confirm_take_over_switch') ? true : false; //模板变量 $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>0,'refund_status'=>0,'status'=>0])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 0, 'refund_status' => 0, 'status' => 0])->find(); + if (!$storeInfo) return; $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; $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>0])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 0])->find(); + if (!$storeInfo) return; $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; $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>0,'status'=>2])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 0, 'status' => 2])->find(); + if (!$storeInfo) return; $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; $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) { - $storeInfo = StoreOrder::where(['order_id'=>$order_id,'paid'=>1,'refund_status'=>1])->find(); - if(!$storeInfo) return; + $storeInfo = StoreOrder::where(['order_id' => $order_id, 'paid' => 1, 'refund_status' => 1])->find(); + if (!$storeInfo) return; $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; $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 回调函数 @@ -235,10 +239,10 @@ class MessageSubscribe public function getAdminNoticeAuth(callable $callable) { $serviceOrderNotice = StoreService::getStoreServiceOrderNotice(); - if(count($serviceOrderNotice)) { + if (count($serviceOrderNotice)) { foreach ($serviceOrderNotice as $uid) { - $userInfo= User::where('uid',$uid)->field('phone,nickname')->find(); - if($userInfo && is_callable($callable)) $callable($userInfo); + $userInfo = User::where('uid', $uid)->field('phone,nickname')->find(); + if ($userInfo && is_callable($callable)) $callable($userInfo); } } } diff --git a/crmeb/crmeb/subscribes/OrderSubscribe.php b/crmeb/crmeb/subscribes/OrderSubscribe.php index e87551f2..85d8db35 100644 --- a/crmeb/crmeb/subscribes/OrderSubscribe.php +++ b/crmeb/crmeb/subscribes/OrderSubscribe.php @@ -41,8 +41,8 @@ class OrderSubscribe */ public function onStoreProductOrderDeliveryAfter($event) { - list($data,$oid) = $event; - AdminStoreOrder::orderPostageAfter($oid,$data); + list($data, $oid) = $event; + AdminStoreOrder::orderPostageAfter($oid, $data); } /** @@ -54,8 +54,8 @@ class OrderSubscribe */ public function onStoreProductOrderDeliveryGoodsAfter($event) { - list($data,$oid) = $event; - AdminStoreOrder::orderPostageAfter($oid,$data); + list($data, $oid) = $event; + AdminStoreOrder::orderPostageAfter($oid, $data); } /** @@ -64,8 +64,8 @@ class OrderSubscribe */ public function onStoreProductOrderRefundNAfter($event) { - list($data,$id) = $event; - AdminStoreOrder::refundNoPrieTemplate($id,$data); + list($data, $id) = $event; + AdminStoreOrder::refundNoPrieTemplate($id, $data); } /** @@ -84,7 +84,7 @@ class OrderSubscribe */ public function onStoreProductOrderEditAfter($event) { - list($data,$id) = $event; + list($data, $id) = $event; //$data total_price 商品总价 pay_price 实际支付 //订单编号 $id } @@ -95,7 +95,7 @@ class OrderSubscribe */ public function onStoreProductOrderDistributionAfter($event) { - list($data,$id) = $event; + list($data, $id) = $event; //$data 送货人姓名/快递公司 送货人电话/快递单号 //订单编号 $id } @@ -113,7 +113,7 @@ class OrderSubscribe * 回退所有 未支付和已退款的状态下才可以退积分退库存退优惠券 * @param $event */ - public function onStoreOrderRegressionAllAfter($event) + public function onStoreOrderRegressionAllAfter($event) { list($order) = $event; StoreOrder::RegressionStock($order) && StoreOrder::RegressionIntegral($order) && StoreOrder::RegressionCoupon($order); @@ -125,16 +125,18 @@ class OrderSubscribe */ public function onOrderPaySuccess($event) { - list($order,$formId) = $event; + list($order, $formId) = $event; //更新用户支付订单数量 User::bcInc($order['uid'], 'pay_count', 1, 'uid'); //发送模版消息、客服消息、短信、小票打印给客户和管理员 - NoticeRepositories::noticeOrderPaySuccess($order,$formId); + NoticeRepositories::noticeOrderPaySuccess($order, $formId); //检测会员等级 event('UserLevelAfter', [$order['uid']]); - - //向后台发送新订单消息 - ChannelService::instance()->send('NEW_ORDER', ['order_id'=>$order['order_id']]); + try { + //向后台发送新订单消息 + ChannelService::instance()->send('NEW_ORDER', ['order_id' => $order['order_id']]); + } catch (\Throwable $e) { + } } } \ No newline at end of file diff --git a/crmeb/crmeb/subscribes/ProductSubscribe.php b/crmeb/crmeb/subscribes/ProductSubscribe.php index 4e0ed34c..2005b3ae 100644 --- a/crmeb/crmeb/subscribes/ProductSubscribe.php +++ b/crmeb/crmeb/subscribes/ProductSubscribe.php @@ -1,4 +1,5 @@ controller()) != 'index') SystemLog::adminVisit($adminInfo->id,$adminInfo->account,$type); + list($adminInfo, $type) = $event; + if (strtolower(app('request')->controller()) != 'index') SystemLog::adminVisit($adminInfo->id, $adminInfo->account, $type); } /** @@ -33,7 +35,7 @@ class SystemSubscribe public function onSystemAdminLoginAfter($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']); } /** @@ -42,7 +44,7 @@ class SystemSubscribe */ public function onMerchantRegisterAfter($event) { - list($merchantInfo) = $event; + list($merchantInfo) = $event; } } \ No newline at end of file diff --git a/crmeb/crmeb/subscribes/TaskSubscribe.php b/crmeb/crmeb/subscribes/TaskSubscribe.php index df2c480d..3a0b998d 100644 --- a/crmeb/crmeb/subscribes/TaskSubscribe.php +++ b/crmeb/crmeb/subscribes/TaskSubscribe.php @@ -1,4 +1,5 @@ $spreadId])) $spreadId = 0; $wechatInfo['nickname'] = filterEmoji($wechatInfo['nickname']); 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'); if (!User::be(['uid' => $uid])) { $wechatInfo = WechatUser::where('uid', $uid)->find(); User::setWechatUser($wechatInfo, $spreadId); } else { - if($login_type) $wechatInfo['login_type'] = $login_type; + if ($login_type) $wechatInfo['login_type'] = $login_type; 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'); - if($login_type) $wechatInfo['login_type'] = $login_type; + if ($login_type) $wechatInfo['login_type'] = $login_type; User::updateWechatUser($wechatInfo, $uid); } else { if (isset($wechatInfo['subscribe_scene'])) unset($wechatInfo['subscribe_scene']); @@ -80,7 +80,7 @@ class UserSubscribe // User::where('uid', $wechatInfo['uid']) // ->limit(1)->update(['openid' => $wechatInfo['openid']]); // else - User::setWechatUser($wechatInfo, $spreadId); + User::setWechatUser($wechatInfo, $spreadId); } $uid = WechatUser::openidToUid($openid, 'openid'); // 设置推广关系