Merge branch 'dev' of https://gitea.lihaink.cn/mkm/multi-store into dev
This commit is contained in:
commit
3bdd52e460
@ -14,8 +14,9 @@ class ProductStatisticLogic extends BaseLogic
|
||||
|
||||
public function get_product_ranking($where)
|
||||
{
|
||||
$list = StoreProductLog::where($where)->with('storeName')
|
||||
$list = StoreProductLog::where($where)->with('store')
|
||||
->field([
|
||||
'store_id',
|
||||
'product_id',
|
||||
'SUM(visit_num) as visit',
|
||||
'COUNT(distinct(uid)) as user',
|
||||
@ -30,7 +31,7 @@ class ProductStatisticLogic extends BaseLogic
|
||||
'COUNT(distinct(pay_uid))-1 as repeats'
|
||||
])->group('product_id')->order('pay' . ' desc')->limit(20)->select()->toArray();
|
||||
foreach ($list as $key => &$item) {
|
||||
if (!$item['store_name'] || !$item['image']) {
|
||||
if (!$item['store_name']) {
|
||||
unset($list[$key]);
|
||||
}
|
||||
if ($item['profit'] == null) $item['profit'] = 0;
|
||||
|
@ -25,6 +25,16 @@ class CartController extends BaseApiController
|
||||
$params = (new CartValidate())->post()->goCheck('add');
|
||||
$params['uid'] = $this->request->userId;
|
||||
$result = Cart::where(['uid' => $params['uid'], 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0,'delete_time' => null])->find();
|
||||
|
||||
//判断起批发价
|
||||
$batch = StoreBranchProduct::where(
|
||||
['product_id'=>$params['product_id'],
|
||||
'store_id' => $params['store_id']
|
||||
]
|
||||
)->value('batch');
|
||||
if($params['cart_num'] < $batch){
|
||||
return $this->fail('起批发量低于最低值'.$batch);
|
||||
}
|
||||
$count = Cart::where(['uid' => $params['uid'], 'delete_time' => null, 'is_pay' => 0])->count();
|
||||
if ($count > 100) {
|
||||
return $this->fail('购物车商品不能大于100个,请先结算');
|
||||
|
@ -4,6 +4,7 @@ namespace app\common\model\store_product_log;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
@ -18,6 +19,11 @@ class StoreProductLog extends BaseModel
|
||||
protected $name = 'store_product_log';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function store()
|
||||
{
|
||||
return $this->hasOne(SystemStore::class, 'id', 'store_id')
|
||||
->bind(['store_name' => 'name', 'store_phone' => 'phone', 'store_detailed_address' => 'detailed_address', 'store_simple_address' => 'address']);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -28,6 +28,15 @@ class CartController extends BaseAdminController
|
||||
$params['staff_id'] = $adminInfo['admin_id'];
|
||||
$params['store_id'] = $adminInfo['store_id'];
|
||||
$result = Cart::where(['uid' => 0,'staff_id'=>$adminInfo['admin_id'], 'store_id' => $adminInfo['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0])->find();
|
||||
//判断起批发价
|
||||
$batch = StoreBranchProduct::where(
|
||||
['product_id'=>$params['product_id'],
|
||||
'store_id' => $adminInfo['store_id']
|
||||
]
|
||||
)->value('batch');
|
||||
if($params['cart_num'] < $batch){
|
||||
return $this->fail('起批发量低于最低值'.$batch);
|
||||
}
|
||||
$count = Cart::where(['uid' => $params['uid'], 'is_pay' => 0])->count();
|
||||
if ($count > 100) {
|
||||
return $this->fail('购物车商品不能大于100个,请先结算');
|
||||
|
Loading…
x
Reference in New Issue
Block a user