123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use think\Db;
- class Timedtask
- {
-
- public function userCouponOver()
- {
- user_coupon_over();
- }
-
- public function goodsOrder()
- {
- $sel_time = time() - 300;
- $order_data = Db::table('goods_order')
- ->where('create_at','< time',date('Y-m-d H:i:s',$sel_time))
- ->where('status','=',0)
- ->where('cancel_state','=',0)
- ->select();
- foreach ($order_data as $order_info) {
- Db::startTrans();
- try {
- Db::table('goods_order')->where(['id'=>$order_info['id']])
- ->update(['status'=>9,'cancel_state'=>1,'cancel_at'=>date('Y-m-d H:i:s'),'cancel_desc'=>'支付超时!自动取消']);
- Db::table('store_goods')->where('id', $order_info['goods_id'])
- ->setInc('stock', $order_info['goods_num']);
- Db::commit();
- }catch (\Exception $e){
- Db::rollback();
- }
- }
- }
-
- public function resolveMagic(){
- resolve_magic();
- }
- }
|