This commit is contained in:
luofei 2023-08-11 15:26:47 +08:00
parent 9a110d43ab
commit c744d8f8e9
2 changed files with 43 additions and 5 deletions

View File

@ -20,6 +20,7 @@ use app\common\model\logistics\Logistics;
use app\common\model\logistics\Order;
use app\common\model\logistics\Product;
use app\common\model\logistics\LogisticsRecord;
use app\common\model\logistics\User;
/**
@ -164,7 +165,7 @@ class LogisticsLogic extends BaseLogic
//查找订单信息
$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_id,m.mer_name,m.mer_phone,m.mer_address,m.long,m.lat')
->field('s.real_name, s.user_phone,s.uid, s.user_address,s.user_address_code,s.logistics_code,m.mer_id,m.mer_name,m.mer_phone,m.mer_address,m.long,m.lat')
->where('order_id', $params['order_id'])->where('order_sn', $params['order_sn'])->find();
if(empty($order['user_address_code'])) return ['code'=>1, 'msg'=>'用户地址信息错误'];
//匹配配送员
@ -175,15 +176,16 @@ class LogisticsLogic extends BaseLogic
->where('u.is_captain',1)
->value('c.user_id');
//判断配送员是否存在
if(!$courier) return ['code'=>0, 'msg'=>'暂无配送员'];
$courier = $courier ?? 0;
//获取配送员信息
$courierInfo = Courier::alias('u')
->field('u.id,u.nickname,a.phone')
->leftjoin('la_admin a', 'u.admin_id = a.id')
->where('u.id', $courier)->find();
if(!$courierInfo) return ['code'=>0, 'msg'=>'配送员未匹配'];
//获取下单用户信息
$orderUser = Courier::field('nickname,mobile')->where('id', $order['uid'])->find();
$orderUser = User::field('nickname,phone')->where('uid', $order['uid'])->find();
//写入数据
Logistics::startTrans();
try {
@ -201,6 +203,7 @@ class LogisticsLogic extends BaseLogic
'user_name' => $order['real_name'],
'user_phone' => $order['user_phone'],
'user_address' => $order['user_address'],
'user_take_code' => '',
'status' => 0,
'create_time' => time(),
'update_time' => time(),
@ -209,12 +212,12 @@ class LogisticsLogic extends BaseLogic
'lst_id' => $lst->id,
'type' => 1,
'user_name' => $orderUser['nickname'],
'user_phone' => $orderUser['mobile'],
'user_phone' => $orderUser['phone'],
'content' => '用户提交订单',
'create_time' => time(),
]);
Logistics::commit();
return ['code'=>1, 'msg'=>'操作成功','data'=>$courierInfo];
return ['code'=>1, 'msg'=>'操作成功','data'=>$courierInfo->toArray()];
} catch (\Exception $e) {
Logistics::rollback();
return ['code'=>0, 'msg'=>$e->getMessage()];

View 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 User extends BaseModel
{
protected $connection = 'mysql2';
protected $name = 'eb_user';
}