添加:提货点管理

This commit is contained in:
wuhui_zzw 2024-04-10 18:43:20 +08:00
parent be408ba6f9
commit 4ae8ae8a6e
10 changed files with 266 additions and 20 deletions

View File

@ -0,0 +1,37 @@
<?php
namespace app\common\dao\store;
use app\common\dao\BaseDao;
use app\common\model\store\Point;
class PointDao extends BaseDao{
protected function getModel(): string{
return Point::class;
}
/**
* Common: 公共搜索模型
* Author: wu-hui
* Time: 2024/04/10 18:14
* @param array $params
* @return Point
*/
public function searchList(array $params){
return (new Point())
->where('is_del', 0)
->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){
$query->where('id', (int)$params['id']);
})
->when(isset($params['mer_take_name']) && $params['mer_take_name'] !== '',function($query) use ($params){
$query->where('mer_take_name', 'like', "%{$params['mer_take_name']}%");
})
->order('create_time DESC,id DESC');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace app\common\model\store;
use app\common\model\BaseModel;
class Point extends BaseModel{
public static function tablePk(): string{
return 'id';
}
public static function tableName(): string{
return 'point';
}
public function getMerTakeLocationAttr($value){
return explode(',', $value);
}
public function getMerTakeDayAttr($value){
return explode(',', $value);
}
public function getMerTakeTimeAttr($value){
return explode(',', $value);
}
}

View File

@ -147,15 +147,15 @@ class Merchant extends BaseModel
}]); }]);
} }
public function getServicesTypeAttr() public function getServicesTypeAttr(){
{ $merId = $this->mer_id ?? 0;
//0 支持在线聊天 1 支持电话 -1 暂无客服 //0 支持在线聊天 1 支持电话 -1 暂无客服
$services_type = merchantConfig($this->mer_id,'services_type'); $services_type = merchantConfig($merId,'services_type');
if ($services_type) { if ($services_type) {
if (!$this->service_phone) $services_type = -1; if (!$this->service_phone) $services_type = -1;
} else { } else {
$services_type = 0; $services_type = 0;
$where = ['mer_id' => $this->mer_id, 'is_open' => 1,'status' => 1]; $where = ['mer_id' => $merId, 'is_open' => 1,'status' => 1];
$service = StoreService::where($where)->count(); $service = StoreService::where($where)->count();
if (!$service) $services_type = -1; if (!$service) $services_type = -1;
} }
@ -236,9 +236,10 @@ class Merchant extends BaseModel
return merchantConfig($this->mer_id, 'mer_certificate'); return merchantConfig($this->mer_id, 'mer_certificate');
} }
public function getIssetCertificateAttr() public function getIssetCertificateAttr(){
{ $merId = $this->mer_id ?? 0;
return count(merchantConfig($this->mer_id, 'mer_certificate') ?: []) > 0;
return count(merchantConfig((int)$merId, 'mer_certificate') ?: []) > 0;
} }
public function getMarginRemindStatusAttr() public function getMarginRemindStatusAttr()

View File

@ -0,0 +1,85 @@
<?php
namespace app\common\repositories\store;
use app\common\dao\store\PointDao;
use app\common\repositories\BaseRepository;
use think\exception\ValidateException;
class PointRepository extends BaseRepository{
public function __construct(PointDao $dao){
$this->dao = $dao;
}
/**
* Common: 公共搜索模型
* Author: wu-hui
* Time: 2024/04/10 18:15
* @param $search
* @return \app\common\model\store\Point
*/
public function getSearchModel($search){
return $this->dao->searchList($search);
}
/**
* Common: 列表获取
* Author: wu-hui
* Time: 2024/04/10 18:18
* @param array $params
* @param int $page
* @param int $limit
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(array $params,int $page,int $limit):array{
$query = $this->dao->searchList($params);
$count = $query->count();
$list = $query->page($page,$limit)->select()->toArray();
return compact('count','list');
}
/**
* Common: 添加 / 编辑
* Author: wu-hui
* Time: 2024/04/10 18:17
* @param $params
* @throws \think\db\exception\DbException
*/
public function editInfo($params){
$data = [
"mer_id" => $params['mer_id'],
"mer_take_name" => $params['mer_take_name'],
"mer_take_phone" => $params['mer_take_phone'],
"mer_take_location" => implode(',',$params['mer_take_location']),
"mer_take_address" => $params['mer_take_address'],
"mer_take_day" => implode(',',$params['mer_take_day']),
"mer_take_time" => implode(',',$params['mer_take_time'])
];
// 判断:是否符合条件
if(empty($params['mer_take_name'])) throw new ValidateException('请输入提货点名称');
if(empty($params['mer_take_phone'])) throw new ValidateException('请输入提货点手机号');
if(empty($params['mer_take_location'])) throw new ValidateException('请选择经纬度');
if(empty($params['mer_take_address'])) throw new ValidateException('请输入提货点详细地址');
if(empty($params['mer_take_day'])) throw new ValidateException('请选择营业日期');
if(empty($params['mer_take_time'])) throw new ValidateException('请选择营业时间');
// 判断:是否已经存在
$isHas = $this->getSearchModel([])
->where('mer_take_name',$params['mer_take_name'])
->when(isset($params['id']) && $params['id'] !== '',function($query) use ($params){
$query->where('id','<>',(int)$params['id']);
})->value('id');
if($isHas > 0) throw new ValidateException('提货点已经存在');
// 操作
if((int)$params['id'] > 0) $this->dao->update((int)$params['id'], $data);// 编辑
else $this->dao->create($data);// 添加
}
}

