pull/1/head
lqmac 9 months ago
parent 5826227dfc
commit 8418ce457b
  1. 3
      .gitignore
  2. 14
      app/api/controller/Index.php
  3. 163
      app/api/controller/Order.php
  4. 31
      app/api/controller/Shop.php
  5. 25
      app/api/controller/Store.php
  6. 6
      app/api/service/Order.php
  7. 14
      app/common.php
  8. 46
      app/common/model/Banner.php
  9. 31
      app/common/model/TransferRecord.php
  10. 2
      app/common/service/Express.php
  11. 2
      app/store/model/order/Delivery.php

3
.gitignore vendored

@ -5,4 +5,5 @@
/runtime
/public/uploads
/public/static
sftp-config.json
sftp-config.json
*.DS_Store

@ -1,16 +1,26 @@
<?php
namespace app\api\controller;
use app\common\model\Banner;
use app\common\model\UploadFile;
/**
* 默认控制器
* Class Index
* @package app\api\controller
*/
class Index
class Index extends Controller
{
public function index()
{
echo '当前访问的index.php,请将index.html设为默认站点入口';
}
public function getBannerList(){
$list = Banner::where("status", 10)->select()->toArray();
foreach ($list as &$value) {
$file_path = UploadFile::where('file_id', $value['image_id'])->field('file_path')->find()->file_path;
$value['image'] = getUrl($file_path);
}
return $this->renderSuccess($list);
}
}

