...
|
...
|
@@ -209,6 +209,10 @@ class Update extends Api |
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/Update/OrderPages)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="address_id", type="int", required=true, description="地址ID")
|
|
|
* @ApiParams (name="total", type="int", required=true, description="总价")
|
|
|
* @ApiParams (name="tick", type="int", required=true, description="1=使用优惠,0=不使用优惠")
|
|
|
* @ApiParams (name="water", type="int", required=true, description="1=使用氧气泡泡,0=不适用氧气泡泡")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
...
|
...
|
@@ -217,5 +221,62 @@ class Update extends Api |
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
|
|
|
public function OrderPages()
|
|
|
{
|
|
|
$UserId = $this->is_token($this->request->header());
|
|
|
$Parmas = $this->request->param();
|
|
|
//检测过期优惠券
|
|
|
$this->ExpTick($UserId);
|
|
|
$Tick = 0;
|
|
|
$Water = 0;
|
|
|
$YunPrice = 0;
|
|
|
if ($Parmas['tick'] == 1) {
|
|
|
$Tick = Db::name('tick')->value('del_price');
|
|
|
}
|
|
|
$WaterNum = Db::name('user')->where('user_id', $UserId)->value('num');
|
|
|
if ($Parmas['water'] == 1) {
|
|
|
if ($Parmas['total'] < 199) {
|
|
|
$this->error('订单金额小于199元,无法抵扣');
|
|
|
}
|
|
|
if ($WaterNum / 100 < 100) {
|
|
|
$this->error('氧气泡泡不足100元,无法抵扣');
|
|
|
}
|
|
|
//计算总价20%
|
|
|
if (($WaterNum / 100 > $Parmas['total'] * 0.2) || ($WaterNum / 100 == $Parmas['total'] * 0.2)) {
|
|
|
//大于或等于
|
|
|
$Water = $Parmas['total'] * 0.2;
|
|
|
} else {
|
|
|
//小于
|
|
|
$Water = $WaterNum / 100;
|
|
|
}
|
|
|
}
|
|
|
//运费
|
|
|
$City = Db::name('address')->where('id', $Parmas['address_id'])->value('city');
|
|
|
if (empty($City)) {
|
|
|
$this->error('获取用户地区失败');
|
|
|
}
|
|
|
$Area = explode('/', $City);
|
|
|
$AreaId = Db::name('area')->where('name', $Area[0])->value('id');
|
|
|
$map[] = ['exp', Db::raw("FIND_IN_SET($AreaId,area_ids)")];
|
|
|
$YunArray = Db::name('freight_model')->find();
|
|
|
$YunModel = Db::name('freight_model')->where($map)->find();
|
|
|
if (empty($YunModel)) {
|
|
|
$YunPrice = $YunArray['price'];
|
|
|
}
|
|
|
$NewTotal = $Parmas['total'] - $Tick - $Water + $YunPrice;
|
|
|
$this->success('成功', [
|
|
|
//优惠券优惠金额
|
|
|
'Tick' => $Tick,
|
|
|
//拥有氧气泡泡
|
|
|
'WaterNum' => $WaterNum,
|
|
|
//商品金额
|
|
|
'Total' => $Parmas['total'],
|
|
|
//运费
|
|
|
'YunPrice' => $YunPrice == 0 ? '免运费' : $YunPrice,
|
|
|
//优惠
|
|
|
'HappyPrice' => $Tick + $Water,
|
|
|
//实付
|
|
|
'NewTotal' => $NewTotal
|
|
|
]);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|