Commit 711d4fd2 by 朱继来

Merge branch 'zjl_order_msg_20180402' into 'master'

订单审核消息推送

See merge request !27
parents 11573682 52a6dd77
...@@ -752,6 +752,8 @@ Class OrderController extends Controller ...@@ -752,6 +752,8 @@ Class OrderController extends Controller
"order_amount" => $request->input('order_amount', ''), "order_amount" => $request->input('order_amount', ''),
"extra_fee" => $request->input('extra_fee', ''), "extra_fee" => $request->input('extra_fee', ''),
"change_info" => $request->input('change_info', ''), "change_info" => $request->input('change_info', ''),
"payTime" => $request->input('payTime', ''),
"payTimeOther" => $request->input('payTimeOther', ''),
"order_id" => $order_id, "order_id" => $order_id,
"pf" => 1, "pf" => 1,
"k1" => $check['k1'], "k1" => $check['k1'],
...@@ -1235,4 +1237,95 @@ Class OrderController extends Controller ...@@ -1235,4 +1237,95 @@ Class OrderController extends Controller
return $response; return $response;
} }
/**
* 定时任务:提前一天上午10点
* 检查订单付款时间
* 过滤条件:状态、测试人员、是否是真实数据、付款时间大于当前时间
* @return [type] [description]
*/
public function checkOrderSendSms()
{
$order = DB::connection('order')
->table('lie_order')
->whereIn('status', ['2', '3'])
->whereNotIn('user_id', $this->testMobile())
->where('is_type', '=', 0)
->where('pay_time', '>', time())
->select('order_id', 'order_sn', 'user_id', 'order_amount', 'currency', 'pay_time')
->orderBy('create_time', 'DESC')
->get();
//调用消息接口
$url = Config('website.api_domain').'msg/sendmessagebyauto';
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$keyword = 'order-pay-time-remind';
if (!empty($order)) {
foreach ($order as $v) {
// 提前一天推送消息
$diff = $v->pay_time - time();
if ($diff <= 86400) {
$currency = $v->currency == 1 ? '¥' : '$';
$orderInfo['data']['order_sn'] = $v->order_sn;
$orderInfo['data']['order_amount'] = $currency.$v->order_amount;
$orderInfo = json_encode($orderInfo['data'], JSON_UNESCAPED_UNICODE);
$orderData = [
"keyword" => $keyword,
"pf" => 1,
"k1" => $data['k1'],
"k2" => $data['k2'],
'touser' => json_encode($v->user_id),
'data' => $orderInfo,
];
$temp = json_decode(curlApi($url, $orderData, "POST"), true);
if ($temp['err_code'] == 0) {
continue;
}
}
}
}
}
// 定时任务:每5分钟
// 付款时间到达后自动取消订单
public function checkOrderCancel()
{
$time = strtotime(date('Y-m-d', time())); // 当天0点
$order = DB::connection('order')
->table('lie_order')
->whereIn('status', ['2', '3'])
->whereNotIn('user_id', $this->testMobile())
->where('is_type', '=', 0)
->where('pay_time', '>=', $time)
->select('order_id', 'pay_time')
->orderBy('create_time', 'DESC')
->get();
if (!empty($order)) {
foreach ($order as $v) {
// 到达付款时间后自动取消订单
if ($v->pay_time <= time()) {
$update = DB::connection('order')
->table('lie_order')
->where('order_id', '=', $v->order_id)
->update(['status' => -1, 'pay_time' => 0]);
if ($update) {
continue;
}
}
}
}
}
} }
\ No newline at end of file
...@@ -61,3 +61,9 @@ Route::group(['middleware' => 'web'], function () { ...@@ -61,3 +61,9 @@ Route::group(['middleware' => 'web'], function () {
}); });
// 不需要登陆态
Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms');
Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel');
});
...@@ -267,3 +267,31 @@ input[type="color"], ...@@ -267,3 +267,31 @@ input[type="color"],
text-overflow:ellipsis; text-overflow:ellipsis;
margin-bottom: 0; margin-bottom: 0;
} }
#payTime {
float: left;
margin-right: 20px;
}
.customArea {
float: left;
display: none;
}
/* 付款时间 */
.checked_section {
position: relative;
height: 60px;
}
.checked_left {
position: absolute;
left: 0;
}
.checked_right {
position: absolute;
right: 0;
line-height: 60px;
}
.count_time {
color: red;
font-size: 20px;
}
\ No newline at end of file
...@@ -1136,11 +1136,24 @@ ...@@ -1136,11 +1136,24 @@
} }
}) })
// 选择付款时间
$('#payTime').change(function(){
var val = $(this).val();
if (val == 0) {
$('.customArea').show();
} else {
$('.customArea').hide();
}
})
// 提交表单 // 提交表单
$('.checkOrder').click(function(){ $('.checkOrder').click(function(){
var sale_id = $('input[name=sale_id]:checked').val(); var sale_id = $('input[name=sale_id]:checked').val();
var order_status = $('input[name=order_status]:checked').val(); var order_status = $('input[name=order_status]:checked').val();
var reason = $('input[name=reason]:checked').val(); var reason = $('input[name=reason]:checked').val();
var payTime = $('#payTime').val();
var payTimeOther = $('#payTimeOther').val();
if (sale_id == null) { if (sale_id == null) {
layer.msg('请选择业务员!'); layer.msg('请选择业务员!');
...@@ -1193,6 +1206,27 @@ ...@@ -1193,6 +1206,27 @@
return false; return false;
} }
if (payTime == '') {
layer.msg('请选择付款时间');
return false;
}
if (payTime == 0 && payTimeOther == '') {
layer.msg('请填写自定义时间');
return false;
}
var reg = /\d/;
if (!reg.test(payTimeOther)) {
layer.msg('格式错误');
return false;
}
if (payTimeOther < 0 || payTimeOther > 30) {
layer.msg('自定义时间限制在1-30天');
return false;
}
var currencySign = currency == 1 ? '¥' : '$'; var currencySign = currency == 1 ? '¥' : '$';
var goods_amount = currencySign+$('input[name=goods_amount]').val(); var goods_amount = currencySign+$('input[name=goods_amount]').val();
var order_amount = currencySign+$('input[name=order_amount]').val(); var order_amount = currencySign+$('input[name=order_amount]').val();
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
</tr> </tr>
</table> </table>
<hr/>
<!-- 调价 --> <!-- 调价 -->
<p>调价</p> <p>调价</p>
<table class="table table-bordered table-hover order-change-table change-table"> <table class="table table-bordered table-hover order-change-table change-table">
...@@ -126,6 +127,7 @@ ...@@ -126,6 +127,7 @@
</table> </table>
<div class="show-advance-pay"> <div class="show-advance-pay">
<hr/>
<p>定金调整</p> <p>定金调整</p>
<table class="table table-bordered table-hover change-table"> <table class="table table-bordered table-hover change-table">
<tr> <tr>
...@@ -147,16 +149,55 @@ ...@@ -147,16 +149,55 @@
</table> </table>
</div> </div>
<p>付款时间</p>
<table class="table table-bordered table-hover change-table">
<tr>
<th>选择付款时间</th>
<td>
<select name="payTime" id="payTime">
<option value="">请选择</option>
<option value="1">1天</option>
<option value="3">3天</option>
<option value="7">7天</option>
<option value="15">15天</option>
<option value="0">其他</option>
</select>
<div class="customArea">
<input type="text" name="payTimeOther" id="payTimeOther" value="" style="width: 50px;">&nbsp;<span class="error">(自定义天数,限制1~30)</span>
</div>
</td>
</tr>
</table>
<a class="btn btn-primary checkOrder">提交</a> <a class="btn btn-primary checkOrder">提交</a>
</form> </form>
@endif @endif
@if ($order_info['status'] == 2) @if ($order_info['status'] == 2)
<p>交易状态:&nbsp;审核通过,请联系客户及时付款!</p> <div class="checked_section">
<div class="checked_left">
<p>交易状态:&nbsp;审核通过,请联系客户及时付款!
@if ($order_info['pay_time'])
<span>订单付款时间截止至:{{date('Y-m-d H:i:s', $order_info['pay_time'])}}</span>
@endif
</p>
@if ($order_info['adjust_count'] < 2) @if ($order_info['adjust_count'] < 2)
<a class="btn btn-default" href="{{URL('adjustPrice', ['order_id'=>$order_info['order_id']])}}">再次调价</a><span class="warn-tip">每笔订单仅有一次“再次调价”机会</span> <a class="btn btn-default" href="{{URL('adjustPrice', ['order_id'=>$order_info['order_id']])}}">再次调价</a><span class="warn-tip">每笔订单仅有一次“再次调价”机会</span>
@endif @endif
</div>
<div class="checked_right">
<p>
<span class="error">剩余付款时间:</span>
<span class="count_time count_day"></span>
<span class="count_time count_hour"></span>
<span class="count_time count_min"></span>
<span class="count_time count_sec"></span>
</p>
</div>
</div>
@endif @endif
@if ($order_info['status'] == -1) @if ($order_info['status'] == -1)
...@@ -174,4 +215,46 @@ ...@@ -174,4 +215,46 @@
var order_amount = "{{$order_info['order_amount']}}"; var order_amount = "{{$order_info['order_amount']}}";
var currency = "{{$order_info['currency']}}"; var currency = "{{$order_info['currency']}}";
var order_pay_type = "{{$order_info['order_pay_type']}}"; var order_pay_type = "{{$order_info['order_pay_type']}}";
var rest_time = "{{$order_info['pay_time'] ? $order_info['pay_time'] - time() : NULL}}";
if (rest_time) {
countDown(rest_time);
} else {
$('.checked_right').hide();
}
// 倒计时
function countDown(times){
var timer=null;
timer = setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//时间默认值
if (times > 0) {
day = Math.floor(times / (60 * 60 * 24));
hour = Math.floor(times / (60 * 60)) - (day * 24);
minute = Math.floor(times / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(times) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (day <= 9) day = '0' + day;
if (hour <= 9) hour = '0' + hour;
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('.count_day').text(day);
$('.count_hour').text(hour);
$('.count_min').text(minute);
$('.count_sec').text(second);
times--;
}, 1000);
if (times <= 0 ) {
clearInterval(timer);
}
}
</script> </script>
\ No newline at end of file
...@@ -312,7 +312,7 @@ ...@@ -312,7 +312,7 @@
<th>供应商</th> <th>供应商</th>
<?php <?php
if ($action_name == 'changeOrder' && count($order_items_info) > 1) { if ($action_name == 'changeOrder' && count($order_items_info) > 1 && $order_info['status'] == 1) {
echo '<th>操作</th>'; echo '<th>操作</th>';
} }
?> ?>
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
<td>{{$v['delivery_time']}}</td> <td>{{$v['delivery_time']}}</td>
<td>{{$v['supplier_name']}}</td> <td>{{$v['supplier_name']}}</td>
@if ($action_name == 'changeOrder' && count($order_items_info) > 1) @if ($action_name == 'changeOrder' && count($order_items_info) > 1 && $order_info['status'] == 1)
<td><a class="btn btn-danger deletegoods" href="javascript:;" data-id="{{$v['rec_id']}}">删除</a></td> <td><a class="btn btn-danger deletegoods" href="javascript:;" data-id="{{$v['rec_id']}}">删除</a></td>
@endif @endif
</tr> </tr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment