This commit is contained in:
彭桃 2023-03-10 11:38:17 +08:00
commit 5fc9c10654
23 changed files with 254 additions and 16 deletions

7
404.html Normal file
View File

@ -0,0 +1,7 @@
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

View File

@ -19,6 +19,9 @@ use think\Model;
class StoreCategory extends BaseModel
{
// 设置当前模型的数据库连接
protected $connection = 'mysql';
/**
* @return string
* @author xaboy

View File

@ -17,6 +17,7 @@ use app\common\model\BaseModel;
use app\common\model\store\coupon\StoreCouponProduct;
use app\common\model\store\StoreSeckillActive;
use app\common\model\system\merchant\Merchant;
use app\common\model\system\supplychain\SupplyChainLinkMerchant;
use think\db\BaseQuery;
class Spu extends BaseModel
@ -163,6 +164,16 @@ class Spu extends BaseModel
{
return $this->hasOne(Merchant::class,'mer_id','mer_id');
}
/**
* 供应链中间件
*
*/
public function supplyChainLink()
{
return $this->hasOne(SupplyChainLinkMerchant::class, 'mer_id', 'eb_merchant_id');
}
public function issetCoupon()
{
return $this->hasOne(StoreCouponProduct::class, 'product_id', 'product_id')->alias('A')

View File

@ -24,6 +24,8 @@ use app\common\model\system\config\SystemConfigValue;
use app\common\model\system\financial\Financial;
use app\common\model\system\serve\ServeOrder;
use app\common\repositories\store\StoreActivityRepository;
use app\common\model\system\supplychain\SupplyChain;
use app\common\model\system\supplychain\SupplyChainLinkMerchant;
class Merchant extends BaseModel
{
@ -53,7 +55,7 @@ class Merchant extends BaseModel
if (!$value) return [];
return explode(',',$value);
}
public function product()
{
return $this->hasMany(Product::class, 'mer_id', 'mer_id');
@ -64,6 +66,7 @@ class Merchant extends BaseModel
return $this->hasMany(SystemConfigValue::class, 'mer_id', 'mer_id');
}
public function showProduct()
{
return $this->hasMany(Product::class, 'mer_id', 'mer_id')
@ -181,6 +184,25 @@ class Merchant extends BaseModel
return $this->merchantType()->bind(['type_name']);
}
/**
* 供应链中间件
*
*/
public function SupplyChainLink()
{
return $this->hasOne(SupplyChainLinkMerchant::class, 'eb_merchant_id', 'mer_id');
}
/**
*
* 关联供应链
*
*/
public function supplyChain()
{
return $this->hasOneThrough(SupplyChain::class, SupplyChainLinkMerchant::class, 'eb_merchant_id', 'id', 'mer_id', 'fa_supply_chain_id');
}
public function getMerCommissionRateAttr()
{
return $this->commission_rate > 0 ? $this->commission_rate : bcmul($this->merchantCategory->commission_rate, 100, 4);

View File

@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\model\system\supplychain;
use app\common\model\BaseModel;
class SupplyChain extends BaseModel
{
// 设置当前模型的数据库连接
protected $connection = 'nongke';
/**
* @return string
* @author xaboy
* @day 2020-03-30
*/
public static function tablePk(): string
{
return 'id';
}
/**
* @return string
* @author xaboy
* @day 2020-03-30
*/
public static function tableName(): string
{
return 'fa_supply_chain';
}
}

View File

@ -0,0 +1,65 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\model\system\supplychain;
use app\common\model\BaseModel;
use app\common\model\store\StoreCategory;
class SupplyChainLinkMerchant extends BaseModel
{
// 设置当前模型的数据库连接
protected $connection = 'nongke';
/**
* @return string
* @author xaboy
* @day 2020-03-30
*/
public static function tablePk(): string
{
return 'id';
}
/**
* @return string
* @author xaboy
* @day 2020-03-30
*/
public static function tableName(): string
{
return 'fa_supply_chain_link_merchant';
}
/**
* 所属供应链
* 一对一
*
*/
public function supplyChain()
{
return $this->hasOne(SupplyChain::class, 'id', 'fa_supply_chain_id');
}
/**
*
* 商户下的分类
*
*/
public function category()
{
return $this->hasMany(StoreCategory::class, 'mer_id', 'eb_merchant_id');
}
}

View File

@ -895,8 +895,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
) + ['allow_address' => !$allow_no_address, 'order_delivery_status' => $orderDeliveryStatus];
}
public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post)
public function v2CreateOrder(int $pay_type, $user, array $cartId, array $extend, array $mark, array $receipt_data, array $takes = null, array $useCoupon = null, bool $useIntegral = false, int $addressId = null, array $post, int $source)
{
$uid = $user->uid;
$orderInfo = $this->v2CartIdByOrderInfo($user, $cartId, $takes, $useCoupon, $useIntegral, $addressId, true);
$order_model = $orderInfo['order_model'];

View File

@ -25,6 +25,7 @@ use app\common\dao\store\product\SpuDao;
use app\common\repositories\store\StoreCategoryRepository;
use app\common\repositories\store\StoreSeckillActiveRepository;
use app\common\repositories\user\UserVisitRepository;
use app\common\model\system\supplychain\SupplyChainLinkMerchant;
use think\facade\Queue;
class SpuRepository extends BaseRepository
@ -118,11 +119,12 @@ class SpuRepository extends BaseRepository
* @param $page
* @param $limit
* @param $userInfo
* @param $source 请求来源
* @return array
* @author Qinii
* @day 12/18/20
*/
public function getApiSearch($where, $page, $limit, $userInfo = null)
public function getApiSearch($where, $page, $limit, $userInfo = null, $source = 2)
{
if (isset($where['keyword']) && !empty($where['keyword'])) {
if (preg_match('/^(\/@[1-9]{1}).*\*\//', $where['keyword'])) {
@ -137,14 +139,29 @@ class SpuRepository extends BaseRepository
}
$where['spu_status'] = 1;
$where['mer_status'] = 1;
$query = $this->dao->search($where);
$query->with([
'merchant' => function ($query) {
$query->field($this->merchantFiled)->with(['type_name']);
},
'issetCoupon',
'issetCoupon'
]);
// 假如是小组服务采购商品,则增加供应链商品的筛选,只获取已入驻商户的商品
if($source == 1)
{
// 获取供应链商户ID
$MerListId = SupplyChainLinkMerchant::with(['supplyChain', 'category'])
->hasWhere('supplyChain', ['status' => 1]) // 启用的供应链团队
->group('eb_merchant_id') // 以分类分组
->column('eb_merchant_id');
// 只获取当前供应链内商户的商品
$query->whereIn('S.mer_id', $MerListId);
}
$productMake = app()->make(ProductRepository::class);
$count = $query->count();
@ -154,6 +171,7 @@ class SpuRepository extends BaseRepository
$append[] = 'max_extension';
$list->append($append);
$list = $this->getBorderList($list);
return compact('count', 'list');
}

View File

@ -68,7 +68,7 @@ class StoreCart extends BaseController
{
$data = $this->checkParams($validate);
if(!in_array($data['product_type'],[0,1,2,3,4])) return app('json')->fail('商品类型错误');
if(!in_array($data['product_type'],[0,1,2,3,4,99])) return app('json')->fail('商品类型错误');
if ($data['cart_num'] <= 0) return app('json')->fail('购买数量有误');
$user = $this->request->userInfo();
event('user.cart.before',compact('user','data'));
@ -103,7 +103,7 @@ class StoreCart extends BaseController
$data['product_id'] = $result['product']['product_id'];
break;
case 99: //小组代购
$result = app()->make(ProductGroupRepository::class)->cartCheck($data,$this->request->userInfo());
$result = app()->make(ProductRepository::class)->cartCheck($data,$this->request->userInfo());
$data['source'] = $data['product_type'];
$data['source_id'] = $data['group_buying_id'];
$data['product_id'] = $result['product']['product_id'];

View File

@ -106,7 +106,7 @@ class StoreCartDg extends BaseController
$data['product_id'] = $result['product']['product_id'];
break;
case 99: //小组代购
$result = app()->make(ProductGroupRepository::class)->cartCheck($data,$this->request->userInfo());
$result = app()->make(ProductDgRepository::class)->cartCheck($data,$this->request->userInfo());
$data['source'] = $data['product_type'];
$data['source_id'] = $data['group_buying_id'];
$data['product_id'] = $result['product']['product_id'];

View File

@ -88,6 +88,7 @@ class StoreOrder extends BaseController
$payType = $this->request->param('pay_type');
$post = (array)$this->request->param('post');
$is_dg = $this->request->param('is_dg',0);
$source = (int)$this->request->param('source'); // 1 小组服务 2 普通来源
$isPc = $payType === 'pc';
if ($isPc) {
$payType = 'balance';
@ -115,8 +116,8 @@ class StoreOrder extends BaseController
// if (!$addressId)
// return app('json')->fail('请选择地址');
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post) {
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post);
$groupOrder = app()->make(LockService::class)->exec('order.create', function () use ($orderCreateRepository, $receipt_data, $mark, $extend, $cartId, $payType, $takes, $couponIds, $useIntegral, $addressId, $post,$source) {
return $orderCreateRepository->v2CreateOrder(array_search($payType, StoreOrderRepository::PAY_TYPE), $this->request->userInfo(), $cartId, $extend, $mark, $receipt_data, $takes, $couponIds, $useIntegral, $addressId, $post,$source);
});
if ($groupOrder['pay_price'] == 0) {

View File

@ -38,8 +38,11 @@ class StoreCategory extends BaseController
*/
public function lst()
{
$source = $this->request->param('source'); // 1 小组服务 2 普通来源
$data = $this->repository->getHot(0);
$list = $this->repository->getApiFormatList(0,1);
$list = $this->repository->getApiFormatList(0, 1, $source);
$ret =[];
foreach ($list as $key => $value) {
if (isset($value['children'])) {

View File

@ -60,11 +60,13 @@ class StoreSpu extends BaseController
'merchant_category_id',
'is_good'
]);
$where['is_gift_bag'] = 0;
$where['product_type'] = 0;
$where['order'] = $where['order'] ?: 'star';
$source = $this->request->param('source'); // 1 小组服务 2 普通来源
if ($where['is_trader'] != 1) unset($where['is_trader']);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo);
$data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo, $source);
return app('json')->success($data);
}

BIN
basic/BaseAuth.php Normal file

Binary file not shown.

BIN
basic/BaseController.php Normal file

Binary file not shown.

BIN
basic/BaseManager.php Normal file

Binary file not shown.

BIN
basic/BaseMessage.php Normal file

Binary file not shown.

BIN
basic/BaseStorage.php Normal file

Binary file not shown.

BIN
basic/BaseUpload.php Normal file

Binary file not shown.

View File

@ -12,6 +12,9 @@
namespace crmeb\traits;
use app\common\model\system\supplychain\SupplyChainLinkMerchant;
trait CategoresDao
{
public $path = 'path';
@ -79,11 +82,29 @@ trait CategoresDao
* @return mixed
* @author Qinii
*/
public function getAll($mer_id = 0,$status = null)
{
return $this->getModel()::getDB()->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){
public function getAll($mer_id = 0,$status = null, $source = 2)
{
// 验证来源 1 小组服务 2 普通来源
if($source == 1)
{
// 获取供应链商户ID
$MerList = SupplyChainLinkMerchant::with(['supplyChain', 'category'])
->hasWhere('supplyChain', ['status' => 1]) // 启用的供应链团队
->group('eb_merchant_id') // 以分类分组
->column('eb_merchant_id');
// 获取供应链商户共同拥有的分类
return $this->getModel()::getDB()->whereIn('mer_id', $MerList)->when(($status !== null),function($query)use($status){
$query->where($this->getStatus(),$status);
})->order('sort DESC,'.$this->getPk().' DESC')->select();
}else{
\think\facade\Log::record('普通访问');
return $this->getModel()::getDB()->where('mer_id', $mer_id)->when(($status !== null),function($query)use($status){
$query->where($this->getStatus(),$status);
})->order('sort DESC,'.$this->getPk().' DESC')->select();
}
}
/**

View File

@ -33,8 +33,8 @@ trait CategoresRepository
* @param null $status
* @return array
*/
public function getApiFormatList($merID,$status = null)
{
public function getApiFormatList($merID,$status = null, $source = 2)
{
return formatCategory($this->dao->getAll($merID,$status)->hidden(['path','level','mer_id','create_time'])->toArray(), $this->dao->getPk());
}

39
index.html Normal file
View File

@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>恭喜,站点创建成功!</title>
<style>
.container {
width: 60%;
margin: 10% auto 0;
background-color: #f0f0f0;
padding: 2% 5%;
border-radius: 10px
}
ul {
padding-left: 20px;
}
ul li {
line-height: 2.3
}
a {
color: #20a53a
}
</style>
</head>
<body>
<div class="container">
<h1>恭喜, 站点创建成功!</h1>
<h3>这是默认index.html本页面由系统自动生成</h3>
<ul>
<li>本页面在FTP根目录下的index.html</li>
<li>您可以修改、删除或覆盖本页面</li>
<li>FTP相关信息请到“面板系统后台 > FTP” 查看</li>
</ul>
</div>
</body>
</html>

0
public/nginx.htaccess Normal file
View File