修改订单逻辑
This commit is contained in:
@@ -19,7 +19,8 @@ class Order extends ApiBase
|
||||
public $like_not_need_login = ['wxmassin', 'lists', 'appInit', 'downLine', 'share', 'config', 'pcLists', 'getpege', 'ttorder'];
|
||||
|
||||
//抖音订单回调
|
||||
public function ttorder(){
|
||||
public function ttorder()
|
||||
{
|
||||
$ttPay = new ttPay();
|
||||
$res = $ttPay->run('notify');
|
||||
}
|
||||
@@ -87,11 +88,9 @@ class Order extends ApiBase
|
||||
|
||||
$action = $post['action'];
|
||||
|
||||
|
||||
$info = OrderLogic::info($post, $this->user_id);
|
||||
|
||||
|
||||
|
||||
if ($info['code'] == 0) {
|
||||
$this->_error($info['msg']);
|
||||
}
|
||||
@@ -181,7 +180,8 @@ class Order extends ApiBase
|
||||
}
|
||||
|
||||
|
||||
public function get3day(){
|
||||
public function get3day()
|
||||
{
|
||||
$goods_id = $this->request->post('id');
|
||||
$order = Db::name('order')->where('id', $goods_id)->find(); //获取到订单的信息
|
||||
$goods = Db::name('goods')->where('id', $order['goods_id'])->find(); //获取到商品的信息
|
||||
@@ -232,7 +232,6 @@ class Order extends ApiBase
|
||||
$lentuserxw = array_column($lentxw, 'user_id');
|
||||
|
||||
|
||||
|
||||
//判断下午
|
||||
$numberxw = Db::name('staff')
|
||||
->where('onwork', 1)
|
||||
@@ -267,7 +266,8 @@ class Order extends ApiBase
|
||||
|
||||
}
|
||||
|
||||
public function getday(){
|
||||
public function getday()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
|
||||
$order = Db::name('order')->where('id', $post['data']['id'])->find(); //获取到订单的信息
|
||||
@@ -277,7 +277,6 @@ class Order extends ApiBase
|
||||
$end = strtotime($day . ' 23:59:59');
|
||||
|
||||
|
||||
|
||||
//统计这个时间请假的用户的数据
|
||||
$orders = Db::name('order_exe')->where('addtime', 1)->where('autotime', '>=', $start)->where('autotime', '<=', $end)->whereNotNull('staff_id')->field('staff_id')->group('staff_id')->select(); //查询有订单的保洁师傅
|
||||
$oneDimensionalArray = array_column($orders, 'staff_id'); // 根据自己的表格字段名修改'字段名'部分
|
||||
@@ -305,9 +304,6 @@ class Order extends ApiBase
|
||||
$lentuserxw = array_column($lentxw, 'user_id');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//判断下午
|
||||
$numberxw = Db::name('staff')
|
||||
->where('onwork', 1)
|
||||
@@ -342,13 +338,17 @@ class Order extends ApiBase
|
||||
$this->_success('获取成功', $data);
|
||||
}
|
||||
|
||||
public function sendgzhmsg($orderid = ''){
|
||||
public function sendgzhmsg($orderid = '')
|
||||
{
|
||||
$uid = $this->user_id;
|
||||
// $uid = 366;
|
||||
$openids = Db::name('user_auth')->where('user_id', $uid)->find(); //获取用户的ID
|
||||
$adder = Db::name('user_address')->where('user_id', $uid)->find();
|
||||
// $openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$openid = $openids['openid'] ?? null;
|
||||
if (!$openid) {
|
||||
return false; // 未绑定公众号
|
||||
}
|
||||
$data = [
|
||||
'touser' => $openid,
|
||||
'url' => '',
|
||||
@@ -371,208 +371,326 @@ class Order extends ApiBase
|
||||
|
||||
}
|
||||
|
||||
public function shensatff($id){
|
||||
public function shensatff($id)
|
||||
{
|
||||
dump($id);
|
||||
|
||||
}
|
||||
|
||||
public function putday(){
|
||||
// public function putday()
|
||||
// {
|
||||
// $post = $this->request->post();
|
||||
// $sw = $post['data']['hourLists'][0]['select'];
|
||||
// $xw = $post['data']['hourLists'][1]['select'];
|
||||
// $orderid = $post['data']['id']; //传递进来的订单id
|
||||
// $day = $post['data']['date'];
|
||||
// $order = Db::name('order')->where('id', $orderid)->find(); //获取到订单的基本信息
|
||||
// $goods = Db::name('goods')->where('id', $order['goods_id'])->find();
|
||||
// if ($order['code'] <= 0) {
|
||||
// $this->_error('订单次数已不足无法预约');
|
||||
// }
|
||||
//
|
||||
// if ($sw && $xw) {
|
||||
// $code = Db::name('order')->where('id', $orderid)->find();
|
||||
// if ($code['code'] <= 2) {
|
||||
// return 20;
|
||||
// } else {
|
||||
// $data = [
|
||||
// 'order_sn' => $order['order_sn'], //订单编号
|
||||
// 'create_time' => time(),
|
||||
// // 'fworder_sn'=> $post['fworder_sn'],
|
||||
// 'date' => $day,
|
||||
// 'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
// 'type' => 3,
|
||||
// 'status' => 0,
|
||||
// 'addtime' => 1,
|
||||
// 'autotime' => strtotime($day),
|
||||
// ];
|
||||
// $list = Db::name('order_exe')->data($data)->insert();
|
||||
// $datas = [
|
||||
// 'order_sn' => $order['order_sn'], //订单编号
|
||||
// 'create_time' => time(),
|
||||
// // 'fworder_sn'=> $post['fworder_sn'],
|
||||
// 'date' => $day,
|
||||
// 'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
// 'type' => 3,
|
||||
// 'status' => 0,
|
||||
// 'addtime' => 2,
|
||||
// 'autotime' => strtotime($day),
|
||||
// ];
|
||||
// $list = Db::name('order_exe')->data($datas)->insert();
|
||||
// $order = Db::name('order')->where('id', $orderid)->update(['code' => $order['code'] - 2]); //获取到订单的基本信息
|
||||
// $this->sendgzhmsg($day);
|
||||
// if ($order['admin_id'] != NULL) {
|
||||
// $admin = Db::name('admin')->where('id', $order['admin_id'])->find();
|
||||
// $openids = Db::name('user_auth')->where('user_id', $admin['user_id'])->find(); //获取用户的ID
|
||||
// //$time=date('Y-m-d',$orders['autotime']);
|
||||
// //$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
// $openid = $openids['openid'];
|
||||
// if ($openid != null)
|
||||
// {
|
||||
// $data = [
|
||||
// 'touser' => $openid,
|
||||
// 'url' => '',
|
||||
// 'template_id' => '9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
// 'data' => [
|
||||
// 'keyword1' => [
|
||||
// 'value' => $order['order_sn']
|
||||
// ],
|
||||
// 'keyword2' => [
|
||||
// 'value' => $goods['name']
|
||||
// ],
|
||||
// 'keyword3' => [
|
||||
// 'value' => $order['consignee']
|
||||
// ],
|
||||
// 'keyword4' => [
|
||||
// 'value' => $order['mobile']
|
||||
// ],
|
||||
// 'keyword5' => [
|
||||
// 'value' => $day
|
||||
// ],
|
||||
//
|
||||
// ]
|
||||
// ];
|
||||
// $config = WeChatServer::getOaConfig();
|
||||
// $app = Factory::officialAccount($config);
|
||||
// $r = $app->template_message->send($data);
|
||||
// }
|
||||
// }
|
||||
// $this->_success('预约成功,待上门', $list);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// if ($sw) {
|
||||
// if ($order > 0) {
|
||||
// $data = [
|
||||
// 'order_sn' => $order['order_sn'], //订单编号
|
||||
// 'create_time' => time(),
|
||||
// // 'fworder_sn'=> $post['fworder_sn'],
|
||||
// 'date' => $day,
|
||||
// 'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
// 'type' => 3,
|
||||
// 'status' => 0,
|
||||
// 'addtime' => 1,
|
||||
// 'autotime' => strtotime($day),
|
||||
// ];
|
||||
// $list = Db::name('order_exe')->data($data)->insert();
|
||||
//
|
||||
// $orderss = Db::name('order')->where('id', $orderid)->update(['code' => $order['code'] - 1]);
|
||||
// //获取到订单的基本信息
|
||||
// $this->sendgzhmsg($day);
|
||||
// if ($order['admin_id'] != null) {
|
||||
// $admin = Db::name('admin')->where('id', $order['admin_id'])->find();
|
||||
// $openids = Db::name('user_auth')->where('user_id', $admin['user_id'])->find(); //获取用户的ID
|
||||
// //$time=date('Y-m-d',$orders['autotime']);
|
||||
// //$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
// $openid = $openids['openid'];
|
||||
// if ($openid != null)
|
||||
// {
|
||||
// $data = [
|
||||
// 'touser' => $openid,
|
||||
// 'url' => '',
|
||||
// 'template_id' => '9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
// 'data' => [
|
||||
// 'keyword1' => [
|
||||
// 'value' => $order['order_sn']
|
||||
// ],
|
||||
// 'keyword2' => [
|
||||
// 'value' => $goods['name']
|
||||
// ],
|
||||
// 'keyword3' => [
|
||||
// 'value' => $order['consignee']
|
||||
// ],
|
||||
// 'keyword4' => [
|
||||
// 'value' => $order['mobile']
|
||||
// ],
|
||||
// 'keyword5' => [
|
||||
// 'value' => $day . '.8:00-12:00'
|
||||
// ],
|
||||
//
|
||||
// ]
|
||||
// ];
|
||||
// $config = WeChatServer::getOaConfig();
|
||||
// $app = Factory::officialAccount($config);
|
||||
// $r = $app->template_message->send($data);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// $this->_success('预约成功,待上门', $list);
|
||||
// } else {
|
||||
// return 20;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// if ($xw) {
|
||||
// if ($order > 0) {
|
||||
// $data = [
|
||||
// 'order_sn' => $order['order_sn'], //订单编号
|
||||
// 'create_time' => time(),
|
||||
// // 'fworder_sn'=> $post['fworder_sn'],
|
||||
// 'date' => $day,
|
||||
// 'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
// 'type' => 3,
|
||||
// 'status' => 0,
|
||||
// 'addtime' => 2,
|
||||
// 'autotime' => strtotime($day),
|
||||
// ];
|
||||
// $list = Db::name('order_exe')->data($data)->insert();
|
||||
// $order = Db::name('order')->where('id', $orderid)->update(['code' => $order['code'] - 1]); //获取到订单的基本信息
|
||||
// $this->sendgzhmsg($day);
|
||||
// if ($order['admin_id'] != NULL) {
|
||||
// $admin = Db::name('admin')->where('id', $order['admin_id'])->find();
|
||||
// $openids = Db::name('user_auth')->where('user_id', $admin['user_id'])->find(); //获取用户的ID
|
||||
// //$time=date('Y-m-d',$orders['autotime']);
|
||||
// //$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
// $openid = $openids['openid'];
|
||||
// if ( $openid != null)
|
||||
// {
|
||||
// //发送预约成功消息
|
||||
// $data = [
|
||||
// 'touser' => $openid,
|
||||
// 'url' => '',
|
||||
// 'template_id' => '9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
// 'data' => [
|
||||
// 'keyword1' => [
|
||||
// 'value' => $order['order_sn']
|
||||
// ],
|
||||
// 'keyword2' => [
|
||||
// 'value' => $goods['name']
|
||||
// ],
|
||||
// 'keyword3' => [
|
||||
// 'value' => $order['consignee']
|
||||
// ],
|
||||
// 'keyword4' => [
|
||||
// 'value' => $order['mobile']
|
||||
// ],
|
||||
// 'keyword5' => [
|
||||
// 'value' => $day . '.14:00-16:00'
|
||||
// ],
|
||||
//
|
||||
// ]
|
||||
// ];
|
||||
// $config = WeChatServer::getOaConfig();
|
||||
// $app = Factory::officialAccount($config);
|
||||
// $r = $app->template_message->send($data);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// $this->_success('预约成功,待上门', $list);
|
||||
// } else {
|
||||
// return 20;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public function putday()
|
||||
{
|
||||
$post = $this->request->post();
|
||||
$sw = $post['data']['hourLists'][0]['select'];
|
||||
$xw = $post['data']['hourLists'][1]['select'];
|
||||
$orderid=$post['data']['id']; //传递进来的订单id
|
||||
$day = $post['data']['date'];
|
||||
$order=Db::name('order')->where('id',$orderid)->find(); //获取到订单的基本信息
|
||||
$hourLists = $post['data']['hourLists'] ?? [];
|
||||
$orderid = $post['data']['id'] ?? 0;
|
||||
$day = $post['data']['date'] ?? '';
|
||||
if (!$orderid || !$day || count($hourLists) < 2) {
|
||||
$this->_error('参数错误');
|
||||
}
|
||||
// 时间段选择
|
||||
$sw = !empty($hourLists[0]['select']); // 上午
|
||||
$xw = !empty($hourLists[1]['select']); // 下午
|
||||
if (!$sw && !$xw) {
|
||||
$this->_error('请选择预约时间段');
|
||||
}
|
||||
// 获取订单
|
||||
$order = Db::name('order')->where('id', $orderid)->find();
|
||||
if (!$order) {
|
||||
$this->_error('订单不存在');
|
||||
}
|
||||
// 获取商品
|
||||
$goods = Db::name('goods')->where('id', $order['goods_id'])->find();
|
||||
if($order['code']<=0){
|
||||
$this->_error('订单次数已不足无法预约');
|
||||
}
|
||||
|
||||
if($sw && $xw){
|
||||
$code=Db::name('order')->where('id',$orderid)->find();
|
||||
if($code['code']<=2){
|
||||
return 20;
|
||||
}else{
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>1,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$datas=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
'create_time'=>time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date'=>$day,
|
||||
'xq'=>$this->Get_Chinese_WeekDay($day),
|
||||
'type'=>3,
|
||||
'status'=>0,
|
||||
'addtime'=>2,
|
||||
'autotime'=>strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($datas)->insert();
|
||||
$order=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-2]); //获取到订单的基本信息
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
}
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
|
||||
}
|
||||
// 需要扣的次数
|
||||
$needCode = ($sw && $xw) ? 2 : 1;
|
||||
if ($order['code'] < $needCode) {
|
||||
$this->_error('订单次数不足,无法预约');
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
// 上午
|
||||
if ($sw) {
|
||||
if($order>0){
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
Db::name('order_exe')->insert([
|
||||
'order_sn' => $order['order_sn'],
|
||||
'create_time'=> time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date' => $day,
|
||||
'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
'type' => 3,
|
||||
'status' => 0,
|
||||
'addtime' => 1,
|
||||
'autotime' => strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$orderss=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-1]); //获取到订单的基本信息
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
$admin=Db::name('admin')->where('id',$order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
$data = [
|
||||
'touser'=>$openid,
|
||||
'url'=>'',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'data'=>[
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day.'.8:00-12:00'
|
||||
],
|
||||
|
||||
]
|
||||
];
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
}
|
||||
|
||||
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
}else{
|
||||
return 20;
|
||||
}
|
||||
|
||||
'goods_id' => $goods['id'],
|
||||
]);
|
||||
}
|
||||
// 下午
|
||||
if ($xw) {
|
||||
if($order>0){
|
||||
$data=[
|
||||
'order_sn'=>$order['order_sn'], //订单编号
|
||||
Db::name('order_exe')->insert([
|
||||
'order_sn' => $order['order_sn'],
|
||||
'create_time'=> time(),
|
||||
// 'fworder_sn'=> $post['fworder_sn'],
|
||||
'date' => $day,
|
||||
'xq' => $this->Get_Chinese_WeekDay($day),
|
||||
'type' => 3,
|
||||
'status' => 0,
|
||||
'addtime' => 2,
|
||||
'autotime' => strtotime($day),
|
||||
];
|
||||
$list=Db::name('order_exe')->data($data)->insert();
|
||||
$order=Db::name('order')->where('id',$orderid)->update(['code'=>$order['code']-1]); //获取到订单的基本信息
|
||||
'goods_id' => $goods['id'],
|
||||
]);
|
||||
}
|
||||
// 扣次数
|
||||
Db::name('order')
|
||||
->where('id', $orderid)
|
||||
->update(['code' => $order['code'] - $needCode]);
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$this->_error('预约失败,请稍后重试');
|
||||
}
|
||||
// 公众号通知
|
||||
$this->sendgzhmsg($day);
|
||||
if($order['admin_id']!=NULL){
|
||||
// 通知管理员
|
||||
if (!empty($order['admin_id'])) {
|
||||
$admin = Db::name('admin')->where('id', $order['admin_id'])->find();
|
||||
$openids=Db::name('user_auth')->where('user_id',$admin['user_id'])->find(); //获取用户的ID
|
||||
//$time=date('Y-m-d',$orders['autotime']);
|
||||
//$openid = 'o_XDv5_Cq72XDOx1qvzq2kcaOYWA';
|
||||
$openid = $openids['openid'];
|
||||
if ($admin) {
|
||||
$openids = Db::name('user_auth')->where('user_id', $admin['user_id'])->find();
|
||||
$openid = $openids['openid'] ?? null;
|
||||
if ($openid) {
|
||||
$timeStr = $sw && $xw
|
||||
? $day
|
||||
: ($sw ? $day . ' 8:00-12:00' : $day . ' 14:00-16:00');
|
||||
|
||||
$data = [
|
||||
'touser' => $openid,
|
||||
'url' => '',
|
||||
'template_id'=>'9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo', //模板id
|
||||
'template_id' => '9ESlNoZweXTioNwyaDuSY9fIXCKhnrBi2Gu0Hl8cmAo',
|
||||
'data' => [
|
||||
'keyword1'=>[
|
||||
'value'=>$order['order_sn']
|
||||
],
|
||||
'keyword2'=>[
|
||||
'value'=>$goods['name']
|
||||
],
|
||||
'keyword3'=>[
|
||||
'value'=>$order['consignee']
|
||||
],
|
||||
'keyword4'=>[
|
||||
'value'=>$order['mobile']
|
||||
],
|
||||
'keyword5'=>[
|
||||
'value'=>$day.'.14:00-16:00'
|
||||
],
|
||||
|
||||
'keyword1' => ['value' => $order['order_sn']],
|
||||
'keyword2' => ['value' => $goods['name'] ?? ''],
|
||||
'keyword3' => ['value' => $order['consignee']],
|
||||
'keyword4' => ['value' => $order['mobile']],
|
||||
'keyword5' => ['value' => $timeStr],
|
||||
]
|
||||
];
|
||||
|
||||
$config = WeChatServer::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$r = $app->template_message->send($data);
|
||||
$app->template_message->send($data);
|
||||
}
|
||||
|
||||
$this->_success('预约成功,待上门', $list);
|
||||
}else{
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_success('预约成功,待上门');
|
||||
}
|
||||
|
||||
|
||||
//保洁师开始接单
|
||||
public function take(){
|
||||
public function take()
|
||||
{
|
||||
$order_id = $this->request->post('params');
|
||||
$order = Db::name('order_exe')->where('id', $order_id)->find();
|
||||
if ($order['autotime'] - time() > 24 * 3600) {
|
||||
@@ -584,14 +702,16 @@ class Order extends ApiBase
|
||||
}
|
||||
|
||||
//保洁师开始接单
|
||||
public function wego(){
|
||||
public function wego()
|
||||
{
|
||||
$order_id = $this->request->post('params');
|
||||
$toke = Db::name('order_exe')->where('id', $order_id)->update(['status' => 1, 'timeadd' => time(), 'staff_status' => 1]);
|
||||
$this->_success('接单成功');
|
||||
}
|
||||
|
||||
//保洁师结束服务
|
||||
public function ends(){
|
||||
public function ends()
|
||||
{
|
||||
$order_id = $this->request->post('params');
|
||||
$toke = Db::name('order_exe')->where('id', $order_id)->update(['status' => 2, 'timeout' => time(), 'staff_status' => 1]);
|
||||
$this->_success('接单成功');
|
||||
@@ -599,16 +719,18 @@ class Order extends ApiBase
|
||||
|
||||
//订单的详情显示
|
||||
|
||||
public function orderinfo(){
|
||||
public function orderinfo()
|
||||
{
|
||||
$type = $this->request->post('type', 'all');
|
||||
$post = $this->request->post();
|
||||
$order_sn=$post['id']['order_sn'];
|
||||
$order_sn = $post['id'];
|
||||
$order_list = OrderLogic::orderinfo($this->user_id, $type, $order_sn, $this->page_no, $this->page_size);
|
||||
$this->_success('获取成功', $order_list);
|
||||
}
|
||||
|
||||
//微信的通知
|
||||
public function wxmassin(){
|
||||
public function wxmassin()
|
||||
{
|
||||
|
||||
$start = strtotime(date("Y-m-d", strtotime("+1 day")));
|
||||
$end = $start + 24 * 3600 - 1;
|
||||
@@ -660,10 +782,10 @@ class Order extends ApiBase
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function getpege(){
|
||||
public function getpege()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$date = Db::name('pageweb')->where('id', $id)->find();
|
||||
$this->_success('获取数据成功', $date);
|
||||
@@ -673,29 +795,34 @@ class Order extends ApiBase
|
||||
|
||||
}
|
||||
|
||||
Class ttPay{
|
||||
class ttPay
|
||||
{
|
||||
|
||||
private $api_url = 'https://developer.toutiao.com/api/apps/ecpay/v1/';
|
||||
private $app_id;
|
||||
private $token;
|
||||
private $salt;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct()
|
||||
{
|
||||
$this->app_id = 'tt0523739e9a12236501';
|
||||
$this->token = '123qazqweeesdflomswwe';
|
||||
$this->salt = 'ejAuHvbI472euyhb34aVyLD92ll9tgZCqWnMi0tX';
|
||||
}
|
||||
|
||||
public function run($action,$order = null){
|
||||
public function run($action, $order = null)
|
||||
{
|
||||
$action = $action ? $action : 'order';
|
||||
if (!in_array($action, ['order', 'query', 'refund', 'settle', 'notify', 'set'])) {
|
||||
echo '非法请求';die;
|
||||
echo '非法请求';
|
||||
die;
|
||||
}
|
||||
return $this->$action($order);
|
||||
}
|
||||
|
||||
//下单
|
||||
private function order($order){
|
||||
private function order($order)
|
||||
{
|
||||
$data = [
|
||||
'out_order_no' => $order['order_sn'],
|
||||
'total_amount' => 1,
|
||||
@@ -708,16 +835,19 @@ Class ttPay{
|
||||
}
|
||||
|
||||
//查询订单
|
||||
private function query(){
|
||||
private function query()
|
||||
{
|
||||
$data = [
|
||||
'out_order_no' => '2021110117254573565'
|
||||
];
|
||||
$res = $this->post('query_order', $data, false);
|
||||
echo json_encode($res);die;
|
||||
echo json_encode($res);
|
||||
die;
|
||||
}
|
||||
|
||||
//订单退款
|
||||
private function refund(){
|
||||
private function refund()
|
||||
{
|
||||
$data = [
|
||||
'out_order_no' => '2021110118351347832',
|
||||
'out_refund_no' => $this->order_number(),
|
||||
@@ -725,11 +855,13 @@ Class ttPay{
|
||||
'refund_amount' => 1,
|
||||
];
|
||||
$res = $this->post('create_refund', $data);
|
||||
echo json_encode($res);die;
|
||||
echo json_encode($res);
|
||||
die;
|
||||
}
|
||||
|
||||
//订单分账
|
||||
private function settle(){
|
||||
private function settle()
|
||||
{
|
||||
$data = [
|
||||
'out_order_no' => '2021110118301265990',
|
||||
'out_settle_no' => $this->order_number(),
|
||||
@@ -737,17 +869,20 @@ Class ttPay{
|
||||
'settle_params' => json_encode([]),//分润方参数 如[['merchant_uid'=>'商户号','amount'=>'10']] 可以有多个分账商户
|
||||
];
|
||||
$res = $this->post('settle', $data);
|
||||
echo json_encode($res);die;
|
||||
echo json_encode($res);
|
||||
die;
|
||||
}
|
||||
|
||||
//支付设置回调测试
|
||||
private function set(){
|
||||
private function set()
|
||||
{
|
||||
$content = file_get_contents('php://input');
|
||||
$this->log('log.txt', $content);
|
||||
}
|
||||
|
||||
//回调
|
||||
private function notify(){
|
||||
private function notify()
|
||||
{
|
||||
$content = input();
|
||||
|
||||
if (empty($content)) return false;
|
||||
@@ -789,7 +924,8 @@ Class ttPay{
|
||||
* 测试订单号,实际应用根据自己应用实际生成
|
||||
* @return string
|
||||
*/
|
||||
private function order_number(){
|
||||
private function order_number()
|
||||
{
|
||||
return date('YmdHis') . rand(10000, 99999);
|
||||
}
|
||||
|
||||
@@ -800,7 +936,8 @@ Class ttPay{
|
||||
* @param boolean $notify 是否有回调
|
||||
* @return array
|
||||
*/
|
||||
private function post($method,$data,$notify=true){
|
||||
private function post($method, $data, $notify = true)
|
||||
{
|
||||
$data['app_id'] = $this->app_id;
|
||||
|
||||
$data['sign'] = $this->sign($data);
|
||||
@@ -815,7 +952,8 @@ Class ttPay{
|
||||
* @param array $map 验签参数
|
||||
* @return stirng
|
||||
*/
|
||||
private function handler($map){
|
||||
private function handler($map)
|
||||
{
|
||||
$rList = array();
|
||||
array_push($rList, $this->token);
|
||||
foreach ($map as $k => $v) {
|
||||
@@ -835,7 +973,8 @@ Class ttPay{
|
||||
* @param array $map 请求参数
|
||||
* @return stirng
|
||||
*/
|
||||
private function sign($map) {
|
||||
private function sign($map)
|
||||
{
|
||||
$rList = array();
|
||||
foreach ($map as $k => $v) {
|
||||
if ($k == "other_settle_params" || $k == "app_id" || $k == "sign" || $k == "thirdparty_id")
|
||||
@@ -859,15 +998,14 @@ Class ttPay{
|
||||
* @param string $path 日志路径
|
||||
* @param string $content 内容
|
||||
*/
|
||||
private function log($path, $content){
|
||||
private function log($path, $content)
|
||||
{
|
||||
$file = fopen($path, "a");
|
||||
fwrite($file, date('Y-m-d H:i:s') . '-----' . $content . "\n");
|
||||
fclose($file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 网络请求
|
||||
* @param stirng $method 请求模式
|
||||
@@ -877,7 +1015,8 @@ Class ttPay{
|
||||
* @param boolean $multi 文件上传
|
||||
* @return array
|
||||
*/
|
||||
private function http( $method = 'GET', $url,$params,$header = array(), $multi = false){
|
||||
private function http($method = 'GET', $url, $params, $header = array(), $multi = false)
|
||||
{
|
||||
|
||||
$opts = array(
|
||||
CURLOPT_TIMEOUT => 30,
|
||||
|
||||
@@ -120,7 +120,9 @@ class OrderLogic extends LogicBase
|
||||
|
||||
$order_amount += $total_shipping_price;//应付订单金额+运费
|
||||
$total_amount += $total_shipping_price;//订单金额+运费
|
||||
|
||||
if ($post['goods_type'] == 4){
|
||||
self::$order_type = CommonOrder::GROUP_ORDER;//普通订单
|
||||
}
|
||||
$result = [
|
||||
'order_type' => self::$order_type,
|
||||
'goods_lists' => array_values($goods_lists),
|
||||
@@ -951,7 +953,6 @@ class OrderLogic extends LogicBase
|
||||
$order = new Order();
|
||||
$where[] = ['del', '=', 0];
|
||||
// $where[] = ['user_id', '=', $user_id];
|
||||
|
||||
switch ($type) {
|
||||
case 'pay':
|
||||
$where[] = ['pay_status', '=', CommonOrder::STATUS_WAIT_PAY];
|
||||
@@ -987,9 +988,23 @@ class OrderLogic extends LogicBase
|
||||
$number=Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',3)->count(); //查询订单服务次数
|
||||
$list['ordercs']=$number;
|
||||
$list['orderyjfw']= $list['number']-$number;
|
||||
$list['orderdaifw'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',0)->count(); //待服务数量
|
||||
$list['orderfwzhon'] = Db::name('order_exe')->where('order_sn',$list['order_sn'])->where('staff_status',1)->count(); //服务中数量
|
||||
$list['showBubble']=false;
|
||||
$list['more']="更多";
|
||||
}
|
||||
/**
|
||||
* order_status:订单状态 0-待付款;1-待发货;2-待收货;3-已完成;4-已关闭
|
||||
* pay_status:支付状态;0-待支付;1-已支付;2-已退款;3-拒绝退款
|
||||
* order_amount:应付款金额
|
||||
* order_type:订单类型;0-服务商品;1-秒杀订单;2-拼团订单;3-砍价订单;4-普通商品
|
||||
* shipping_status:发货状态
|
||||
* number:订单的总条数
|
||||
* code:订单的执行次数
|
||||
* goods_price:订单商品总价
|
||||
* ordercs:以订单服务次数
|
||||
* orderyjfw:订单的剩余执行次数
|
||||
*/
|
||||
$data = [
|
||||
'list' => $lists,
|
||||
'page' => $page,
|
||||
|
||||
@@ -10,10 +10,11 @@ class Order extends Model
|
||||
protected $name = 'order';
|
||||
|
||||
//订单类型
|
||||
const NORMAL_ORDER = 0;//普通订单
|
||||
const NORMAL_ORDER = 0;//服务订单
|
||||
const SECKILL_ORDER = 1;//秒杀订单
|
||||
const TEAM_ORDER = 2;//拼团订单
|
||||
const BARGAIN_ORDER = 3;//砍价订单
|
||||
const GROUP_ORDER = 4; //普通订单
|
||||
|
||||
//订单状态
|
||||
const STATUS_WAIT_PAY = 0; //待付款
|
||||
@@ -52,6 +53,7 @@ class Order extends Model
|
||||
self::SECKILL_ORDER => '秒杀订单',
|
||||
self::TEAM_ORDER => '拼团订单',
|
||||
self::BARGAIN_ORDER => '砍价订单',
|
||||
self::GROUP_ORDER => '普通订单',
|
||||
];
|
||||
|
||||
if ($type === true){
|
||||
|
||||
Reference in New Issue
Block a user