细节优化+订单自动脚本
parent
1b42b5361e
commit
61db80920c
|
|
@ -359,6 +359,9 @@
|
|||
<dt>取消时间</dt>
|
||||
<dd>{{if empty($v['cancel_time'])}}<span class="cr-ddd">未填写</span>{{else /}}{{$v.cancel_time}}{{/if}}</dd>
|
||||
|
||||
<dt>关闭时间</dt>
|
||||
<dd>{{if empty($v['close_time'])}}<span class="cr-ddd">未填写</span>{{else /}}{{$v.close_time}}{{/if}}</dd>
|
||||
|
||||
<dt>创建时间</dt>
|
||||
<dd>{{$v.add_time}}</dd>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,24 @@
|
|||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_order_close_limit_time.name}}<span class="am-form-group-label-tips">{{$data.common_order_close_limit_time.describe}}</span></label>
|
||||
<input type="number" name="{{$data.common_order_close_limit_time.only_tag}}" placeholder="{{$data.common_order_close_limit_time.name}}" data-validation-message="{{$data.common_order_close_limit_time.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_order_close_limit_time.value}}"{{/if}} required />
|
||||
<div class="am-alert am-alert-warning" data-am-alert>
|
||||
<p class="am-text-warning">建议将该地址添加到linux定时任务定时请求即可(结果 sucs:0, fail:0 冒号后面则是处理的数据条数,sucs成功,fali失败)</p>
|
||||
<a href="{{:MyUrl('api/crontab/orderclose')}}" target="_blank">{{:MyUrl('api/crontab/orderclose')}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group">
|
||||
<label>{{$data.common_order_success_limit_time.name}}<span class="am-form-group-label-tips">{{$data.common_order_success_limit_time.describe}}</span></label>
|
||||
<input type="number" name="{{$data.common_order_success_limit_time.only_tag}}" placeholder="{{$data.common_order_success_limit_time.name}}" data-validation-message="{{$data.common_order_success_limit_time.error_tips}}" class="am-radius" {{if !empty($data)}}value="{{$data.common_order_success_limit_time.value}}"{{/if}} required />
|
||||
<div class="am-alert am-alert-warning" data-am-alert>
|
||||
<p class="am-text-warning">建议将该地址添加到linux定时任务定时请求即可(结果 sucs:0, fail:0 冒号后面则是处理的数据条数,sucs成功,fali失败)</p>
|
||||
<a href="{{:MyUrl('api/crontab/ordersuccess')}}" target="_blank">{{:MyUrl('api/crontab/ordersuccess')}}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<input type="hidden" name="nav_type" value="{{$nav_type}}" />
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\service\CrontabService;
|
||||
|
||||
/**
|
||||
* 定时任务
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2019-08-18T17:19:33+0800
|
||||
*/
|
||||
class Crontab extends Common
|
||||
{
|
||||
/**
|
||||
* 订单关闭
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-08-18T17:19:33+0800
|
||||
*/
|
||||
public function OrderClose()
|
||||
{
|
||||
$ret = CrontabService::OrderClose();
|
||||
return 'sucs:'.$ret['data']['sucs'].', fail:'.$ret['data']['fail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-08-18T17:19:33+0800
|
||||
*/
|
||||
public function OrderSuccess()
|
||||
{
|
||||
$ret = CrontabService::OrderSuccess();
|
||||
return 'sucs:'.$ret['data']['sucs'].', fail:'.$ret['data']['fail'];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: Devil
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\service;
|
||||
|
||||
use think\Db;
|
||||
use app\service\OrderService;
|
||||
use app\service\BuyService;
|
||||
use app\service\MessageService;
|
||||
|
||||
/**
|
||||
* 定时任务服务层
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 0.0.1
|
||||
* @datetime 2019-08-18T17:19:33+0800
|
||||
*/
|
||||
class CrontabService
|
||||
{
|
||||
/**
|
||||
* 订单自动关闭
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-08-18T17:22:29+0800
|
||||
* @desc 从订单创建时间开始计算周期
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function OrderClose($params = [])
|
||||
{
|
||||
// 获取可关闭订单
|
||||
$time = time()-intval(MyC('common_order_close_limit_time', 30, true));
|
||||
$where = [
|
||||
['add_time', '<', $time],
|
||||
['status', '=', 1],
|
||||
];
|
||||
$order = Db::name('Order')->where($where)->field('id,status,user_id')->select();
|
||||
|
||||
// 状态
|
||||
$sucs = 0;
|
||||
$fail = 0;
|
||||
if(!empty($order))
|
||||
{
|
||||
// 订单更新数据
|
||||
$upd_data = [
|
||||
'status' => 6,
|
||||
'close_time' => time(),
|
||||
'upd_time' => time(),
|
||||
];
|
||||
foreach($order as $v)
|
||||
{
|
||||
// 开启事务
|
||||
Db::startTrans();
|
||||
unset($where[2]);
|
||||
$where[] = ['id', '=', $v['id']];
|
||||
if(Db::name('Order')->where($where)->update($upd_data))
|
||||
{
|
||||
// 库存回滚
|
||||
$ret = BuyService::OrderInventoryRollback(['order_id'=>$v['id'], 'order_data'=>$upd_data]);
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 用户消息
|
||||
MessageService::MessageAdd($v['user_id'], '订单关闭', '订单超时关闭', 1, $v['id']);
|
||||
|
||||
// 订单状态日志
|
||||
OrderService::OrderHistoryAdd($v['id'], $upd_data['status'], $v['status'], '超时关闭', 0, '系统');
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
$sucs++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 事务回滚
|
||||
Db::rollback();
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
return DataReturn('操作成功', 0, ['sucs'=>$sucs, 'fail'=>$fail]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单自动收货
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-08-18T17:24:05+0800
|
||||
* @desc 从发货时间开始计算周期
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function OrderSuccess($params = [])
|
||||
{
|
||||
// 获取可收货订单
|
||||
$time = time()-intval(MyC('common_order_success_limit_time', 21600, true));
|
||||
$where = [
|
||||
['delivery_time', '<', $time],
|
||||
['status', '=', 3],
|
||||
];
|
||||
$order = Db::name('Order')->where($where)->field('id,status,user_id')->select();
|
||||
|
||||
// 状态
|
||||
$sucs = 0;
|
||||
$fail = 0;
|
||||
if(!empty($order))
|
||||
{
|
||||
// 更新订单状态
|
||||
$upd_data = [
|
||||
'status' => 4,
|
||||
'collect_time' => time(),
|
||||
'upd_time' => time(),
|
||||
];
|
||||
foreach($order as $v)
|
||||
{
|
||||
// 开启事务
|
||||
Db::startTrans();
|
||||
unset($where[2]);
|
||||
$where[] = ['id', '=', $v['id']];
|
||||
if(Db::name('Order')->where($where)->update($upd_data))
|
||||
{
|
||||
// 订单商品积分赠送
|
||||
$ret = IntegralService::OrderGoodsIntegralGiving(['order_id'=>$v['id']]);
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 订单商品销量增加
|
||||
$ret = OrderService::GoodsSalesCountInc(['order_id'=>$v['id']]);
|
||||
if($ret['code'] == 0)
|
||||
{
|
||||
// 用户消息
|
||||
MessageService::MessageAdd($v['user_id'], '订单收货', '订单自动收货成功', 1, $v['id']);
|
||||
|
||||
// 订单状态日志
|
||||
OrderService::OrderHistoryAdd($v['id'], $upd_data['status'], $v['status'], '自动收货', 0, '系统');
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
$sucs++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 事务回滚
|
||||
Db::rollback();
|
||||
$fail++;
|
||||
}
|
||||
}
|
||||
return DataReturn('操作成功', 0, ['sucs'=>$sucs, 'fail'=>$fail]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -35,14 +35,17 @@ return array (
|
|||
'plugins_service_users_center_left_menu_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_header_navigation_top_right_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_order_status_change_history_success_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\distribution\\Hook',
|
||||
1 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_order_aftersale_audit_handle_end' =>
|
||||
array (
|
||||
|
|
@ -50,11 +53,41 @@ return array (
|
|||
),
|
||||
'plugins_css' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\share\\Hook',
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
1 => 'app\\plugins\\share\\Hook',
|
||||
),
|
||||
'plugins_js' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\share\\Hook',
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
1 => 'app\\plugins\\share\\Hook',
|
||||
),
|
||||
'plugins_service_navigation_header_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_goods_detail_panel_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_buy_goods_bottom' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_buy_handle' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_buy_form_inside' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_buy_order_insert_success' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_service_user_register_end' =>
|
||||
array (
|
||||
0 => 'app\\plugins\\coupon\\Hook',
|
||||
),
|
||||
'plugins_view_common_bottom' =>
|
||||
array (
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -111,14 +111,8 @@ class BaiduMini
|
|||
'message' => '请填写平台公钥',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'default' => __MY_URL__.'payment_order_'.strtolower(str_replace(['payment', '\\'], '', get_class($this))).'_notify.php',
|
||||
'name' => 'notify_url',
|
||||
'placeholder' => '异步通知地址',
|
||||
'title' => '异步通知地址',
|
||||
'desc' => '将该地址配置到百度小程序支付后台异步通知',
|
||||
'is_required' => 0,
|
||||
'element' => 'message',
|
||||
'message' => '异步通知地址,将该地址配置到百度小程序支付后台异步通知<br />'.__MY_URL__.'payment_order_'.strtolower(str_replace(['payment', '\\'], '', get_class($this))).'_notify.php',
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue