作者 李忠强

更新

... ... @@ -210,7 +210,23 @@ class Order extends Api
$goods_array[] = $goods;
$sum_price = bcadd($sum_price,bcmul($sku['goods_price'],$value['number'],2),2);
}
$this->success('下单页详情',['list'=>$goods_array,'price'=>$sum_price]);
$addressmodel = new UserAddress();
$address = $addressmodel->where('user_id',$this->auth->id)->where('normal_status','1')->find();
$express_price = 0;
if ($address){
// 计算运费
$lat1 = $address['lat'];
$lng1 = $address['lng'];
$admin_address = Db::name('admin_address')->find();
$lat2 = $admin_address['lat'];
$lng2 = $admin_address['lng'];
$express_price = $this->distancePrice($lat1,$lng1,$lat2,$lng2);
if ($express_price === false) $express_price = 0;
}else{
$address = [];
}
$sum_price += $express_price;
$this->success('下单页详情',['list'=>$goods_array,'price'=>$sum_price,'address'=>$address]);
}
/**
... ...
... ... @@ -11,4 +11,13 @@ class UserMoneyLog extends Model
protected $autoWriteTimestamp = 'int';
protected $createTime = 'createtime';
protected $updateTime = false;
protected $append = [
'createtime_text'
];
public function getCreatetimeTextAttr($value,$data)
{
$value = !empty($data['createtime']) ? date('Y年m月d日 H:i') : '';
return $value;
}
}
\ No newline at end of file
... ...