106 行
4.4 KiB
PHP
可执行文件
106 行
4.4 KiB
PHP
可执行文件
<?php
|
||
|
||
namespace Retail\Controller;
|
||
|
||
use Think\Controller;
|
||
|
||
use Common\Business\Plug;
|
||
use Blessing\Business\Index;
|
||
|
||
//[1.8.20]
|
||
class TimingController extends Controller
|
||
{
|
||
/*
|
||
* 定时任务修改会员等级
|
||
*/
|
||
public function timingTask()
|
||
{
|
||
$stime = time();
|
||
$where['state'] = 1;
|
||
$plus_vip_info = M('retail_plus_vip')->where($where)->select();
|
||
if ($plus_vip_info) {
|
||
$plus_ids = array(); //plus会员表
|
||
$xcx_ids = array(); //普通用户表
|
||
$vip_ids = array(); //常规会员表
|
||
foreach ($plus_vip_info as $key => &$val) {
|
||
if (!empty($val['end_time']) && ($val['end_time'] < $stime)) {
|
||
array_push($plus_ids, $val['id']);
|
||
if (!empty($val['vip_id']) && $val['vip_id'] != 0) {
|
||
array_push($vip_ids, $val['vip_id']);
|
||
}
|
||
if (!empty($val['xcx_vip_id']) && $val['xcx_vip_id'] != 0) {
|
||
array_push($xcx_ids, $val['xcx_vip_id']);
|
||
}
|
||
}
|
||
}
|
||
if (!empty($plus_ids)) {//plus会员过期
|
||
M('retail_plus_vip')->where(array('id' => array('in', $plus_ids)))->save(array('state' => 2));
|
||
}
|
||
if (!empty($xcx_ids)) {//普通成员
|
||
M('retail_xcxvip')->where(array('id' => array('in', $xcx_ids)))->save(array('type' => 3));
|
||
}
|
||
if (!empty($vip_ids)) {
|
||
M('retail_vip')->where(array('id' => array('in', $vip_ids)))->save(array('plus_type' => 3, 'plus_state' => 2));
|
||
}
|
||
}
|
||
}
|
||
|
||
/*
|
||
*定时任务购买成功后多久自动确认收货
|
||
*/
|
||
public function timingReceivingGoods()
|
||
{
|
||
$stime = time();
|
||
$where['status'] = 1;
|
||
$where['state'] = 0;
|
||
$where['modify_order_state'] = 1;
|
||
$storeInfo = M('retail_store')->field("id,modify_order_day")->where($where)->select();
|
||
if ($storeInfo) {
|
||
foreach ($storeInfo as $key => &$val) {
|
||
if (!empty($val['modify_order_day'])) {
|
||
$map = array();
|
||
$difference_time = $stime - (86399 * $val['modify_order_day']);
|
||
$map['b.pay_state'] = 1;
|
||
$map['b.pay_type'] = array('neq', 0);
|
||
$map['b.type'] = 1;
|
||
$map['b.order_type'] = array('in','1,3');
|
||
$map['b.refund_status'] = array('in','0,5');
|
||
$map['b.store_id'] = $val['id'];
|
||
$map['l.status'] = 2;
|
||
$map['l.pickup_type'] = ['in','2,3'];
|
||
$map['l.delivery_time'] = array('elt', $difference_time);
|
||
$orderInfo = M('retail_bill_order as b')
|
||
->join("ls_retail_bill_online as l on b.id=l.bill_id")
|
||
->where($map)
|
||
->field("l.bill_id,b.order_type")
|
||
->select();
|
||
|
||
$plugClass = new Plug();
|
||
//订单信息,判断该门店是否,有,并且开启,祝福语插件
|
||
$storePlugStatusPost = [
|
||
'store_id' => $val['id'],
|
||
'identification_arr' => ['blessing'],
|
||
];
|
||
$storePlugStatus = $plugClass->plugStoreStatus($storePlugStatusPost);//获取状态
|
||
|
||
if ($orderInfo) {
|
||
foreach ($orderInfo as $onlineKey => $onlineVal) {
|
||
M('retail_bill_online')->where(array('bill_id' => $onlineVal['bill_id']))->save(array('status' => 3, 'receiving_goods_time' => $stime));
|
||
if($onlineVal['order_type'] == 3){
|
||
M('retail_bill_order')->where(array('id'=>$onlineVal['bill_id']))->save(array('refund_status'=>2));
|
||
}
|
||
|
||
if ($storePlugStatus === true) {
|
||
//有权限,可以修改有效期
|
||
$index = new Index();
|
||
$index->validityTimeSave($onlineVal['bill_id'],2);//修改有效期:$type == 1:首次扫码(id = 门店id),2:确认订单(id = 订单id)
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
} |