|
@@ -169,7 +169,7 @@ class Package extends BaseModel
|
|
|
*/
|
|
|
public static function time_out()
|
|
|
{
|
|
|
- $list = self::where('status',1)->where('add_time','<',strtotime("-".sys_config('order_whole_time')." hour"))->select();
|
|
|
+ $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']);
|
|
@@ -189,13 +189,18 @@ class Package extends BaseModel
|
|
|
{
|
|
|
$data['status'] = 2;
|
|
|
$data['paid'] = 1;
|
|
|
- $list = self::where('pay_time', '<', strtotime("-" . sys_config('order_whole_time') . " hour"))->select()->toArray();
|
|
|
+ $list = self::where('pay_time', '<', strtotime("-" . sys_config('order_whole_time') . " hour"))->where('status',1)->select()->toArray();
|
|
|
self::beginTrans();
|
|
|
try {
|
|
|
foreach ($list as $info) {
|
|
|
$package_income = bcmul($info['price'], bcdiv(sys_config('package_income'), 100, 3), 2);
|
|
|
User::where('uid', $info['to_uid'])->dec('gold', $package_income)->update();
|
|
|
$to_user = User::where('uid', $info['to_uid'])->find();
|
|
|
+ if($to_user['gold']<=0)
|
|
|
+ {
|
|
|
+ User::where('uid', $info['to_uid'])->update(['gold'=>0]);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
UserBill::income('扣除收益', $info['to_uid'], 'gold', 'dec', $package_income, $info['id'], $to_user['gold'], '订单未确认收货系统确认,扣除收益' .$package_income );
|
|
|
if ($info['last_id'] > 0) self::edit(['status' => 4], $info['last_id']);
|
|
|
}
|