商品成交时发送短信

商品成交时发送短信


根据需求:商品成交时发送短信

html代码省略.....

Model代码省略.....

   /*
* -------------------------------------------------
* 修改状态 public
* Author: lzp Time:2016-05-27
* -------------------------------------------------
*/ 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[0]['demand_id']]]);
$demand_id = $reg[0]['demand_id'];
$reg['demand'] = $this->priceModel->selectPrice(['demand_id'=>['eq',$demand_id]]);
foreach ($reg['demand'] as $key => $value){
if($value['phone'] == $reg[0]['phone']){
unset($reg['demand'][$key]);
}else{
$new[] = $value['phone'];
}
}
$new = ['0'=>'136********'];
if((time()-strtotime($rel[0]['create_time']))> 86400){
echo "<script>alert('已超时!');history.back();</script>";
die;
}else if(strtotime($rel[0]['finish_time'])>0){
echo "<script>alert('已成交!');history.back();</script>";
die;
}else{
$data_demand = [ 'is_available' => 2, 'finish_time' => date("Y-m-d H:i:s") ];
$result['Price'] = $this->priceModel->savePrice( ['id'=>['eq',$id]], ['state'=>2] );
$result['Demadn'] = $this->demandModel->saveDemand(['id'=>['eq',$reg[0]['demand_id']]] , $data_demand);
$mobile = implode(",", $new);
$content = "此条需求已成交,下次再来哟!";
smsApp($mobile,$content); //发短信
return $result;
}
}
05-06 02:43