View File

@ -62,13 +62,16 @@ class StoreCartRepository extends BaseRepository
if ($item['merchant']){ if ($item['merchant']){
$merchantData = $item['merchant']->append(['openReceipt'])->toArray(); $merchantData = $item['merchant']->append(['openReceipt'])->toArray();
} else { } else {
$merchantData = ['mer_id' => 0]; $merchantData = [
'mer_id' => 0,
'delivery_way' => [1,2]
];
} }
unset($item['merchant']); unset($item['merchant']);
$coupon_make = app()->make(StoreCouponRepository::class); $coupon_make = app()->make(StoreCouponRepository::class);
if (!isset($arr[$item['mer_id']])) { if (!isset($arr[$item['mer_id']])) {
if ($hasCoupon) if ($hasCoupon) $merchantData['hasCoupon'] = $coupon_make->validMerCouponExists($item['mer_id'], $hasCoupon);
$merchantData['hasCoupon'] = $coupon_make->validMerCouponExists($item['mer_id'], $hasCoupon);
$arr[$item['mer_id']] = $merchantData; $arr[$item['mer_id']] = $merchantData;
} }
if ($hasCoupon && !$arr[$item['mer_id']]['hasCoupon']) { if ($hasCoupon && !$arr[$item['mer_id']]['hasCoupon']) {

View File

@ -130,6 +130,12 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
$order_svip_discount = 0; $order_svip_discount = 0;
// 循环计算每个店铺的订单数据 // 循环计算每个店铺的订单数据
foreach($merchantCartList as &$merchantCart){ foreach($merchantCartList as &$merchantCart){
// 数据补齐
if(!in_array('coupon', array_keys($merchantCart))) $merchantCart['coupon'] = [];
if(!in_array('config', array_keys($merchantCart))) $merchantCart['config'] = [];
// 其他参数
$postageRule = []; $postageRule = [];
$total_price = 0; $total_price = 0;
$total_num = 0; $total_num = 0;
@ -957,9 +963,8 @@ class StoreOrderCreateRepository extends StoreOrderRepository{
// $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true); // $orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
$orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key); $orderInfo = Cache::get('order_create_cache'.$uid.'_'.$key);
if(!$orderInfo){ if(!$orderInfo) throw new ValidateException('订单操作超时,请刷新页面');
throw new ValidateException('订单操作超时,请刷新页面');
}
$order_model = $orderInfo['order_model']; $order_model = $orderInfo['order_model'];
$order_extend = $orderInfo['order_extend']; $order_extend = $orderInfo['order_extend'];
if(!$orderInfo['order_delivery_status']){ if(!$orderInfo['order_delivery_status']){

View File

@ -1296,9 +1296,12 @@ class ProductRepository extends BaseRepository
$merchantRepository = app()->make(MerchantRepository::class); $merchantRepository = app()->make(MerchantRepository::class);
$care = false; $care = false;
if ($uid) $care = $merchantRepository->getCareByUser($merId, $uid); if ($uid) $care = $merchantRepository->getCareByUser($merId, $uid);
$merchant = $merchantRepository->search(['mer_id' => $merId])->with(['type_name']) $merchant = $merchantRepository->search(['mer_id' => $merId])
->field('mer_id,mer_name,real_name,mer_address,mer_keyword,mer_avatar,mer_banner,mini_banner,product_score,service_score,postage_score,service_phone,care_count,type_id')->find() ->with(['type_name'])
->append(['isset_certificate','services_type'])->toArray(); ->field('mer_id,mer_name,real_name,mer_address,mer_keyword,mer_avatar,mer_banner,mini_banner,product_score,service_score,postage_score,service_phone,care_count,type_id')
->findOrEmpty()
->append(['isset_certificate','services_type'])
->toArray();
$merchant['top_banner'] = merchantConfig($merId, 'mer_pc_top'); $merchant['top_banner'] = merchantConfig($merId, 'mer_pc_top');
$merchant['care'] = $care; $merchant['care'] = $care;
$merchant['recommend'] = $this->getRecommend($productId,$merId); $merchant['recommend'] = $this->getRecommend($productId,$merId);
@ -1444,7 +1447,8 @@ class ProductRepository extends BaseRepository
} else { } else {
$res = json_decode($res, true); $res = json_decode($res, true);
} }
$res['merchant'] = $this->getMerchant($product['mer_id'],$product['product_id'],$uid);
$res['merchant'] = $this->getMerchant((int)$product['mer_id'],$product['product_id'],$uid);
return $res; return $res;
} }

View File

@ -0,0 +1,70 @@
<?php
namespace app\controller\admin\store;
use app\common\repositories\store\PointRepository;
use think\App;
use crmeb\basic\BaseController;
class Point extends BaseController{
protected $repository;
public function __construct(App $app, PointRepository $repository){
parent::__construct($app);
$this->repository = $repository;
}
/**
* Common: 列表获取
* Author: wu-hui
* Time: 2024/04/10 18:20
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getList(){
[$page, $limit] = $this->getPage();
$params = $this->request->params(['mer_take_name']);
$data = $this->repository->getList((array)$params,(int)$page,(int)$limit);
return app('json')->success($data);
}
/**
* Common: 编辑信息
* Author: wu-hui
* Time: 2024/04/10 18:19
* @return mixed
* @throws \think\db\exception\DbException
*/
public function editInfo(){
$params = $this->request->params([
['id', 0],
'mer_take_name',
'mer_take_phone',
'mer_take_location',
'mer_take_address',
'mer_take_day',
'mer_take_time'
]);
$params['mer_id'] = (int)$this->request->merId();
$this->repository->editInfo($params);
return app('json')->success();
}
/**
* Common: 删除信息
* Author: wu-hui
* Time: 2024/04/10 18:42
* @param $id
* @return mixed
*/
public function delInfo($id){
$id = (int)$this->request->param('id');
$this->repository->update($id,['is_del' => 1]);
return app('json')->success('删除成功');
}
}

View File

@ -299,8 +299,7 @@ class StoreProduct extends BaseController
* @author Qinii * @author Qinii
* @day 2020-06-24 * @day 2020-06-24
*/ */
public function config() public function config(){
{
$data = systemConfig(['extension_status','svip_switch_status','integral_status']); $data = systemConfig(['extension_status','svip_switch_status','integral_status']);
$merData= merchantConfig($this->request->merId(),['mer_integral_status','mer_integral_rate','mer_svip_status','svip_store_rate']); $merData= merchantConfig($this->request->merId(),['mer_integral_status','mer_integral_rate','mer_svip_status','svip_store_rate']);
$svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'],100,2) : 0; $svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'],100,2) : 0;
@ -310,8 +309,8 @@ class StoreProduct extends BaseController
$data['integral_rate'] = $merData['mer_integral_rate'] ?: 0; $data['integral_rate'] = $merData['mer_integral_rate'] ?: 0;
// $data['delivery_way'] = $this->request->merchant()->delivery_way ? $this->request->merchant()->delivery_way : [2]; // $data['delivery_way'] = $this->request->merchant()->delivery_way ? $this->request->merchant()->delivery_way : [2];
// $data['is_audit'] = $this->request->merchant()->is_audit; // $data['is_audit'] = $this->request->merchant()->is_audit;
$data['delivery_way'] = [2];
$data['is_audit'] = 0; $data['is_audit'] = 0;
$data['delivery_way'] = [1,2];
return app('json')->success($data); return app('json')->success($data);
} }

View File

@ -515,6 +515,15 @@ Route::group(function () {
'_path' => '/config/guarantee', '_path' => '/config/guarantee',
'_auth' => true, '_auth' => true,
]); ]);
// 提货点管理
Route::group('store/point', function () {
Route::get('list','/getList')->name('systemStorePointList');
Route::post('edit','/editInfo')->name('systemStorePointEditInfo');
Route::post('del/:id','/delInfo')->name('systemStorePointDelInfo');
})->prefix('admin.store.Point');
})->middleware(AllowOriginMiddleware::class) })->middleware(AllowOriginMiddleware::class)