基于PHP实现商品成交时发送短信功能

2019/6/30 16:39:14

本文主要是介绍基于PHP实现商品成交时发送短信功能,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

最近做了一个项目,其中有需求,要求我们实现此功能:商品成交时发送短信,下面小编贴出核心代码,方面大家以后学习。

html代码省略.....

Model代码省略.....

核心代码如下所示:

  /*
* -------------------------------------------------
* 修改状态 public 
* Author: lzp Time:--
* -------------------------------------------------
*/
public function changeStateAction() {
$id = $_REQUEST['id'];
$result = $this->changeConfirmState($id);
if ($result) {
$this->success("修改成功");
} else {
$this->error("修改失败");
}
}
private function changeConfirmState($id) {
$reg = $this->priceModel->selectPrice(['id'=>['eq', $id]]);
$rel = $this->demandModel->selectDemand(['id'=>['eq',$reg[]['demand_id']]]);
$demand_id = $reg[]['demand_id'];
$reg['demand'] = $this->priceModel->selectPrice(['demand_id'=>['eq',$demand_id]]);
foreach ($reg['demand'] as $key => $value){
if($value['phone'] == $reg[]['phone']){
unset($reg['demand'][$key]);
}else{
$new[] = $value['phone'];
}
}
$new = [''=>'********'];
if((time()-strtotime($rel[]['create_time']))> ){
echo "<script>alert('已超时!');history.back();</script>";
die;
}else if(strtotime($rel[]['finish_time'])>){
echo "<script>alert('已成交!');history.back();</script>";
die;
}else{
$data_demand = [ 'is_available' => , 'finish_time' => date("Y-m-d H:i:s") ];
$result['Price'] = $this->priceModel->savePrice( ['id'=>['eq',$id]], ['state'=>] );
$result['Demadn'] = $this->demandModel->saveDemand(['id'=>['eq',$reg[]['demand_id']]] , $data_demand);
$mobile = implode(",", $new);
$content = "此条需求已成交,下次再来哟!";
smsApp($mobile,$content); //发短信
return $result;
}
} 

以上代码是小编给大家贴的核心的代码,代码还算简单,所以没给大家写太多的注释,大家在参考过程中遇到任何问题,欢迎给我留言,小编会及时回复大家的,在此非常感谢大家对找一找教程网网站的支持!



这篇关于基于PHP实现商品成交时发送短信功能的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程