|
@@ -36,7 +36,11 @@ class Package extends BaseModel
|
|
|
$data['last_id'] = $last_id;
|
|
|
$data['price'] = $price;
|
|
|
if(empty($user['phone']) || empty($user['wx_no']) || empty($user['alipay_no'])) return self::setErrorInfo('请点我的到个人中设置,完善信息后下单!');
|
|
|
-
|
|
|
+ if($to_uid==0)
|
|
|
+ {
|
|
|
+ $stock = StoreWholesale::where('id',$whole_id)->value('stock');
|
|
|
+ if($stock<1) return self::setErrorInfo('库存不足!');
|
|
|
+ }
|
|
|
if(cache('reserve_'.$uid,1) && false) return self::setErrorInfo('你已报名,无需重复报名');
|
|
|
if($last_id>0 && self::where('last_id',$last_id)->where('uid',$uid)->find())
|
|
|
{
|
|
@@ -75,7 +79,10 @@ class Package extends BaseModel
|
|
|
$res = self::create($data);
|
|
|
User::where('uid',$uid)->dec('gold',$integral)->update();
|
|
|
UserBill::expend("预约扣金豆",$uid,'gold','pay_money',$integral,$res['id'],bcsub($user['gold'],$integral,2),'预约扣除'.$integral."金豆");
|
|
|
- if($last_id==0) User::edit(['is_whole'=>1],$uid);
|
|
|
+ if($last_id==0) {
|
|
|
+ User::edit(['is_whole' => 1], $uid);
|
|
|
+ StoreWholesale::where('id',$whole_id)->inc('sales',1)->dec('stock',1)->update();
|
|
|
+ }
|
|
|
if($last_id>0) self::where('id',$last_id)->update(['status'=>3]);
|
|
|
self::commitTrans();
|
|
|
return $res->toArray();
|
|
@@ -175,7 +182,7 @@ class Package extends BaseModel
|
|
|
$list = self::where('status',0)->where('add_time','<',strtotime("-".sys_config('order_whole_time')." hour"))->select();
|
|
|
foreach ($list as $v)
|
|
|
{
|
|
|
- if($v['last_id']>0) self::edit(['status'=>2],$v['last_id']);
|
|
|
+ if($v['last_id']>0) self::edit(['status'=>2],$v['last_id']); else StoreWholesale::where('id',$v['whole_id'])->dec('sales',1)->inc('stock',1)->update();
|
|
|
self::edit(['status'=>-2],$v['id']);
|
|
|
}
|
|
|
return true;
|