Timetask.php
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace app\api\controller;
use app\common\controller\Api;
/**
* @ApiInternal
*/
class Timetask extends Api
{
protected $noNeedLogin = ['*'];
protected $noNeedRight = ['*'];
/**
* 取消订单
*/
public function orderCancel()
{
$model = new \app\api\model\Order();
$list = $model->where('order_status','10')->where('pay_status','10')->select();
$goodsmodel = new \app\api\model\OrderGoods();
$skumodel = new \app\api\model\GoodsSpec();
foreach ($list as $key => $value){
// 增加库存
$goods = $goodsmodel->where('order_id',$value['id'])->select();
foreach ($goods as $k => $val){
if ($value['deduct_stock_type'] == 10){
$skumodel->where('goods_spec_id',$val['goods_spec_id'])->setInc('stock_num',$val['total_num']);
}
}
}
$model->where('order_status','10')->where('pay_status','10')->isUpdate()->save(['order_status'=>'20']);
}
}