public function CombineAccout($phonenum,$openid){
$openid_customerid = $this->where(["openid"=>$openid])->getField("customer_ID");
$phonenum_customerid = $this->where(["phonenum"=>$phonenum])->getField("customer_ID");
$commit = true;
$this->startTrans();
if($phonenum_customerid){//已存在手机账户,转移数据
if(!M("orders")->where(["customerid"=>$phonenum_customerid])->save(["customerid"=>$openid_customerid]))
$commit=false;
if(!$this->where(["customer_ID"=>$phonenum_customerid])->delete())
$commit=false;
}
if(!$this->where(["customer_ID"=>$openid_customerid])->save(["phonenum"=>$phonenum]))
$commit=false;
if($commit)
{
return $this->commit();
}else{
$this->rollback();
return false;
}
}
最佳答案