@ -19,6 +19,8 @@ use app\api\service\User as UserService;
use app\api\service\Order as OrderService;
use app\common\service\qrcode\Extract as ExtractQRcode;
use cores\exception\BaseException;
use app\common\model\TransferRecord;
use app\common\model\UploadFile;
/**
* 我的订单控制器
@ -90,7 +92,36 @@ class Order extends Controller
],
]);
}
/**
* 获取物流跟踪信息
* @param int $orderId 订单ID
* @return Json
* @throws BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function expressSearch(int $expressNo): Json
{
$items = [
[
'time' => "2021-12-15 17:19:28",
"context"=>"【杭州市】您的包裹已存放至【驿站】,记得早点来取它回家!",
"ftime"=>"2021-12-15 17:19:28",
"areaCode"=>"CN330102000000",//本数据元对应的行政区域编码,resultv2=1或者resultv2=4才会展示
"areaName"=>"浙江,杭州市,上城区",//本数据元对应的行政区域名称,resultv2=1或者resultv2=4才会展示
"status"=>"投柜或驿站",//本数据元对应的物流状态名称或者高级物流状态名称,resultv2=1或者resultv2=4才会展示
"location"=>"浙江省 杭州市 上城区", //本数据元对应的快件当前地点,resultv2=4才会展示
"areaCenter"=>"120.184349,30.25446", //本数据元对应的行政区域经纬度,resultv2=4才会展示
"areaPinYin"=>"shang cheng qu",//本数据元对应的行政区域拼音,resultv2=4才会展示
"statusCode"=>"501",//本数据元对应的高级物流状态值,resultv2=4才会展示
],
];
$express['items'] = $items;
$express['express_name'] = "顺丰";
$express['express_no'] = "1222222222222";
return $this->renderSuccess($express);
}
/**
* 获取物流跟踪信息
* @param int $orderId 订单ID
@ -136,7 +167,26 @@ class Order extends Controller
}
return $this->renderError($model->getError());
}
/**
* 获取当前用户行为数量
* @return Json
* @throws BaseException
*/
public function actionCounts(): Json
{
// $model = new OrderModel;
// $counts = $model->getTodoCounts();
$data = [
'reservation_number' => 0,
'view_number' => 0,
'send_number' => 0,
'integral_number' => 0,
'coupon_number' => 0,
'goods_collect_number' => 0,
'cart_number' => 0,
];
return $this->renderSuccess($data);
}
/**
* 获取当前用户待处理的订单数量
* @return Json
@ -144,9 +194,30 @@ class Order extends Controller
*/
public function todoCounts(): Json
{
$model = new OrderModel;
$counts = $model->getTodoCounts();
return $this->renderSuccess(compact('counts'));
// $model = new OrderModel;
// $counts = $model->getTodoCounts();
$data = [
'goods_order' => [
'payment_number' => 0,
'delivery_number' => 0,
'received_number' => 0,
'finish_number' => 0,
],
'service_order' => [
'confirm_number' => 0,
'service_number' => 0,
'payment_number' => 0,
'check_number' => 0,
],
'distribution_order' => [
'payment_number' => 0,
'delivery_number' => 0,
'received_number' => 0,
'finish_number' => 0,
'retund_number' => 0,
],
];
return $this->renderSuccess($data);
}
/**
@ -173,4 +244,86 @@ class Order extends Controller
$Qrcode = new ExtractQRcode($userInfo, $orderId, $channel);
return $this->renderSuccess(['qrcode' => $Qrcode->getImage()]);
}
/**
* 调货列表
* @return Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function transferList(): Json
{
$params = $this->request->param();
$where = [];
if (!empty($params['search'])) {
$where[] = ['goods_sn', 'like', "%{$params["search"]}%"];
}
$list = TransferRecord::where('status',1)
->where($where)
->order("id desc")
->paginate(10)->each(function ($item, $key) {
$goods_sn = explode("、", $item['goods_sn']);
$goods_num = explode("、", $item['goods_num']);
$goods_price = explode("、", $item['goods_price']);
$goods = [];
$total_price = 0;
foreach ($goods_sn as $seq => $value) {
$price = (float)$goods_price[$seq] ?? 0.00;
$goods[] = [
'name' => $value,
'price' => $price,
'num' => $goods_num[$seq] ?? 0,
"image" =>'https://imgservice5.suning.cn/uimg1/b2c/image/nXmtUUkwKxasCEBIX90d7w.png'
];
$total_price += $price;
}
$item['goods'] = $goods;
$item['total_price'] = $total_price;
$transfer_image_ids = UploadFile::whereIn('file_id', explode(",", $item['transfer_image_id']))->field('file_id,file_path,file_type,storage,domain')->select();
foreach ($transfer_image_ids as &$transfer_image_id) {
$transfer_image_id['file_path'] = getUrl($transfer_image_id['file_path']);
}
$chat_image_ids = UploadFile::whereIn('file_id', explode(",", $item['chat_image_id']))->field('file_id,file_path,file_type,storage,domain')->select();
foreach ($chat_image_ids as &$chat_image_id) {
$chat_image_id['file_path'] = getUrl($chat_image_id['file_path']);
}
$item['transfer_image_ids'] = $transfer_image_ids;
$item['chat_image_ids'] = $chat_image_ids;
return $item;
})->toArray();
return $this->renderSuccess($list);
}
public function editTransfer(): Json
{
$params = $this->request->param();
$id = $params['id']??0;
unset($params['id']);
TransferRecord::where('id',$id)->update($params);
return $this->renderSuccess('ok');
}
public function addTransfer(): Json
{
$params = $this->request->param();
$storeid = request()->header()['storeid'];
$params['user_id'] = \app\api\service\User::getCurrentLoginUserId();
$params['store_id'] = $storeid;
TransferRecord::create($params);
return $this->renderSuccess('ok');
}
}

@ -87,4 +87,35 @@ class Shop extends Controller
}
return $this->renderSuccess($data);
}
public function editShop(int $shopId): Json
{
$param = $this->request->param();
$upData = [
'shop_name' => $param['shop_name']??"",
'address' => $param['address']??"",
'phone' => $param['phone']??"",
'wechat_img_id' => $param['wechat_img_id']??"",
];
ShopModel::where('shop_id',$param['shop_id'])->update($upData);
return $this->renderSuccess('ok');
}
public function getShopInfo(){
$banner_imgs = [];
$share_imgs = [];
$activity_imgs = [];
$data = [
'banner_imgs' => $banner_imgs,
'share_imgs' => $share_imgs,
'activity_imgs' => $activity_imgs,
];
return $this->renderSuccess('ok');
}
}

@ -19,6 +19,8 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\api\validate\store\Store as StoreValidte;
use \app\common\model\Store as StoreInfoModel;
use app\common\model\UploadFile;
/**
* 商城基础信息
@ -78,4 +80,27 @@ class Store extends Controller
$service = new StoreService;
return $this->renderSuccess($service->getStore());
}
public function editStore(): Json
{
$params = $this->request->param();
$storeid = request()->header()['storeid'];
$upData = [
'group_share_img_id'=>$params['group_share_img_id']??0
];
StoreInfoModel::where('store_id',$storeid)->update($upData);
return $this->renderSuccess('ok');
}
public function getStoreInfo(): Json
{
$storeid = request()->header()['storeid'];
$info = StoreInfoModel::where('store_id',$storeid)->find()->toArray();
$file = UploadFile::where('file_id', $info['group_share_img_id'])->field('file_path,domain')->find();
$info['group_share_img'] = getUrl($file['file_path'], $file['domain']);
return $this->renderSuccess($info);
}
}

@ -41,6 +41,9 @@ class Order extends OrderService
// 获取发货单列表
$model = new DeliveryModel;
$list = $model->getList($orderId);
// echo "<pre>";
// print_r($list);
// exit();
// 整理物流跟踪信息
return $this->getExpressTraces($orderId, $list);
}
@ -62,6 +65,9 @@ class Order extends OrderService
// 整理物流跟踪信息
$Express = new ExpressService;
foreach ($list as $item) {
// echo "<pre>";
// print_r($item['express']);
// exit();
if (!empty($item['express'])) {
$item['traces'] = $Express->traces(
$item['express'],

@ -443,3 +443,17 @@ function hide_mobile(string $mobile): string
{
return substr_replace($mobile, '****', 3, 4);
}
function getHost(){
return (isset($_SERVER['REQUEST_SCHEME'])&&!empty($_SERVER['REQUEST_SCHEME']) ? $_SERVER['REQUEST_SCHEME'] : "https")."://".$_SERVER['HTTP_HOST'];
}
function getUrl($value, $host = ''){
if (strpos($value, "http") !== false) {
return $value;
}
$host = $host ? $host : getHost();
return $value ? $host."/".$value : "";
}

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;
/**
* 文章模型
* Class Article
* @package app\common\model
*/
class Banner extends BaseModel
{
// 定义表名
protected $name = 'banner';
// 定义主键
protected $pk = 'id';
// 追加字段
protected $append = [];
/**
* 关联文章封面图
* @return HasOne
*/
public function image(): HasOne
{
return $this->hasOne('UploadFile', 'file_id', 'image_id')
->bind(['image_url' => 'preview_url']);
}
}

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
/**
* 模型类:购物车
* Class Cart
* @package app\common\model
*/
class TransferRecord extends BaseModel
{
// 定义表名
protected $name = 'transfer_record';
// 定义主键
protected $pk = 'id';
}

@ -57,6 +57,8 @@ class Express extends BaseService
$result = ExpressFacade::store($config['default'])
->setOptions($config['providerConfig'][$config['default']])
->query($code, $expressNo);
var_dump($result);
exit();
// 记录缓存, 有效期60分钟
Cache::set($cacheIndex, $result, 60 * 60);
return $result;

@ -49,7 +49,7 @@ class Delivery extends DeliveryModel
{
// 默认参数
$params = $this->setQueryDefaultValue($param, [
'searchType' => '', // 关键词类型 (10订单号)
'searchType' => '10', // 关键词类型 (10订单号)
'searchValue' => '', // 关键词内容
'betweenTime' => [], // 起止时间
]);

Loading…
Cancel
Save