init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
187
Application/Retail/Business/UU.class.php
可执行文件
187
Application/Retail/Business/UU.class.php
可执行文件
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
namespace Retail\Business;
|
||||
|
||||
use Common\Model\RetailStoreModel;
|
||||
use Retail\Model\UuModel;
|
||||
|
||||
//[1.7.90]
|
||||
|
||||
/**
|
||||
* UU配送
|
||||
* Class UU
|
||||
* [
|
||||
* getUuDeliveryList 获取UU配送记录
|
||||
* getUuDeliveryTotal UU订单统计
|
||||
* handleMap 处理条件
|
||||
* ]
|
||||
* @package Retail\Business
|
||||
* @author GuYunQinFeng
|
||||
*/
|
||||
class UU
|
||||
{
|
||||
/**
|
||||
* 获取UU配送记录
|
||||
* @param $param
|
||||
* [
|
||||
* store_id 门店id
|
||||
* merchant_id 商户id
|
||||
* time 添加时间
|
||||
* order_type 订单类型 1普通 2拼团 3秒杀
|
||||
* order_id 门店订单号
|
||||
* status 订单状态 当前状态0未下单1下单成功 3跑男抢单 4已到达 5已取件 6到达目的地 10收件人已收货 -1订单取消
|
||||
* page 页码
|
||||
* limit 页长
|
||||
* ]
|
||||
* @return array
|
||||
*/
|
||||
public function getUuDeliveryList($param)
|
||||
{
|
||||
$where = $this->handleMap($param);
|
||||
$UuModel = new UuModel();
|
||||
if ($param['page'] && $param['limit']) {
|
||||
$list = $UuModel->getSelect($where, '', 'id desc', "{$param['page']}, {$param['limit']}");
|
||||
} else {
|
||||
$list = $UuModel->getSelect($where, '', 'id desc');
|
||||
}
|
||||
if ($list) {
|
||||
$RetailStoreModel = new RetailStoreModel();
|
||||
$count = $UuModel->getCount($where);
|
||||
$storeIdArr = [];
|
||||
$storeInfoArr = [];
|
||||
foreach ($list as $key => &$val) {
|
||||
$val['index'] = $key + 1;
|
||||
// 减少门店名称重复查询
|
||||
if (in_array($val['storeid'], $storeIdArr)) {
|
||||
$val['store_name'] = $storeInfoArr[$val['storeid']]['name'];
|
||||
} else {
|
||||
$val['store_name'] = $RetailStoreModel->getFindField(['id' => $val['storeid']], 'storetag');
|
||||
$storeIdArr[] = $val['storeid'];
|
||||
$storeInfoArr[$val['storeid']]['name'] = $val['store_name'];
|
||||
}
|
||||
switch ($val['state']) {
|
||||
case 0:
|
||||
$val['order_status'] = '未下单UU';
|
||||
break;
|
||||
case 1:
|
||||
$val['order_status'] = '下单成功';
|
||||
break;
|
||||
case 3:
|
||||
$val['order_status'] = '跑男抢单';
|
||||
break;
|
||||
case 4:
|
||||
$val['order_status'] = '骑手已达到';
|
||||
break;
|
||||
case 5:
|
||||
$val['order_status'] = '已取件';
|
||||
break;
|
||||
case 6:
|
||||
$val['order_status'] = '骑手到达目的地';
|
||||
break;
|
||||
case 10:
|
||||
$val['order_status'] = '收件人已收货';
|
||||
break;
|
||||
case -1:
|
||||
$val['order_status'] = '已取消配送';
|
||||
break;
|
||||
}
|
||||
switch ($val['order_genre']) {
|
||||
case 1:
|
||||
$val['order_type'] = '商城订单';
|
||||
break;
|
||||
case 2:
|
||||
$val['order_type'] = '拼团订单';
|
||||
break;
|
||||
case 3:
|
||||
$val['order_type'] = '秒杀订单';
|
||||
break;
|
||||
}
|
||||
if (!empty($val['addtime'])) {
|
||||
$val['add_time'] = date('Y-m-d H:i:s', $val['addtime']);
|
||||
unset($val['addtime']);
|
||||
}
|
||||
}
|
||||
return callBack(statusCode()['success'],'数据获取成功',[
|
||||
'list' => $list,
|
||||
'count' => $count,
|
||||
]);
|
||||
} else {
|
||||
return callBack(statusCode()['success'],'暂无数据',[
|
||||
'list' => [],
|
||||
'count' => 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UU订单统计
|
||||
*/
|
||||
public function getUuDeliveryTotal($param)
|
||||
{
|
||||
$where = $this->handleMap($param);
|
||||
$UuModel = new UuModel();
|
||||
$order_count = $UuModel->getCount($where);
|
||||
if (empty($param['status']) || $param['status'] == 2) {
|
||||
$where['state'] = 10;
|
||||
$complete = $UuModel->getCount($where);
|
||||
if (empty($param['status'])) {
|
||||
$where['state'] = ['not in', '0,-1'];
|
||||
}
|
||||
$cost_total = $UuModel->getSum($where, 'need_paymoney');
|
||||
$cost_total = $cost_total ? $cost_total : 0;
|
||||
$coupon_money = $UuModel->getSum($where, 'total_priceoff');
|
||||
$coupon_money = $coupon_money ? $coupon_money : 0;
|
||||
} else {
|
||||
$complete = 0;
|
||||
$cost_total = 0;
|
||||
$coupon_money = 0;
|
||||
}
|
||||
return callBack(statusCode()['success'],'数据获取成功',[
|
||||
'order_count' => $order_count,
|
||||
'complete' => $complete,
|
||||
'cost_total' => $cost_total,
|
||||
'coupon_money' => $coupon_money,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 条件处理
|
||||
*/
|
||||
public function handleMap($param)
|
||||
{
|
||||
$where['merchantid'] = $param['merchant_id'];
|
||||
if (!empty($param['order_id'])) {
|
||||
$where['order_id'] = ['like', '%' . $param['order_id'] . '%'];
|
||||
}
|
||||
if (!empty($param['store_id'])) {
|
||||
$where['storeid'] = $param['store_id'];
|
||||
}
|
||||
if (!empty($param['status'])) {
|
||||
switch ($param['status']) {
|
||||
case 1:
|
||||
$where['state'] = ['neq', 10];
|
||||
break;
|
||||
case 2:
|
||||
$where['state'] = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($param['order_type'])) {
|
||||
$where['order_genre'] = $param['order_type'];
|
||||
}
|
||||
$time = $param['time'];
|
||||
if (!empty($time)) {
|
||||
if(!is_array($time)){
|
||||
$time = explode(',',$time);
|
||||
}
|
||||
$start_time = strtotime($time[0]);
|
||||
$end_time = strtotime($time[1]);
|
||||
$where['addtime'] = ['between', [$start_time, $end_time]];
|
||||
}else if ($param['is_export']){
|
||||
//默认导出当日记录
|
||||
$where['addtime'] = ['between', [strtotime(date('Y-m-d 00:00:00')), time()]];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户