| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- <?php
- namespace bizHd\notice\classes;
- use biz\base\classes\BaseClass;
- use bizHd\admin\classes\AdminClass;
- use bizHd\purchase\classes\PurchaseClass;
- use bizHd\staff\classes\StaffClass;
- use bizHd\wx\classes\WxOpenClass;
- use common\components\dict;
- use common\components\miniUtil;
- use Yii;
- class NoticeClass extends BaseClass
- {
- //售后结果通知 ssh 20230813
- public static function afterSaleNotice($shop, $refund)
- {
- $result = [];
- $mainId = $shop->mainId ?? 0;
- $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
- $merchant = WxOpenClass::getWxInfo();
- $ptStyle = dict::getDict('ptStyle', 'hd');
- if (getenv('YII_ENV') == 'production') {
- $msgList = dict::getDict('hdMiniMessage');
- } else {
- $msgList = dict::getDict('hdMiniMessageDev');
- }
- $msgId = $msgList['afterSale']['msgId'] ?? '';
- if (empty($msgId)) {
- return $result;
- }
- if (!empty($staffList)) {
- $ids = array_column($staffList, 'adminId');
- if (!empty($ids)) {
- $adminList = AdminClass::getByIds($ids);
- if (!empty($adminList)) {
- $orderSn = $refund->orderSn ?? '';
- $refundType = $refund->refundType ?? 1;
- $name = $refundType == 1 ? '退货退款' : '只退款';
- $addTime = $refund->addTime ?? '';
- $status = $refund->status ?? 0;
- $statusName = '已通过';
- if ($status == 2) {
- $statusName = '已驳回';
- }
- foreach ($adminList as $admin) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (!empty($miniOpenId)) {
- $msg = [
- "thing4" => ["value" => $name],
- "time5" => ["value" => $addTime],
- "character_string3" => ["value" => $orderSn],
- "phrase2" => ["value" => $statusName],
- "thing6" => ["value" => "点击查看详情"],
- ];
- $page = 'pagesPurchase/refundDetail?id=' . $refund->id;
- Yii::info(json_encode($msg));
- $respond = miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
- if (isset($respond['errcode']) && $respond['errcode'] === 0) {
- $result['hasNotice'] = 1;
- }
- }
- }
- }
- }
- }
- return $result;
- }
- //有新的结账单 ssh 20230514
- public static function newClearNotice($shop, $clear)
- {
- $result = [];
- $mainId = $shop->mainId ?? 0;
- $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
- $merchant = WxOpenClass::getWxInfo();
- $ptStyle = dict::getDict('ptStyle', 'hd');
- if (getenv('YII_ENV') == 'production') {
- $msgList = dict::getDict('hdMiniMessage');
- } else {
- $msgList = dict::getDict('hdMiniMessageDev');
- }
- $msgId = $msgList['remindHdClear']['msgId'] ?? '';
- if (empty($msgId)) {
- return $result;
- }
- $num = $clear->num ?? 0;
- $actPrice = $clear->actPrice ?? 0;
- $ghsName = $clear->ghsName ?? '没有';
- if (!empty($staffList)) {
- $ids = array_column($staffList, 'adminId');
- if (!empty($ids)) {
- $adminList = AdminClass::getByIds($ids);
- if (!empty($adminList)) {
- foreach ($adminList as $admin) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (!empty($miniOpenId)) {
- $msg = [
- "thing5" => ["value" => $ghsName],
- "short_thing2" => ["value" => $num . "笔"],
- "amount3" => ["value" => $actPrice],
- "thing4" => ["value" => "点击帮我结下款哦"],
- ];
- $page = 'admin/clear/info?id=' . $clear->id;
- Yii::info(json_encode($msg));
- $respond = miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
- if (isset($respond['errcode']) && $respond['errcode'] === 0) {
- $result['hasNotice'] = 1;
- }
- }
- }
- }
- }
- }
- return $result;
- }
- //采购成功之后小程序通知
- public static function cgSuccessMiniNotice($cgShop, $cg)
- {
- $result = [];
- $mainId = $cgShop->mainId ?? 0;
- $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
- $merchant = WxOpenClass::getWxInfo();
- $ptStyle = dict::getDict('ptStyle', 'hd');
- if (getenv('YII_ENV') == 'production') {
- $msgList = dict::getDict('hdMiniMessage');
- } else {
- $msgList = dict::getDict('hdMiniMessageDev');
- }
- $msgId = $msgList['cgSuccess']['msgId'] ?? '';
- if (empty($msgId)) {
- return $result;
- }
- $ghsName = $cg->ghsName ?? '';
- $bigNum = $cg->bigNum ?? 0;
- $num = '';
- if ($bigNum > 0) {
- $num = $bigNum . '扎';
- }
- $smallNum = $cg->smallNum ?? 0;
- if ($smallNum > 0) {
- $num .= $smallNum . '支';
- }
- $name = "花材" . $num;
- $actPrice = $cg->actPrice ?? 0;
- $payTime = $cg->payTime ?? '';
- $remark = "点击查看详情";
- if (isset($cg->debt) && $cg->debt == 1) {
- $remark = "====点击付款====";
- $name = $name . '【赊账】';
- }
- if (!empty($staffList)) {
- $ids = array_column($staffList, 'adminId');
- if (!empty($ids)) {
- $adminList = AdminClass::getByIds($ids);
- if (!empty($adminList)) {
- foreach ($adminList as $admin) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (!empty($miniOpenId)) {
- $msg = [
- "thing1" => ["value" => $ghsName],
- "thing2" => ["value" => $name],
- "amount3" => ["value" => $actPrice],
- "date4" => ["value" => $payTime],
- "thing5" => ["value" => $remark]
- ];
- $page = 'pagesPurchase/purDetails?id=' . $cg->id;
- $respond = miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
- if (isset($respond['errcode']) && $respond['errcode'] === 0) {
- $result['hasNotice'] = 1;
- }
- }
- }
- }
- }
- }
- return $result;
- }
- //订单发货后小程序通知
- public static function orderFhMiniNotice($order)
- {
- $cgId = $order->purchaseId ?? 0;
- $cg = PurchaseClass::getById($cgId, true);
- if (empty($cg)) {
- return false;
- }
- $result = [];
- $mainId = $cg->mainId ?? 0;
- $staffList = StaffClass::getAllByCondition(['mainId' => $mainId], null, 'adminId');
- $merchant = WxOpenClass::getWxInfo();
- $ptStyle = dict::getDict('ptStyle', 'hd');
- if (getenv('YII_ENV') == 'production') {
- $msgList = dict::getDict('hdMiniMessage');
- } else {
- $msgList = dict::getDict('hdMiniMessageDev');
- }
- $msgId = $msgList['fhNotice']['msgId'] ?? '';
- if (empty($msgId)) {
- return $result;
- }
- $ghsName = $cg->ghsName ?? '';
- $bigNum = $cg->bigNum ?? 0;
- $num = '';
- if ($bigNum > 0) {
- $num = $bigNum . '扎';
- }
- $smallNum = $cg->smallNum ?? 0;
- if ($smallNum > 0) {
- $num .= $smallNum . '支';
- }
- $name = "花材" . $num;
- $orderSn = $cg->orderSn ?? '';
- $sendTime = date("Y-m-d H:i:s");
- $remark = "点击查看详情";
- if (isset($cg->debt) && $cg->debt == 1) {
- $remark = "===点击查看详情===";
- }
- if (!empty($staffList)) {
- $ids = array_column($staffList, 'adminId');
- if (!empty($ids)) {
- $adminList = AdminClass::getByIds($ids);
- if (!empty($adminList)) {
- foreach ($adminList as $admin) {
- $miniOpenId = $admin['miniOpenId'] ?? '';
- if (!empty($miniOpenId)) {
- $msg = [
- "thing12" => ["value" => $ghsName],
- "thing1" => ["value" => $name],
- "character_string2" => ["value" => $orderSn],
- "date3" => ["value" => $sendTime],
- "thing6" => ["value" => $remark]
- ];
- $page = 'pagesPurchase/purDetails?id=' . $cg->id;
- $respond = miniUtil::commonSendSubscribeMessage($merchant, $ptStyle, $msgId, $miniOpenId, $page, $msg);
- if (isset($respond['errcode']) && $respond['errcode'] === 0) {
- $result['hasNotice'] = 1;
- }
- }
- }
- }
- }
- }
- return $result;
- }
- }
|