基于PHP實(shí)現(xiàn)商品成交時(shí)發(fā)送短信功能
最近做了一個(gè)項(xiàng)目,其中有需求,要求我們實(shí)現(xiàn)此功能:商品成交時(shí)發(fā)送短信,下面小編貼出核心代碼,方面大家以后學(xué)習(xí)。
html代碼省略.....
Model代碼省略.....
核心代碼如下所示:
/*
* -------------------------------------------------
* 修改狀態(tài) 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('已超時(shí)!');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); //發(fā)短信
return $result;
}
}
以上代碼是小編給大家貼的核心的代碼,代碼還算簡(jiǎn)單,所以沒給大家寫太多的注釋,大家在參考過程中遇到任何問題,歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的,在此非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
PHP設(shè)計(jì)模式(一)工廠模式Factory實(shí)例詳解【創(chuàng)建型】
這篇文章主要介紹了PHP設(shè)計(jì)模式 工廠模式Factory,結(jié)合實(shí)例形式詳細(xì)分析了工廠模式的基本概念、原理、實(shí)現(xiàn)方法與操作注意事項(xiàng),需要的朋友可以參考下2020-05-05
淺析echo(),print(),print_r(),return之間的區(qū)別
這篇文章主要是對(duì)echo(),print(),print_r(),return之間的區(qū)別進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助2013-11-11
php實(shí)現(xiàn)微信支付之現(xiàn)金紅包
這篇文章主要為大家詳細(xì)介紹了php實(shí)現(xiàn)微信支付之現(xiàn)金紅包,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05

