作者 郭盛
1 个管道 的构建 通过 耗费 1 秒

修改订单优惠劵问题

... ... @@ -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]);
}
/**
... ...
... ... @@ -25,7 +25,7 @@ class Pay extends Api
parent::_initialize();
$this->options = [
'app_id' => config('app_id'),
'secret' => config('app_secret'),
'secret' => config('app_secrets'),
'payment' => [
'merchant_id' => config('wx_mch_id'),
'key' => config('wx_pay_key'),
... ...
... ... @@ -6534,7 +6534,7 @@
<div class="row mt0 footer">
<div class="col-md-6" align="left">
Generated on 2020-01-17 14:06:34 </div>
Generated on 2020-01-17 14:30:24 </div>
<div class="col-md-6" align="right">
<a href="https://www.fastadmin.net" target="_blank">FastAdmin</a>
</div>
... ...