老师,在snapOrder方法中,视频并没有写出返回值,那么在place方法调用时,$orderSnap变量就无法获得对应的值,这是是否有问题?
public function place($uid, $oProducts)
{
// oProducts和products作对比
// products从数据库中查询出来
$this->oProducts = $oProducts;
$this->products = $this->getProductsByOrder($oProducts);
$this->uid = $uid;
$status = $this->getOrderStatus();
if (!$status['pass'])
{
$status['order_id'] = -1;
return $status;
}
// 开始创建订单
$orderSnap = $this->snapOrder($status);
$order = $this->createOrder($orderSnap);
// 订单快照
private function snapOrder($status)
{
$snap = [
'orderPrice' => 0,
'totalCount' => 0,
'pStatus' => [],
'snapAddress' => null,
'snapName' => '',
'snapImg' => ''
];
$snap['orderPrice'] = $status['orderPrice'];
$snap['totalCount'] = $status['totalCount'];
$snap['pStatus'] = $status['pStatusArray'];
$snap['snapAddress'] = json_encode($this->getUserAddress());
$snap['snapName'] = $this->products[0]['name'];
$snap['snapImg'] = $this->products[0]['main_img_url'];
if(count($this->products) > 1){
$snap['snapName'] .= '等';
}
}