feat(order): 添加门店选择判断和商品查询优化
This commit is contained in:
parent
98abb78670
commit
9e0e1524f2
@ -66,6 +66,11 @@ class OrderLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0)
|
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [], $createOrder = 0)
|
||||||
{
|
{
|
||||||
|
if(empty($params['store_id']) || $params['store_id'] <= 0){
|
||||||
|
self::setError('请选择门店');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
||||||
if (empty($cart_select)) {
|
if (empty($cart_select)) {
|
||||||
@ -84,9 +89,9 @@ class OrderLogic extends BaseLogic
|
|||||||
self::$fresh_price = 0; //生鲜金额
|
self::$fresh_price = 0; //生鲜金额
|
||||||
/** 计算价格 */
|
/** 计算价格 */
|
||||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||||
$field = 'id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
$field = 'product_id id,store_name,image,unit,price,vip_price,cost,purchase,cate_id,store_info,rose';
|
||||||
foreach ($cart_select as $k => $v) {
|
foreach ($cart_select as $k => $v) {
|
||||||
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
|
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field($field)->find();
|
||||||
if (!$find) {
|
if (!$find) {
|
||||||
self::setError('商品不存在');
|
self::setError('商品不存在');
|
||||||
return false;
|
return false;
|
||||||
@ -114,7 +119,8 @@ class OrderLogic extends BaseLogic
|
|||||||
$price = $find['cost'];
|
$price = $find['cost'];
|
||||||
} else {
|
} else {
|
||||||
$price = $find['price'];
|
$price = $find['price'];
|
||||||
if (isset($params['store_id']) && $params['store_id'] == getenv('ACTIVITY_STORE_ID')) {
|
//单门店活动判断
|
||||||
|
if ($params['store_id'] == getenv('ACTIVITY_STORE_ID')) {
|
||||||
$storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price');
|
$storeBranchPrice = StoreBranchProduct::where('store_id', getenv('ACTIVITY_STORE_ID'))->where('product_id', $v['product_id'])->value('price');
|
||||||
if ($storeBranchPrice) {
|
if ($storeBranchPrice) {
|
||||||
$price = $storeBranchPrice;
|
$price = $storeBranchPrice;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user