noticeMessageHandle(); return $param; } /** * Common: 权益即将过期通知 * Author: wu-hui * Time: 2023/01/11 10:43 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function noticeMessageHandle(){ // 获取通知列表 $list = $this->getList(); $updateData = []; foreach($list as $item){ // 发送通知 $res = (new AliPayMessage($item['site_id']))->sendMessage($item['member_id'],'INTEREST_EXPIRATION_NOTICE',[ 'store_name' => $item['store_name'],// 商家名称 'surplus' => (int)$item['surplus'],// 剩余次数 'content' => $item['goods_name'],// 优惠内容 ]); // 发送成功 if($res['code'] == 0){ $updateData[] = [ 'id' => $item['id'], 'time_notice' => time(), 'is_notice' => 1, ]; } } (new NewBaseModel(['table_name'=>'member_goods_card_notice']))->saveAll($updateData); } /** * Common: 获取通知列表 * Author: wu-hui * Time: 2023/01/11 10:38 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function getList(){ $list = Db::name('member_goods_card_notice')->alias('mgcn') ->join('member_goods_card mgc','mgcn.member_goods_card = mgc.card_id','left') ->join('store','mgc.store_id = store.store_id','left') ->field('mgcn.id,mgc.site_id,mgc.member_id,mgc.goods_name,(mgc.total_num - mgc.total_use_num) as surplus,store.store_name') ->where('mgcn.id','>',0) ->where('mgcn.is_notice',0) ->order('mgcn.id','ASC') ->limit($this->limit) ->select(); return $list ? $list->toArray() : []; } }