feat: 修改购物车商品查询逻辑和订单逻辑,根据用户身份调整商品价格计算方式,并更新相关文档
This commit is contained in:
parent
74c0456f1a
commit
f6c8b7865e
@ -64,6 +64,10 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
->toArray();
|
->toArray();
|
||||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||||
$this->off_activity=$off_activity;
|
$this->off_activity=$off_activity;
|
||||||
|
$user_ship = User::where('id', $userId)->value('user_ship');
|
||||||
|
if (in_array($user_ship, [4, 5, 6, 7])) {
|
||||||
|
$off_activity=1;
|
||||||
|
}
|
||||||
foreach ($list as $key => &$item) {
|
foreach ($list as $key => &$item) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
||||||
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
|
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace app\api\lists\product;
|
namespace app\api\lists\product;
|
||||||
|
|
||||||
|
|
||||||
use app\admin\lists\BaseAdminDataLists;
|
use app\api\lists\BaseApiDataLists;
|
||||||
use app\common\lists\ListsExtendInterface;
|
use app\common\lists\ListsExtendInterface;
|
||||||
use app\common\lists\ListsSortInterface;
|
use app\common\lists\ListsSortInterface;
|
||||||
use app\common\model\dict\DictType;
|
use app\common\model\dict\DictType;
|
||||||
@ -12,6 +12,7 @@ use app\common\model\store_product\StoreProduct;
|
|||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\cate\Cate;
|
use app\common\model\cate\Cate;
|
||||||
use app\common\model\Config;
|
use app\common\model\Config;
|
||||||
|
use app\common\model\user\User;
|
||||||
//use app\common\model\goods\GoodsLabel;
|
//use app\common\model\goods\GoodsLabel;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ use think\facade\Db;
|
|||||||
* Class goods
|
* Class goods
|
||||||
* @package app\api\goods
|
* @package app\api\goods
|
||||||
*/
|
*/
|
||||||
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExtendInterface
|
class ProductLists extends BaseApiDataLists implements ListsSearchInterface, ListsSortInterface, ListsExtendInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +37,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
'=' => ['store_id', 'cate_id', 'top_cate_id', 'two_cate_id'],
|
'=' => ['store_id', 'cate_id', 'top_cate_id', 'two_cate_id'],
|
||||||
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
|
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @notes 设置支持排序字段
|
* @notes 设置支持排序字段
|
||||||
@ -71,17 +71,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
*/
|
*/
|
||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
// $class_all = $this->request->get('class_all');
|
|
||||||
// if ($class_all) {
|
|
||||||
// //查3级别的
|
|
||||||
// $arr = Cate::where('pid', $class_all)->column('id');
|
|
||||||
// if ($arr) {
|
|
||||||
// $arr2 = Cate::where('pid', 'in', $arr)->column('id');
|
|
||||||
// $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)];
|
|
||||||
// } else {
|
|
||||||
// $this->searchWhere[] = ['cate_id', '=', $class_all];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
$order = $this->request->get('order', '');
|
$order = $this->request->get('order', '');
|
||||||
$field = $this->request->get('field', '');
|
$field = $this->request->get('field', '');
|
||||||
if (empty($order) || empty($field)) {
|
if (empty($order) || empty($field)) {
|
||||||
@ -116,20 +105,26 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
|||||||
}
|
}
|
||||||
public function extend()
|
public function extend()
|
||||||
{
|
{
|
||||||
// $off_activity = Config::where('name', 'off_activity')->value('value');
|
$price = 'price';
|
||||||
// if($off_activity==1){
|
$op_price = 'price';
|
||||||
// $data=[
|
$off_activity = 0;
|
||||||
// 'off_activity' => $off_activity,
|
if ($this->userId > 0) {
|
||||||
// 'price' => 'cost',
|
$user_ship = User::where('id', $this->userId)->value('user_ship');
|
||||||
// 'op_price' => 'price',
|
if (in_array($user_ship, [4, 5, 6, 7])) {
|
||||||
// ];
|
$price = 'cost';
|
||||||
// }else{
|
$op_price = 'price';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||||
|
if ($off_activity == 1) {
|
||||||
|
$price = 'cost';
|
||||||
|
$op_price = 'price';
|
||||||
|
}
|
||||||
$data = [
|
$data = [
|
||||||
'off_activity' => 0,
|
'off_activity' => $off_activity,
|
||||||
'price' => 'price',
|
'price' => $price,
|
||||||
'op_price' => 'price',
|
'op_price' => $op_price,
|
||||||
];
|
];
|
||||||
// }
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,15 @@ class OrderLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
unset($cart_select[$k]['id']);
|
unset($cart_select[$k]['id']);
|
||||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||||
// if ($off_activity == 1) {
|
if ($off_activity == 1) {
|
||||||
// $price = $find['cost'];
|
$price = $find['cost'];
|
||||||
// } else {
|
} else {
|
||||||
|
if ($user && in_array($user['user_ship'], [4, 5, 6, 7])) {
|
||||||
|
$price = 'cost';
|
||||||
|
} else {
|
||||||
$price = $find['price'];
|
$price = $find['price'];
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
$cart_select[$k]['price'] = $price;
|
$cart_select[$k]['price'] = $price;
|
||||||
$cart_select[$k]['cost'] = $find['cost'];
|
$cart_select[$k]['cost'] = $find['cost'];
|
||||||
$cart_select[$k]['vip'] = 0;
|
$cart_select[$k]['vip'] = 0;
|
||||||
@ -534,7 +538,8 @@ class OrderLogic extends BaseLogic
|
|||||||
(new StoreProductLog())->update(
|
(new StoreProductLog())->update(
|
||||||
[
|
[
|
||||||
'store_id' => $params['store_id']
|
'store_id' => $params['store_id']
|
||||||
], ['oid' => $order['id']]
|
],
|
||||||
|
['oid' => $order['id']]
|
||||||
);
|
);
|
||||||
(new StoreOrderCartInfo())->update([
|
(new StoreOrderCartInfo())->update([
|
||||||
'verify_code' => $params['verify_code'] . '-1',
|
'verify_code' => $params['verify_code'] . '-1',
|
||||||
|
@ -588,7 +588,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
|
|
||||||
}
|
}
|
||||||
//积分写入
|
//积分写入
|
||||||
if(in_array($order['pay_type'],[3,7,9,13,17])&&$order['uid']>0){
|
if(isset($user) && $user['user_ship']==0){
|
||||||
UserSignLogic::OrderWrite($order);
|
UserSignLogic::OrderWrite($order);
|
||||||
}
|
}
|
||||||
if ($off_activity == 1) {
|
if ($off_activity == 1) {
|
||||||
@ -644,10 +644,10 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
switch ($user_ship) {
|
switch ($user_ship) {
|
||||||
case 1: // 厨师
|
case 1: // 厨师
|
||||||
case 4: // 商户
|
//case 4: // 商户
|
||||||
case 5: // 种养殖
|
//case 5: // 种养殖
|
||||||
case 6: // 酒店
|
// case 6: // 酒店
|
||||||
case 7: // 食堂
|
// case 7: // 食堂
|
||||||
case 8: // 一条龙
|
case 8: // 一条龙
|
||||||
CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id);
|
CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user