...
|
...
|
@@ -64,16 +64,37 @@ class Order extends Api |
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
if($param['is_use'] == 1){
|
|
|
|
|
|
if(empty($param['coupon_id'])){
|
|
|
$this->error('优惠劵ID错误');
|
|
|
}
|
|
|
$yong = Db::name('commission')
|
|
|
->where('id',1)
|
|
|
->find();
|
|
|
$youhui = Db::name('coupon')->where('id',$param['coupon_id'])->find();
|
|
|
if($youhui['is_use'] != 0){
|
|
|
$this->error('优惠劵已过期或者已使用');
|
|
|
}
|
|
|
$param['commission'] = $yong['proportion'];
|
|
|
$param['createtime'] = time();
|
|
|
$param['num'] = get_order_sn();
|
|
|
$data = Db::name('order')->insertGetId($param);
|
|
|
if(empty($data)){
|
|
|
$this->error('失败');
|
|
|
}else{
|
|
|
//修改优惠劵为已使用
|
|
|
Db::name('coupon')->where('id',$param['coupon_id'])->update(['is_use'=>1]);
|
|
|
$this->success('success',['order_id'=>$data]);
|
|
|
}
|
|
|
}else{
|
|
|
$yong = Db::name('commission')
|
|
|
->where('id',1)
|
|
|
->find();
|
|
|
$param['commission'] = $yong['proportion'];
|
|
|
$param['createtime'] = time();
|
|
|
$param['num'] = get_order_sn();
|
|
|
$data = Db::name('order')->insertGetId($param);
|
|
|
$this->success('success',['order_id'=>$data]);
|
|
|
}
|
|
|
$yong = Db::name('commission')
|
|
|
->where('id',1)
|
|
|
->find();
|
|
|
$param['commission'] = $yong['proportion'];
|
|
|
$param['createtime'] = time();
|
|
|
$param['num'] = get_order_sn();
|
|
|
$data = Db::name('order')->insertGetId($param);
|
|
|
$this->success('success',['order_id'=>$data]);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|