升级
This commit is contained in:
parent
e3519fb693
commit
bf2d167f03
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
namespace app\api\controller;
|
namespace app\api\controller;
|
||||||
|
|
||||||
|
use app\api\logic\LogisticsLogic;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,60 +39,12 @@ class LogisticsController extends BaseApiController
|
|||||||
public function courierLogisticsList(): \think\response\Json
|
public function courierLogisticsList(): \think\response\Json
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
$courier_id = input('courier_id', 0, 'intval');
|
$params = $this->request->get(['courier_id','status','page_size','page_num','keywords']);
|
||||||
$status = input('status', 0, 'intval');
|
//验证参数
|
||||||
$page_size = input('page_size', 5, 'intval');
|
if(empty($params['courier_id'])) return $this->fail('参数错误');
|
||||||
$page_num = input('page_num', 1, 'intval');
|
if(empty($params['keywords'])) $params['keywords'] = '';
|
||||||
$keywords = input('keywords', '', 'trim');
|
//返回数据
|
||||||
if(empty($courier_id)) return $this->fail('参数错误');
|
return $this->data(LogisticsLogic::list($params));
|
||||||
//获取物流信息
|
|
||||||
$logistics = Db::name('logistics')->whereRaw('courier_id='.$courier_id.' AND status='.$status.' AND (order_sn="'.$keywords.'" OR shop_name LIKE "%'.$keywords.'%" OR user_name LIKE "%'.$keywords.'%")')->order('update_time desc')->paginate([
|
|
||||||
'list_rows'=> $page_size,
|
|
||||||
'page' => $page_num,
|
|
||||||
])->each(
|
|
||||||
function ($item, $key) use($status) {
|
|
||||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
|
||||||
switch ($status) {
|
|
||||||
case 0:
|
|
||||||
$item['status_name'] = '待取货';
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
$item['status_name'] = '配送中';
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$item['status_name'] = '已送达';
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$item['status_name'] = '已完成';
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
$item['status_name'] = '已取消';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$item['status_name'] = '未知状态';
|
|
||||||
}
|
|
||||||
$item['products'] = Db::connect('mysql2')->table('eb_store_order_product')->field('product_num,cart_info')->where('order_id', $item['order_id'])->select()->each(
|
|
||||||
function ($item2) {
|
|
||||||
$item2['cart_info'] = json_decode($item2['cart_info'], true);
|
|
||||||
$item2['goods_name'] = $item2['cart_info']['product']['store_name'];
|
|
||||||
$item2['goods_unit'] = $item2['cart_info']['product']['unit_name'];
|
|
||||||
unset($item2['cart_info']);
|
|
||||||
return $item2;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
$item['product_count'] = count( $item['products']);
|
|
||||||
$records = Db::name('logistics_record')->field('status,create_time')->where('lst_id', $item['id'])->order('create_time asc')->select()->toArray();
|
|
||||||
foreach($records as $k=>$v){
|
|
||||||
if($v['status'] == 0) $item['xd_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
||||||
if($v['status'] == 1) $item['qh_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
||||||
if($v['status'] == 2) $item['pc_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
||||||
if($v['status'] == 3) $item['sh_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
||||||
if($v['status'] == 4) $item['qx_time'] = date('Y-m-d H:i:s', $v['create_time']);
|
|
||||||
}
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
return $this->data($logistics);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -103,52 +56,11 @@ class LogisticsController extends BaseApiController
|
|||||||
public function logisticsDetail(): \think\response\Json
|
public function logisticsDetail(): \think\response\Json
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
$logistics_id = input('logistics_id', 0, 'intval');
|
$logistics_id = $this->request->get('logistics_id');
|
||||||
//获取物流信息
|
//验证参数
|
||||||
$logistics = Db::name('logistics')
|
if(empty($logistics_id)) return $this->fail('参数错误');
|
||||||
->field('id,order_id,order_sn,shop_name,shop_phone,shop_address,user_name,user_address,status,create_time')
|
|
||||||
->where('id', $logistics_id)->find();
|
|
||||||
if(!$logistics) return $this->fail('物流信息不存在');
|
|
||||||
$logistics['create_time'] = date('Y-m-d H:i:s', $logistics['create_time']);
|
|
||||||
//获取订单商品信息
|
|
||||||
$product = Db::connect('mysql2')->table('eb_store_order_product')->field('product_num,cart_info')->where('order_id', $logistics['order_id'])->select()->each(
|
|
||||||
function ($item, $key) {
|
|
||||||
$item['cart_info'] = json_decode($item['cart_info'], true);
|
|
||||||
$item['goods_name'] = $item['cart_info']['product']['store_name'];
|
|
||||||
$item['goods_unit'] = $item['cart_info']['product']['unit_name'];
|
|
||||||
unset($item['cart_info']);
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
//获取物流记录
|
|
||||||
$record = Db::name('logistics_record')->field('type,user_name,content,create_time')->where('lst_id', $logistics_id)->order('create_time desc')->select()->each(
|
|
||||||
function ($item) {
|
|
||||||
switch ($item['type']) {
|
|
||||||
case 1:
|
|
||||||
$item['content'] = '用户'.$item['user_name'].$item['content'];
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
$item['content'] = '配送员'.$item['user_name'].$item['content'];
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
$item['content'] = '平台'.$item['user_name'].$item['content'];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$item['content'] = '未知';
|
|
||||||
}
|
|
||||||
$item['create_time'] = date('Y-m-d H:i:s', $item['create_time']);
|
|
||||||
unset($item['type'], $item['user_name']);
|
|
||||||
return $item;
|
|
||||||
}
|
|
||||||
)->toArray();
|
|
||||||
//返回数据
|
//返回数据
|
||||||
$data = [
|
return $this->data(LogisticsLogic::detail($logistics_id));
|
||||||
'logistics' => $logistics,
|
|
||||||
'product' => $product,
|
|
||||||
'product_count' => count($product),
|
|
||||||
'record' => $record,
|
|
||||||
];
|
|
||||||
return $this->data($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -161,64 +73,13 @@ class LogisticsController extends BaseApiController
|
|||||||
public function logisticsCreate(): \think\response\Json
|
public function logisticsCreate(): \think\response\Json
|
||||||
{
|
{
|
||||||
//获取参数
|
//获取参数
|
||||||
$order_id = input('order_id', 0, 'intval');
|
$params = $this->request->post(['order_id','order_sn']);
|
||||||
$order_sn = input('order_sn', '', 'trim');
|
//验证参数
|
||||||
//判断物流信息是否已存在
|
if(empty($params['order_id']) || empty($params['order_sn'])) return $this->fail('参数错误');
|
||||||
$logistics = Db::name('logistics')->where('order_id', $order_id)->where('order_sn', $order_sn)->find();
|
//生成数据
|
||||||
if($logistics) return $this->fail('物流信息已存在');
|
$result = LogisticsLogic::create($params);
|
||||||
//查找订单信息
|
//返回数据
|
||||||
$order = Db::connect('mysql2')->table('eb_store_order')->alias('s')
|
return $result['code'] ==1 ? $this->success('生成成功') : $this->fail($result['msg']);
|
||||||
->leftjoin('eb_merchant m', 'm.mer_id = s.mer_id')
|
|
||||||
->field('s.real_name, s.user_phone,s.uid, s.user_address,s.user_address_code,m.mer_name, m.mer_phone, m.mer_address')
|
|
||||||
->where('order_id', $order_id)->where('order_sn', $order_sn)->find();
|
|
||||||
if (!$order) return $this->fail('订单信息不存在');
|
|
||||||
$addressCode = explode(',', $order['user_address_code']);
|
|
||||||
//匹配配送员
|
|
||||||
$courier = Db::connect('mysql3')->name('la_user')->where(
|
|
||||||
[
|
|
||||||
'province'=> $addressCode[0],
|
|
||||||
'city'=> $addressCode[1],
|
|
||||||
'area'=> $addressCode[2],
|
|
||||||
'street'=> $addressCode[3],
|
|
||||||
'village'=> $addressCode[4],
|
|
||||||
'brigade'=> $addressCode[5],
|
|
||||||
'is_captain'=> 1,
|
|
||||||
'is_contract'=> 1,
|
|
||||||
]
|
|
||||||
)->value('id');
|
|
||||||
if (!$courier) return $this->fail('暂无配送员');
|
|
||||||
//写入数据
|
|
||||||
Db::startTrans();
|
|
||||||
try {
|
|
||||||
$lst_id = Db::name('logistics')->insertGetId([
|
|
||||||
'order_id' => $order_id,
|
|
||||||
'order_sn' => $order_sn,
|
|
||||||
'courier_id' => $courier,
|
|
||||||
'shop_name' => $order['mer_name'],
|
|
||||||
'shop_phone' => $order['mer_phone'],
|
|
||||||
'shop_address' => $order['mer_address'],
|
|
||||||
'user_id' => $order['uid'],
|
|
||||||
'user_name' => $order['real_name'],
|
|
||||||
'user_phone' => $order['user_phone'],
|
|
||||||
'user_address' => $order['user_address'],
|
|
||||||
'status' => 0,
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time(),
|
|
||||||
]);
|
|
||||||
Db::name('logistics_record')->insert([
|
|
||||||
'lst_id' => $lst_id,
|
|
||||||
'type' => 1,
|
|
||||||
'user_name' => $order['real_name'],
|
|
||||||
'user_phone' => $order['user_phone'],
|
|
||||||
'content' => '用户提交订单',
|
|
||||||
'create_time' => time(),
|
|
||||||
]);
|
|
||||||
Db::commit();
|
|
||||||
return $this->success('生成物流信息成功');
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
Db::rollback();
|
|
||||||
return $this->fail('生成物流信息失败');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -236,15 +97,14 @@ class LogisticsController extends BaseApiController
|
|||||||
$logistics = Db::name('logistics')->where('id', $logistics_id)->where('courier_id',$user_id)->where('status',0)->find();
|
$logistics = Db::name('logistics')->where('id', $logistics_id)->where('courier_id',$user_id)->where('status',0)->find();
|
||||||
if (!$logistics) return $this->fail('物流信息不存在');
|
if (!$logistics) return $this->fail('物流信息不存在');
|
||||||
//获取配送员信息
|
//获取配送员信息
|
||||||
$courier = Db::connect('mysql3')->name('la_user')->field('real_name,mobile')->where('id', $user_id)->find();
|
$courier = Db::connect('mysql3')->name('la_admin')->field('name,phone')->where('id', $user_id)->find();
|
||||||
if (!$courier) return $this->fail('配送人员信息不存在');
|
if (!$courier) return $this->fail('配送人员信息不存在');
|
||||||
//设置记录信息
|
//设置记录信息
|
||||||
$record = [
|
$record = [
|
||||||
'lst_id' => $logistics['id'],
|
'lst_id' => $logistics['id'],
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'status' => 1,
|
'user_name' => $courier['name'],
|
||||||
'user_name' => $courier['real_name']? $courier['real_name'] : $courier['nickname'],
|
'user_phone' => $courier['phone'],
|
||||||
'user_phone' => $courier['mobile'],
|
|
||||||
'content' => '已提取商品',
|
'content' => '已提取商品',
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
@ -272,15 +132,14 @@ class LogisticsController extends BaseApiController
|
|||||||
$logistics = Db::name('logistics')->where('id', $logistics_id)->where('courier_id',$user_id)->where('status',1)->find();
|
$logistics = Db::name('logistics')->where('id', $logistics_id)->where('courier_id',$user_id)->where('status',1)->find();
|
||||||
if (!$logistics) return $this->fail('物流信息不存在');
|
if (!$logistics) return $this->fail('物流信息不存在');
|
||||||
//获取配送员信息
|
//获取配送员信息
|
||||||
$courier = Db::connect('mysql3')->name('la_user')->field('real_name,mobile')->where('id', $user_id)->find();
|
$courier = Db::connect('mysql3')->name('la_admin')->field('name,phone')->where('id', $user_id)->find();
|
||||||
if (!$courier) return $this->fail('配送人员信息不存在');
|
if (!$courier) return $this->fail('配送人员信息不存在');
|
||||||
//设置记录信息
|
//设置记录信息
|
||||||
$record = [
|
$record = [
|
||||||
'lst_id' => $logistics['id'],
|
'lst_id' => $logistics['id'],
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'status' => 2,
|
'user_name' => $courier['name'],
|
||||||
'user_name' => $courier['real_name']? $courier['real_name'] : $courier['nickname'],
|
'user_phone' => $courier['phone'],
|
||||||
'user_phone' => $courier['mobile'],
|
|
||||||
'content' => '已完成配送',
|
'content' => '已完成配送',
|
||||||
'create_time' => time(),
|
'create_time' => time(),
|
||||||
];
|
];
|
||||||
@ -312,7 +171,6 @@ class LogisticsController extends BaseApiController
|
|||||||
$record = [
|
$record = [
|
||||||
'lst_id' => $logistics['id'],
|
'lst_id' => $logistics['id'],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'status' => 3,
|
|
||||||
'user_name' => $logistics['user_name'],
|
'user_name' => $logistics['user_name'],
|
||||||
'user_phone' => $logistics['user_phone'],
|
'user_phone' => $logistics['user_phone'],
|
||||||
'content' => '已确认收货',
|
'content' => '已确认收货',
|
||||||
@ -346,7 +204,6 @@ class LogisticsController extends BaseApiController
|
|||||||
$record = [
|
$record = [
|
||||||
'lst_id' => $logistics['id'],
|
'lst_id' => $logistics['id'],
|
||||||
'type' => 1,
|
'type' => 1,
|
||||||
'status' => 4,
|
|
||||||
'user_name' => $logistics['user_name'],
|
'user_name' => $logistics['user_name'],
|
||||||
'user_phone' => $logistics['user_phone'],
|
'user_phone' => $logistics['user_phone'],
|
||||||
'content' => '已取消订单',
|
'content' => '已取消订单',
|
||||||
@ -372,7 +229,27 @@ class LogisticsController extends BaseApiController
|
|||||||
if(empty($id) || empty($status) || empty($data)) return false;
|
if(empty($id) || empty($status) || empty($data)) return false;
|
||||||
Db::startTrans();
|
Db::startTrans();
|
||||||
try {
|
try {
|
||||||
Db::name('logistics')->where('id', $id)->update(['status' => $status, 'update_time' => time()]);
|
$update = [
|
||||||
|
'status' => $status,
|
||||||
|
'update_time' => time(),
|
||||||
|
];
|
||||||
|
switch($status){
|
||||||
|
case 1:
|
||||||
|
$update['qh_time'] = time();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$update['pc_time'] = time();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$update['sh_time'] = time();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
$update['qx_time'] = time();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Db::name('logistics')->where('id', $id)->update($update);
|
||||||
Db::name('logistics_record')->insert($data);
|
Db::name('logistics_record')->insert($data);
|
||||||
Db::commit();
|
Db::commit();
|
||||||
return true;
|
return true;
|
||||||
|
165
app/api/logic/LogisticsLogic.php
Normal file
165
app/api/logic/LogisticsLogic.php
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\api\logic;
|
||||||
|
|
||||||
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\logistics\Courier;
|
||||||
|
use app\common\model\logistics\Logistics;
|
||||||
|
use app\common\model\logistics\Order;
|
||||||
|
use app\common\model\logistics\Product;
|
||||||
|
use app\common\model\logistics\LogisticsRecord;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物流逻辑
|
||||||
|
* Class LogisticsLogic
|
||||||
|
* @package app\api\logic
|
||||||
|
*/
|
||||||
|
class LogisticsLogic extends BaseLogic
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* 物流列表
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function list($params):array {
|
||||||
|
//获取物流列表
|
||||||
|
$logistics = Logistics::where('courier_id', $params['courier_id'])
|
||||||
|
->where('status', $params['status'] ?? 0)
|
||||||
|
->where('(order_sn="'.$params['keywords'].'" OR shop_name LIKE "%'.$params['keywords'].'%" OR user_name LIKE "%'.$params['keywords'].'%")')
|
||||||
|
->paginate([
|
||||||
|
'list_rows'=> !empty($params['page_size'])? $params['page_size'] : 6,
|
||||||
|
'page' => !empty($params['page_num'])? $params['page_num'] : 1,
|
||||||
|
])->each(function($lst_item){
|
||||||
|
$lst_item['status_name'] = $lst_item->status_name;
|
||||||
|
//获取产品信息
|
||||||
|
$lst_item['products'] = Product::field('product_num,cart_info')->where('order_id', $lst_item['order_id'])->select()->each(function($pro_item){
|
||||||
|
$pro_item['cart_info'] = json_decode($pro_item['cart_info'], true);
|
||||||
|
$pro_item['goods_name'] = $pro_item['cart_info']['product']['store_name'];
|
||||||
|
$pro_item['goods_unit'] = $pro_item['cart_info']['product']['unit_name'];
|
||||||
|
unset($pro_item['cart_info']);
|
||||||
|
return $pro_item;
|
||||||
|
});
|
||||||
|
$lst_item['product_count'] = count($lst_item['products']);
|
||||||
|
return $lst_item;
|
||||||
|
})->toArray();
|
||||||
|
//返回数据
|
||||||
|
return $logistics;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 物流详情
|
||||||
|
* @param $id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function detail($id):array {
|
||||||
|
//获取物流信息
|
||||||
|
$logistics = Logistics::field('id,order_id,order_sn,shop_name,shop_phone,shop_address,user_name,user_address,status,create_time')
|
||||||
|
->where('id', $id)->find();
|
||||||
|
//获取商品信息
|
||||||
|
$product = Product::field('product_num,cart_info')->where('order_id', $logistics['order_id'])->select()->each(function($pro_item){
|
||||||
|
$pro_item['cart_info'] = json_decode($pro_item['cart_info'], true);
|
||||||
|
$pro_item['goods_name'] = $pro_item['cart_info']['product']['store_name'];
|
||||||
|
$pro_item['goods_unit'] = $pro_item['cart_info']['product']['unit_name'];
|
||||||
|
unset($pro_item['cart_info']);
|
||||||
|
return $pro_item;
|
||||||
|
})->toArray();
|
||||||
|
//获取物流记录
|
||||||
|
$records = LogisticsRecord::field('type,user_name,content,create_time')
|
||||||
|
->where('lst_id', $logistics['id'])->order('create_time desc')->select()->each(function($red_item){
|
||||||
|
switch ($red_item['type']) {
|
||||||
|
case 1:
|
||||||
|
$red_item['content'] = '用户'.$red_item['user_name'].$red_item['content'];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$red_item['content'] = '配送员'.$red_item['user_name'].$red_item['content'];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$red_item['content'] = '平台'.$red_item['user_name'].$red_item['content'];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$red_item['content'] = '未知';
|
||||||
|
}
|
||||||
|
unset($red_item['type'], $red_item['user_name']);
|
||||||
|
})->toArray();
|
||||||
|
//返回数据
|
||||||
|
return[
|
||||||
|
'logistics' => $logistics,
|
||||||
|
'product' => $product,
|
||||||
|
'product_count' => count($product),
|
||||||
|
'record' => $records,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 生成物流信息
|
||||||
|
* @param $params
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function create($params):array {
|
||||||
|
//判断物流信息是否已存在
|
||||||
|
$logistics = Logistics::where('order_id', $params['order_id'])->where('order_sn', $params['order_sn'])->find();
|
||||||
|
if($logistics) return ['code'=>0, 'msg'=>'物流信息已存在'];
|
||||||
|
//查找订单信息
|
||||||
|
$order = Order::alias('s')
|
||||||
|
->leftjoin('eb_merchant m', 'm.mer_id = s.mer_id')
|
||||||
|
->field('s.real_name, s.user_phone,s.uid, s.user_address,s.user_address_code,m.mer_name, m.mer_phone, m.mer_address')
|
||||||
|
->where('order_id', $params['order_id'])->where('order_sn', $params['order_sn'])->find();
|
||||||
|
if(empty($order['user_address_code'])) return ['code'=>1, 'msg'=>'用户地址信息错误'];
|
||||||
|
//匹配配送员
|
||||||
|
$arr = explode(',', $order['user_address_code']);
|
||||||
|
array_pop($arr);
|
||||||
|
$addr = implode(',', $arr);
|
||||||
|
$courier = Courier::alias('c')
|
||||||
|
->leftjoin('la_admin_role r', 'r.admin_id = c.id')
|
||||||
|
->where("CONCAT_WS(',',c.province,c.city,c.area,c.street,c.village) = '". $addr."'")
|
||||||
|
->where('r.role_id', 6)
|
||||||
|
->value('c.id');
|
||||||
|
//判断配送员是否存在
|
||||||
|
if(!$courier) return ['code'=>0, 'msg'=>'暂无配送员'];
|
||||||
|
//写入数据
|
||||||
|
Logistics::startTrans();
|
||||||
|
try {
|
||||||
|
$lst = Logistics::create([
|
||||||
|
'order_id' => $params['order_id'],
|
||||||
|
'order_sn' => $params['order_sn'],
|
||||||
|
'courier_id' => $courier,
|
||||||
|
'shop_name' => $order['mer_name'],
|
||||||
|
'shop_phone' => $order['mer_phone'],
|
||||||
|
'shop_address' => $order['mer_address'],
|
||||||
|
'user_id' => $order['uid'],
|
||||||
|
'user_name' => $order['real_name'],
|
||||||
|
'user_phone' => $order['user_phone'],
|
||||||
|
'user_address' => $order['user_address'],
|
||||||
|
'status' => 0,
|
||||||
|
'create_time' => time(),
|
||||||
|
'update_time' => time(),
|
||||||
|
]);
|
||||||
|
LogisticsRecord::create([
|
||||||
|
'lst_id' => $lst->id,
|
||||||
|
'type' => 1,
|
||||||
|
'user_name' => $order['real_name'],
|
||||||
|
'user_phone' => $order['user_phone'],
|
||||||
|
'content' => '用户提交订单',
|
||||||
|
'create_time' => time(),
|
||||||
|
]);
|
||||||
|
Logistics::commit();
|
||||||
|
return ['code'=>1, 'msg'=>'操作成功'];
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
Logistics::rollback();
|
||||||
|
return ['code'=>0, 'msg'=>$e->getMessage()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
35
app/common/model/logistics/Courier.php
Normal file
35
app/common/model/logistics/Courier.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\model\logistics;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logistics模型
|
||||||
|
* Class Logistics
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class Courier extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $connection = 'mysql3';
|
||||||
|
protected $name = 'la_admin';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -12,7 +12,7 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\common\model;
|
namespace app\common\model\logistics;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
@ -29,6 +29,15 @@ class Logistics extends BaseModel
|
|||||||
|
|
||||||
protected $name = 'logistics';
|
protected $name = 'logistics';
|
||||||
|
|
||||||
|
public function getStatusNameAttr($value,$data): string
|
||||||
|
{
|
||||||
|
$status = [0=>'待取货',1=>'配送中',2=>'已配送',3=>'已完成',4=>'已取消'];
|
||||||
|
return $status[$data['status']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreateTimeAttr($value): string
|
||||||
|
{
|
||||||
|
return date('Y-m-d H:i:s',$value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -12,7 +12,7 @@
|
|||||||
// | author: likeadminTeam
|
// | author: likeadminTeam
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
namespace app\common\model;
|
namespace app\common\model\logistics;
|
||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
@ -29,6 +29,9 @@ class LogisticsRecord extends BaseModel
|
|||||||
|
|
||||||
protected $name = 'logistics_record';
|
protected $name = 'logistics_record';
|
||||||
|
|
||||||
|
public function getCreateTimeAttr($value): string
|
||||||
|
{
|
||||||
|
return date('Y-m-d H:i:s',$value);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
35
app/common/model/logistics/Order.php
Normal file
35
app/common/model/logistics/Order.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\model\logistics;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logistics模型
|
||||||
|
* Class Logistics
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class Order extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $connection = 'mysql2';
|
||||||
|
protected $name = 'eb_store_order';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
35
app/common/model/logistics/Product.php
Normal file
35
app/common/model/logistics/Product.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||||
|
// | 开源版本可自由商用,可去除界面版权logo
|
||||||
|
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||||
|
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||||
|
// | 访问官网:https://www.likeadmin.cn
|
||||||
|
// | likeadmin团队 版权所有 拥有最终解释权
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | author: likeadminTeam
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace app\common\model\logistics;
|
||||||
|
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logistics模型
|
||||||
|
* Class Logistics
|
||||||
|
* @package app\common\model
|
||||||
|
*/
|
||||||
|
class Product extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $connection = 'mysql2';
|
||||||
|
protected $name = 'eb_store_order_product';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user