Merge pull request 'dev' (#94) from dev into master

Reviewed-on: #94
This commit is contained in:
mkm 2023-12-05 17:47:29 +08:00
commit 40d2087ece
11 changed files with 248 additions and 34 deletions

View File

@ -2570,13 +2570,13 @@ class StoreOrderRepository extends BaseRepository
} else {
//默认其他分类
$cate_id = 1726;
$spec_type = 1;
$spec_type = 0;
$detail = $attr;
/**查询平台分类 */
$cate_id_one = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
$cate_id_one = Db::name('store_category')->where('is_show',1)->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
if ($cate_id_one) {
$cate_id_two = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
$cate_id_two = Db::name('store_category')->where('is_show',1)->where('mer_id', 0)->where('pid',$cate_id_one)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
if ($cate_id_two) {
$cate_id = $cate_id_two;
}
@ -2697,6 +2697,7 @@ class StoreOrderRepository extends BaseRepository
"mer_status" => 1,
"rate" => 3,
];
$make = app()->make(ProductRepository::class);
$product_id = $make->create($datas, $product_type);
if ($product_id) {
@ -2747,6 +2748,7 @@ class StoreOrderRepository extends BaseRepository
$attrValue['price'] = $datum['value']['price'];
$attrValue['procure_price'] = $procure_price;
$attrValue["image"] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png";
Db::name('store_product')->where('product_id',$find['product_id'])->update(['spec_type'=>1]);
Db::name('store_product_attr_value')->insert($attrValue);
}
/**

View File

@ -38,6 +38,9 @@ class CacheRepository extends BaseRepository
const CONSIGN_PRODUCT_AGREE = 'consign_product_agree';
//商户开通采购、交易及结算功能协议
const MERC_SETTLE_AGREE = 'mer_settlement_agree';
//生鲜类商品交易售后纠纷处理规则
const FRESHRULES = 'fresh_rules';
//积分说明
const INTEGRAL_RULE = 'sys_integral_rule';
@ -91,6 +94,7 @@ class CacheRepository extends BaseRepository
['label' => '供应链商户补充协议','key' => self::MERC_SUPPLY_AGREE],
['label' => '产品代销三方合作协议书', 'key' => self::CONSIGN_PRODUCT_AGREE],
['label' => '商户开通采购、交易及结算功能协议', 'key' => self::MERC_SETTLE_AGREE],
['label' => '生鲜类商品交易售后纠纷处理规则', 'key' => self::FRESHRULES],
];
if (!$type) {
$data[] = ['label' => '注销声明', 'key' => self::CANCELLATION_MSG];
@ -125,6 +129,7 @@ class CacheRepository extends BaseRepository
self::MERC_SUPPLY_AGREE,
self::CONSIGN_PRODUCT_AGREE,
self::MERC_SETTLE_AGREE,
self::FRESHRULES,
];
}

View File

@ -23,32 +23,64 @@ class Logistics extends BaseController
}
}
// 三轮车列表 从供销系统获取
// 三轮车列表 每个乡镇订单最多的配送员的三轮车
public function vehicleList()
{
// 镇区域码为空,查区县的公司
if (empty($this->streetCode)) {
$companyList = Db::connect('work_task')->name('company')->where('area', $this->areaCode)->select()->toArray();
} else {
$companyList = Db::connect('work_task')->name('company')->where('street', $this->streetCode)->select()->toArray();
// 查区县的镇农科公司
$list = [];
$companyList = Db::connect('work_task')->name('company')->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray();
foreach ($companyList as $company) {
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
->where(['street'=> $company['street'], 'company_type'=>18])
->column('id');
$userIdList = Db::connect('work_task')->name('user')
->whereIn('company_id', $serviceGroupCompanyIds)
->where(['group_id'=>5])
->column('id');
// 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员
$topCourier = Db::connect('logistics')->name('logistics')
->field(['courier_id','courier_name','COUNT(order_id) AS order_count'])
->whereIn('courier_id', $userIdList)
->group('courier_id')
->order('order_count DESC')
->find();
// 小组公司没有配送员或是没有三轮车
if (empty($topCourier)) {
continue;
}
// 三轮车车牌号 根据配送员id反查公司id公司id反查车牌号
$courier = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->find();
$vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courier['company_id']])->find();
$topCourier['id'] = $vehicleRent['car_id'];
$topCourier['license'] = $vehicleRent['car_license'];
$topCourier['area_code'] = $courier['area'];
$topCourier['street_code'] = $courier['street'];
$list[] = $topCourier;
}
$companyIds = array_column($companyList, 'id');
// 查镇车辆列表
$list = Db::connect('work_task')->name('vehicle_rent')
->field('company_id, car_id as id, car_license as license')
->append(['area_code','street_code'])
->whereIn('company_id', $companyIds)
->where('status','in','0,1,2')
->withAttr('area_code', function ($value, $data){
$company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
return $company['area'];
})
->withAttr('street_code', function ($value, $data){
$company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
return $company['street'];
})
->group('company_id')
->select()->toArray();
// $list = Db::connect('work_task')->name('vehicle_rent')
// ->field('company_id, car_id as id, car_license as license')
// ->append(['area_code','street_code'])
// ->whereIn('company_id', $companyIds)
// ->where('status','in','0,1,2')
// ->withAttr('area_code', function ($value, $data){
// $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
// return $company['area'];
// })
// ->withAttr('street_code', function ($value, $data){
// $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
// return $company['street'];
// })
// ->group('company_id')
// ->select()->toArray();
$count = count($list);
return app('json')->success(compact('count', 'list'));
@ -91,8 +123,8 @@ class Logistics extends BaseController
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
->where(['street'=> $this->streetCode, 'company_type'=>18])
->column('id');
->where(['street'=> $this->streetCode, 'company_type'=>18])
->column('id');
$userIdList = Db::connect('work_task')->name('user')
->whereIn('company_id', $serviceGroupCompanyIds)
->where(['group_id'=>5])
@ -113,7 +145,38 @@ class Logistics extends BaseController
// 已完成数
$topCourier['finished_order_count'] = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$topCourier['courier_id']])->count();
return app('json')->success($topCourier);
// 三轮车车牌号 根据配送员id反查公司id公司id反查车牌号
$courierCompanyId = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->value('company_id');
$vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courierCompanyId])->find();
$topCourier['car_id'] = $vehicleRent['car_id'];
$topCourier['car_license'] = $vehicleRent['car_license'];
return app('json')->success($topCourier);
}
// 第二页 地图 最新的10笔配送订单地址 以及最近一次取货地址发散
public function logisticsMapCount()
{
$courierId = $this->request->param('courier_id');
// 最近一次取货地址 最新一笔的配送中订单的取货地址
$latestLogistics = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id' => $courierId])->order('id', 'desc')->find();
$latestOrderInfo = Db::name('store_order')->where(['order_id'=>$latestLogistics['order_id']])->find();
$merchant = Db::name('merchant')->where(['mer_id'=>$latestOrderInfo['mer_id']])->find();
// 拼接商户的详细地址 area_id street_id village_id
$area = Db::name('geo_area')->where('area_code', $merchant['area_id'])->find();
$city = Db::name('geo_city')->where('city_code', $area['city_code'])->find();
$province = Db::name('geo_province')->where('province_code', $city['province_code'])->find();
$street = Db::name('geo_street')->where('street_code', $merchant['street_id'])->find();
$village = Db::name('geo_village')->where('village_id', $merchant['village_id'])->find();
$merAddress = $province['province_name'] . $city['city_name'] . $area['area_name'] . $street['street_name'].$village['village_name'].$merchant['mer_address'];
$latestOrder['mer_address'] = $merAddress;
// 最新的10笔订单
$latestTenOrder = Db::connect('logistics')->name('logistics')->field('receiver_address')->where(['status'=>1, 'courier_id' => $courierId])->order('id', 'desc')->limit(10)->select()->toArray();
return app('json')->success(compact('latestOrder', 'latestTenOrder'));
}
}

View File

@ -214,4 +214,129 @@ class Order extends BaseController
return app('json')->success(compact('townList'));
}
// 第二页 时间段订单统计
public function dateRangeOrderCount()
{
$list = [];
// 00:00-02:00
$startTime0 = strtotime(date('Y-m-d', time()));
$endTime2 = strtotime(date('Y-m-d 02:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime0, $endTime2]);
// 02:00-04:00
$startTime2 = strtotime(date('Y-m-d 02:00:00'));
$endTime4 = strtotime(date('Y-m-d 04:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime2, $endTime4]);
// 04:00-06:00
$startTime4 = strtotime(date('Y-m-d 04:00:00'));
$endTime6 = strtotime(date('Y-m-d 06:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime4, $endTime6]);
// 06:00-08:00
$startTime6 = strtotime(date('Y-m-d 06:00:00'));
$endTime8 = strtotime(date('Y-m-d 08:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime6, $endTime8]);
// 08:00-10:00
$startTime8 = strtotime(date('Y-m-d 08:00:00'));
$endTime10 = strtotime(date('Y-m-d 10:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime8, $endTime10]);
// 10:00-12:00
$startTime10 = strtotime(date('Y-m-d 10:00:00'));
$endTime12 = strtotime(date('Y-m-d 12:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime10, $endTime12]);
// 12:00-14:00
$startTime12 = strtotime(date('Y-m-d 12:00:00'));
$endTime14 = strtotime(date('Y-m-d 14:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime12, $endTime14]);
// 14:00-16:00
$startTime14 = strtotime(date('Y-m-d 14:00:00'));
$endTime16 = strtotime(date('Y-m-d 16:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime14, $endTime16]);
// 16:00-18:00
$startTime16 = strtotime(date('Y-m-d 16:00:00'));
$endTime18 = strtotime(date('Y-m-d 18:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime16, $endTime18]);
// 18:00-20:00
$startTime18 = strtotime(date('Y-m-d 18:00:00'));
$endTime20 = strtotime(date('Y-m-d 20:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime18, $endTime20]);
// 20:00-22:00
$startTime20 = strtotime(date('Y-m-d 20:00:00'));
$endTime22 = strtotime(date('Y-m-d 22:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime20, $endTime22]);
// 22:00-24:00
$startTime22 = strtotime(date('Y-m-d 22:00:00'));
$endTime24 = strtotime(date('Y-m-d 24:00:00'));
$list[] = $this->getTimeRangeOrderCount([$startTime22, $endTime24]);
return app('json')->success($list);
}
private function getTimeRangeOrderCount($timeRange)
{
$hourOrderCountQuery = Db::name('store_order')->alias('o')
->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status'])
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->leftJoin('merchant m', 'o.mer_id = m.mer_id')
->leftJoin('store_order_product op', 'o.order_id = op.order_id')
->leftJoin('product_library p', 'op.product_id = p.id')
->whereTime('og.create_time', 'between', $timeRange) // whereTime('create_time', 'between', [$a[0],$a[1]]);
->where('o.paid', 1)
->whereNotNull('o.pay_time');
// 待取货订单数统计query 订单待发货
$pendingPickupOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereTime('og.create_time', 'between', $timeRange)
->where('o.status', 0)
->where('o.paid', 1)
->whereNotNull('o.pay_time');;
// 未配送订单数统计query 订单待收货
$undeliveredOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereTime('og.create_time', 'between', $timeRange)
->where('o.status', 1)
->where('o.paid', 1)
->whereNotNull('o.pay_time');;
// 已完成订单数统计query 订单已完成
$doneOrderCountQuery = Db::name('store_order')->alias('o')
->leftJoin('product_order_log og', 'o.order_id = og.order_id')
->whereTime('og.create_time', 'between', $timeRange)
->whereIn('o.status', [2,3])
->where('o.paid', 1)
->whereNotNull('o.pay_time');
if ($this->areaCode != '') {
$hourOrderCountQuery->where('og.district_code', $this->areaCode);
$pendingPickupOrderCountQuery->where('og.district_code', $this->areaCode);
$undeliveredOrderCountQuery->where('og.district_code', $this->areaCode);
$doneOrderCountQuery->where('og.district_code', $this->areaCode);
} else if ($this->streetCode != '') {
$hourOrderCountQuery->where('og.street_code', $this->streetCode);
$pendingPickupOrderCountQuery->where('og.street_code', $this->streetCode);
$undeliveredOrderCountQuery->where('og.street_code', $this->streetCode);
$doneOrderCountQuery->where('og.street_code', $this->streetCode);
}
// 今日订单数
$hourOrderCount = $hourOrderCountQuery->count();
// 待取货订单数
$pendingOrderCount = $pendingPickupOrderCountQuery->count();
// 未配送订单数
$undeliveredOrderCount = $undeliveredOrderCountQuery->count();
// 已完成订单数
$doneOrderCount = $doneOrderCountQuery->count();
return compact('hourOrderCount', 'pendingOrderCount', 'undeliveredOrderCount', 'doneOrderCount');
}
}

View File

@ -59,7 +59,10 @@ class Merchant extends BaseController
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['keyword', 'date', 'status', 'statusTag', 'is_trader', 'category_id', 'type_id', 'area_id', 'street_id']);
return app('json')->success($this->repository->lst($where, $page, $limit));
$data = $this->repository->lst($where, $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
}

View File

@ -39,7 +39,10 @@ class StoreProduct extends BaseController
unset($_where['product_type']);
unset($_where['star']);
$where = array_merge($where, $_where);
return app('json')->success($this->repository->getAdminList($merId, $where, $page, $limit));
$data = $this->repository->getAdminList($merId, $where, $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
public function lists()

View File

@ -41,7 +41,10 @@ class User extends BaseController
'uid',
]);
[$page, $limit] = $this->getPage();
return app('json')->success($this->repository->getList($where, $page, $limit));
$data = $this->repository->getList($where, $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
}

View File

@ -26,7 +26,10 @@ class UserGroup extends BaseController
{
$page = 1;
$limit = 9999;
return app('json')->success($this->repository->getList([], $page, $limit));
$data = $this->repository->getList([], $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
}

View File

@ -28,7 +28,10 @@ class UserLabel extends BaseController
$limit = 9999;
$where = $this->request->params(['type', 'all']);
$where['mer_id'] = $this->request->merId();
return app('json')->success($this->repository->getList($where, $page, $limit));
$data = $this->repository->getList($where, $page, $limit);
$data['lists'] = $data['list'];
unset($data['list']);
return app('json')->success($data);
}
}

View File

@ -37,7 +37,7 @@ return [
\crmeb\listens\AutoUnLockBrokerageListen::class,
\crmeb\listens\AutoSendPayOrderSmsListen::class,
\crmeb\listens\SyncSmsResultCodeListen::class,
\crmeb\listens\SyncBroadcastStatusListen::class,
// \crmeb\listens\SyncBroadcastStatusListen::class,直播间
\crmeb\listens\ExcelFileDelListen::class,
\crmeb\listens\RefundOrderAgreeListen::class,
\crmeb\listens\SeckillTImeCheckListen::class,

View File

@ -721,9 +721,13 @@ Route::group('api/', function () {
Route::get('order_ranking', 'Order/orderRanking');
Route::get('delivered_product_ranking', 'Order/deliveredProductRanking');
Route::get('town_map_count', 'Order/townMapCount');
Route::get('date_range_order_count', 'Order/dateRangeOrderCount');
Route::get('vehicle_list', 'Logistics/vehicleList');
Route::get('latest_logistics', 'Logistics/latestLogistics');
Route::get('logistics_count', 'Logistics/logisticsCount');
Route::get('logistics_map_count', 'Logistics/logisticsMapCount');
})->prefix('api.dataview.');