基于PHP实现商品成交时发送短信功能
发布时间:2016-11-27 01:46:21 所属栏目:聚会 来源:网络整理
导读:最近做了一个项目,其中有需求,要求我们实现此功能:商品成交时发送短信,下面小编贴出核心代码,方面大家以后学习。 html代码省略..... Model代码省略..... 核心代码如下所示: /** -------------------------------------------------* 修改状态 public
最近做了一个项目,其中有需求,要求我们实现此功能:商品成交时发送短信,下面小编贴出核心代码,方面大家以后学习。 html代码省略..... Model代码省略..... 核心代码如下所示: /* * ------------------------------------------------- * 修改状态 public * Author: lzp Time:-- * ------------------------------------------------- */ public function changeStateAction() { $id = $_REQUEST['id']; $result = $this-gt;changeConfirmState($id); if ($result) { $this-gt;success("修改成功"); } else { $this-gt;error("修改失败"); } } private function changeConfirmState($id) { $reg = $this-gt;priceModel-gt;selectPrice(['id'=gt;['eq', $id]]); $rel = $this-gt;demandModel-gt;selectDemand(['id'=gt;['eq',$reg[]['demand_id']]]); $demand_id = $reg[]['demand_id']; $reg['demand'] = $this-gt;priceModel-gt;selectPrice(['demand_id'=gt;['eq',$demand_id]]); foreach ($reg['demand'] as $key =gt; $value){ if($value['phone'] == $reg[]['phone']){ unset($reg['demand'][$key]); }else{ $new[] = $value['phone']; } } $new = [''=gt;'********']; if((time()-strtotime($rel[]['create_time']))gt; ){ echo "lt;scriptgt;alert('已超时!');history.back();lt;/scriptgt;"; die; }else if(strtotime($rel[]['finish_time'])gt;){ echo "lt;scriptgt;alert('已成交!');history.back();lt;/scriptgt;"; die; }else{ $data_demand = [ 'is_available' =gt; , 'finish_time' =gt; date("Y-m-d H:i:s") ]; $result['Price'] = $this-gt;priceModel-gt;savePrice( ['id'=gt;['eq',$id]], ['state'=gt;] ); $result['Demadn'] = $this-gt;demandModel-gt;saveDemand(['id'=gt;['eq',$reg[]['demand_id']]] , $data_demand); $mobile = implode(",", $new); $content = "此条需求已成交,下次再来哟!"; smsApp($mobile,$content); //发短信 return $result; } } 以上代码是小编给大家贴的核心的代码,代码还算简单,所以没给大家写太多的注释,大家在参考过程中遇到任何问题,欢迎给我留言,小编会及时回复大家的,在此非常感谢大家对脚本之家网站的支持! (编辑:云计算网_泰州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |