Merge pull request 'dev' (#35) from dev into main

Reviewed-on: #35
This commit is contained in:
mkm 2024-07-11 17:08:19 +08:00
commit 0ea88df531
20 changed files with 367 additions and 199 deletions

View File

@ -8,6 +8,8 @@ use app\admin\controller\BaseAdminController;
use app\admin\lists\user\UserLists; use app\admin\lists\user\UserLists;
use app\admin\logic\user\UserLogic; use app\admin\logic\user\UserLogic;
use app\admin\validate\user\UserValidate; use app\admin\validate\user\UserValidate;
use app\api\lists\user_sign\UserSignLists;
use app\api\lists\user_sign_log\UserSignLogLists;
class UserController extends BaseAdminController class UserController extends BaseAdminController
{ {
@ -82,6 +84,19 @@ class UserController extends BaseAdminController
} }
/**
* 礼品券/冻结券
*/
public function userSing()
{
return $this->dataLists(new UserSignLogLists());
}
//用户领取列表 //用户领取列表
public function userGiftList() public function userGiftList()
{ {

View File

@ -75,69 +75,30 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
if (!empty($this->request->adminInfo['store_id'])) { if (!empty($this->request->adminInfo['store_id'])) {
$item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0; $item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
} }
//厨师判断 other_uid不为空 user_ship=1厨师
$cookCheck = 0;
if(!empty($item['other_uid']) && $item['other_uid'] >0){
$cookCheck = User::where('id', $item['other_uid'])->value('user_ship')??0;
}
if ($item['financial_pm'] == 0) { if ($item['financial_pm'] == 0) {
$item['number'] = '-' . $item['number']; $item['number'] = '-' . $item['number'];
$item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']); $Identity = OrderEnum::getFinancialType($item['financial_type']);
if($cookCheck == 1 && $item['financial_type'] ==12){
$Identity ="厨师";
}
$item['financial_type_name'] = '订单支出:' .$Identity;
} else { } else {
$item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得'; $Identity = OrderEnum::getFinancialType($item['financial_type']);
if($cookCheck == 1 && $item['financial_type'] ==12){
$Identity ="厨师";
}
$item['financial_type_name'] = $Identity . '获得';
$item['number'] = '+' . $item['number']; $item['number'] = '+' . $item['number'];
} }
$item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name'); $item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
$item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : ''; $item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']); $item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
})->toArray(); })->toArray();
// foreach ($data as $key => $item) {
// $list1 = StoreFinanceFlow::where('order_id', $item['order_id'])->where('financial_type', '>', 1)->field($field)->select()->each(function ($item) {
// if ($item['user_id'] <= 0) {
// $item['nickname'] = '游客';
// } else {
// $id = $item['user_id'];
// $item['nickname'] = User::where('id', $item['user_id'])->value('nickname') . "|$id";
// }
// if (!empty($this->request->adminInfo['store_id'])) {
// $item['financial_pm'] = $item['financial_pm'] == 0 ? 1 : 0;
// }
// if ($item['financial_pm'] == 0) {
// $item['number'] = '-' . $item['number'];
// $item['financial_type_name'] = '订单支出:' . OrderEnum::getFinancialType($item['financial_type']);
// } else {
// $item['financial_type_name'] = OrderEnum::getFinancialType($item['financial_type']) . '获得';
// $item['number'] = '+' . $item['number'];
// }
// $item['staff_name'] = SystemStoreStaff::where('id', $item['staff_id'])->value('staff_name');
// $item['store_name'] = $item['store_id'] > 0 ? SystemStore::where('id', $item['store_id'])->value('name') : '';
// $item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
// });
// $list2 = UserSign::where('order_id', $item['order_sn'])->whereIn('user_ship', [0, 2, 3])->select();
// foreach ($list2 as $k => $v) {
// $list2[$k]['id'] = 'JF' . $v['id'];
// $list2[$k]['order_sn'] = $item['order_sn'];
// $list2[$k]['store_name'] = $item['store_name'];
// if($v['user_ship']==0){
// $list2[$k]['financial_pm'] = 1;
// $list2[$k]['number'] = '+' . $v['number'];
// }else{
// if($v['financial_pm']==1){
// $list2[$k]['financial_pm'] = 1;
// $list2[$k]['number'] = '+' . $v['number'];
// }else{
// $list2[$k]['financial_pm'] = 0;
// $list2[$k]['number'] = '-' . $v['number'];
// }
// }
// $list2[$k]['nickname'] = $v['uid'] > 0 ? User::where('id', $v['uid'])->value('nickname') . '|' . $v['uid'] : '游客';
// $list2[$k]['financial_type_name'] = $v['title'];
// $list2[$k]['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
// }
// $list3 = array_merge($list1->toArray(), $list2->toArray());
// // 提取 financial_pm 字段到单独的数组
// $financial_pm = array_column($list3, 'financial_pm');
// // 对 financial_pm 数组进行排序,这将影响原始数组
// array_multisort($financial_pm, SORT_ASC, $list3);
// $data[$key]['list']=$list3;
// }
return $data; return $data;
} }

View File

@ -47,13 +47,15 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
return StoreOrderCartInfo::where($this->searchWhere) return StoreOrderCartInfo::where($this->searchWhere)
->field('cart_info,product_id,store_id')->limit($this->limitOffset, $this->limitLength) ->field('cart_info,product_id,store_id')->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item) { ->select()->each(function ($item) {
$find=StoreBranchProduct::where('product_id',$item['product_id'])->where('store_id',$item['store_id'])->field('image,store_name')->find(); $find=StoreBranchProduct::where('product_id',$item['product_id'])->where('store_id',$item['store_id'])->field('image,store_name,store_info')->find();
if($find){ if($find){
$item['image']=$find['image'];//商品图片 $item['image']=$find['image'];//商品图片
$item['store_name']=$find['store_name'];//商品名称 $item['store_name']=$find['store_name'];//商品名称
$item['store_info']=$find['store_info'];//商品规格
}else{ }else{
$item['image']='';//商品图片 $item['image']='';//商品图片
$item['store_name']='';//商品名称 $item['store_name']='';//商品名称
$item['store_info']='';//商品规格-(数据库叫商品简介)
} }
return $item; //返回处理后的数据。 return $item; //返回处理后的数据。
}) })

View File

@ -4,6 +4,7 @@ namespace app\admin\lists\user_product_storage_log;
use app\admin\lists\BaseAdminDataLists; use app\admin\lists\BaseAdminDataLists;
use app\common\model\store_order\StoreOrder;
use app\common\model\user_product_storage_log\UserProductStorageLog; use app\common\model\user_product_storage_log\UserProductStorageLog;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
@ -28,6 +29,7 @@ class UserProductStorageLogLists extends BaseAdminDataLists implements ListsSear
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['uid', 'oid', 'product_id','status','store_id'],
'between_time' => ['create_time'], 'between_time' => ['create_time'],
]; ];
} }
@ -44,20 +46,44 @@ class UserProductStorageLogLists extends BaseAdminDataLists implements ListsSear
*/ */
public function lists(): array public function lists(): array
{ {
$store_id = $this->request->get('store_id','');
$order_sn = $this->request->get('order_sn','');
$order = StoreOrder::where('store_id',$store_id)
->where('order_id','like','%'.$order_sn.'%')->column('id');
if($order){
$where[]=['oid','in',$order];
$this->searchWhere[]=$where;
}
return UserProductStorageLog::where($this->searchWhere) return UserProductStorageLog::where($this->searchWhere)
->field(['id', 'oid', 'uid', 'product_id', 'store_id', 'financial_pm', 'nums']) ->field(['id', 'oid', 'uid', 'product_id', 'store_id', 'financial_pm', 'nums','times','update_time'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function($item){ ->select()->each(function($item){
$user=User::where('id',$item['uid'])->field('nickname,real_name')->find(); $user=User::where('id',$item['uid'])->field('nickname,real_name,mobile')->find();
$item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name');
$item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid']; $item['nickname']=$user['real_name']?$user['real_name'].'|'.$item['uid']:$user['nickname'].'|'.$item['uid'];
$item['store_name']=StoreProduct::where('id',$item['product_id'])->value('store_name'); $item['mobile'] = $user['mobile']??'';
$goods = StoreProduct::where('id',$item['product_id'])->field('store_name,image,store_info,price')->withTrashed()->find();
$item['store_name']=$goods['store_name']??'';
$item['store_name_img']=$goods['image']??'';
$item['store_info']=$goods['store_info']??'';//规格
$item['price']=$goods['price']??'';
$order = StoreOrder::where('id',$item['oid'])->withTrashed()->field('order_id,verify_code,verify_img')->find();
$item['verify_code'] = $order['verify_code']??'';
$item['order_id'] = $order['order_id']??'';
$item['verify_img'] = '';
if($order['verify_img']){
$item['verify_img'] = 'https://'.$this->request->host(true).$order['verify_img'];
}
if($item['financial_pm']==1){ if($item['financial_pm']==1){
$item['financial_pm']='增加'; $item['financial_pm']='增加';
}else{ }else{
$item['financial_pm']='减少'; $item['financial_pm']='减少';
} }
if($item['times']){
$item['times']=date('Y-m-d H:i:s',$item['times']);
}
return $item; return $item;
}) })
->toArray(); ->toArray();

View File

@ -283,6 +283,15 @@ class UserLogic extends BaseLogic
->page($params['page_no'],$params['page_size']) ->page($params['page_no'],$params['page_size'])
->order('id','desc') ->order('id','desc')
->select()->toArray(); ->select()->toArray();
foreach ($data as &$value){
if($value['status'] == 0){
$value['title'] = "购买商品".$value['all']."元获得".$value['number']."元返还金";
}else{
//退回到余额、微信、采购款
$back = self::dealTitleCate($value['pay_type']);
$value['title'] = "返还金解冻".$value['number']."元退回到".$back;
}
}
break; break;
default: default:
$data = []; $data = [];
@ -309,4 +318,29 @@ class UserLogic extends BaseLogic
]; ];
} }
public static function dealTitleCate($pay_type)
{
switch ($pay_type){
case 18:
$title = "采购款";
break;
case 17:
$title = "现金";
break;
case 3:
$title ="余额";
break;
case 7:
case 9:
$title ="微信";
break;
case 13:
$title ="支付宝";
break;
default:
$title ="默认";
}
return $title;
}
} }

View File

@ -0,0 +1,30 @@
<?php
namespace app\api\controller\user_product_storage_log;
use app\admin\lists\user_product_storage_log\UserProductStorageLogLists;
use app\api\controller\BaseApiController;
/**
* 用户商品储存控制器
* Class UserProductStorageLogController
* @package app\admin\controller\user_product_storage_log
*/
class UserProductStorageLogController extends BaseApiController
{
/**
* @notes 获取用户商品日志列表
* @return
* @author admin
* @date 2024/06/28 11:05
*/
public function lists()
{
return $this->dataLists(new UserProductStorageLogLists());
}
}

View File

@ -25,6 +25,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
protected $total_price = 0; protected $total_price = 0;
protected $activity_price = 0; protected $activity_price = 0;
protected $off_activity = 0; protected $off_activity = 0;
protected $user_ship = 0;
/** /**
@ -63,6 +64,11 @@ 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');
$user_ship = User::where('id', $userId)->value('user_ship');
if (in_array($user_ship, [4, 5, 6, 7])) {
$off_activity=1;
}
$this->user_ship=$user_ship;
$this->off_activity=$off_activity; $this->off_activity=$off_activity;
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']])
@ -108,17 +114,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
$data= [ $data= [
'off_activity' => $this->off_activity, 'off_activity' => $this->off_activity,
'total_price' => $this->total_price, 'total_price' => $this->total_price,
'msg' => '您已选购满500元支付成功后即可获得'.bcmul($this->total_price,0.1,2).'元品牌礼品兑换券,可到线下门店兑换礼品。', 'msg' => '',
'pay_price' => $this->total_price 'pay_price' => $this->total_price
]; ];
if($this->off_activity==0){//1 if($this->user_ship==0){
$this->activity_price = $this->total_price; $data['msg']='您已选购满500元支付成功后即可获得'.bcmul($this->total_price,0.1,2).'元品牌礼品兑换券,可到线下门店兑换礼品。';
}
if($this->off_activity==1){//1
$data['pay_price']=$this->activity_price; $data['pay_price']=$this->activity_price;
if($this->activity_price<500){ if($this->activity_price<500){
$data['msg']='还差'.bcsub(500,$this->activity_price,2).'即可获得10%的品牌礼品兑换券,可到线下门店兑换礼品。'; if($this->user_ship==0){
$data['pay_price']= $this->activity_price; $data['msg']='还差'.bcsub(500,$this->activity_price,2).'即可获得10%的品牌礼品兑换券,可到线下门店兑换礼品。';
}
}else{ }else{
$data['msg']= '您已选购满500元支付成功后即可获得'.bcmul($this->activity_price,0.1,2).'元品牌礼品兑换券,可到线下门店兑换礼品。'; if($this->user_ship==0){
$data['msg']= '您已选购满500元支付成功后即可获得'.bcmul($this->activity_price,0.1,2).'元品牌礼品兑换券,可到线下门店兑换礼品。';
}
} }
} }
return $data; return $data;

View File

@ -28,7 +28,7 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['paid', 'status', 'is_writeoff'], '=' => ['paid', 'status', 'is_writeoff','reservation'],
'between_time' => 'create_time', 'between_time' => 'create_time',
'%like%' => ['order_id'], '%like%' => ['order_id'],
]; ];

View File

@ -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,9 +21,10 @@ 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
{ {
protected $off_activity = 0;
protected $user_ship = 0;
/** /**
* @notes 设置搜索条件 * @notes 设置搜索条件
@ -33,10 +35,9 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['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,35 +72,41 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
*/ */
public function lists(): array public function lists(): array
{ {
// $class_all = $this->request->get('class_all'); $order = $this->request->get('order', '');
// if ($class_all) { $field = $this->request->get('field', '');
// //查3级别的 if (empty($order) || empty($field)) {
// $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','');
$field = $this->request->get('field','');
if(empty($order)||empty($field)){
$order = $this->sortOrder; $order = $this->sortOrder;
}else{ } else {
$order = [$field => $order]; $order = [$field => $order];
} }
$fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock'; $fields = 'id,product_id,cate_id,store_name,cost,store_id,vip_price,purchase,price,bar_code,image,sales,store_info,delete_time,unit,batch,top_cate_id,two_cate_id,stock';
$off_activity = Config::where('name', 'off_activity')->value('value');
$uid=0;
if($this->request->get('uid',0)>0){
$uid=$this->request->get('uid',0);
}elseif( $this->userId > 0){
$uid=$this->userId;
}
if ($uid>0) {
$user_ship = User::where('id', $uid)->value('user_ship');
if (in_array($user_ship, [4, 5, 6, 7])) {
$off_activity = 1;
}
}
$this->off_activity = $off_activity;
$this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['status', '=', 1];
// $this->searchWhere[] = ['stock', '>', 0]; // $this->searchWhere[] = ['stock', '>', 0];
return StoreBranchProduct::where($this->searchWhere) return StoreBranchProduct::where($this->searchWhere)
->field($fields) ->field($fields)
->with(['className', 'unitName']) ->with(['className', 'unitName'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order($order) ->order($order)
// ->page($this->limitOffset +1,$this->limitLength) // ->page($this->limitOffset +1,$this->limitLength)
->select()->toArray(); ->select()->each(function ($item) {
$item['tag']=' 赠10%品牌礼品券 ';
return $item;
})
->toArray();
} }
@ -116,20 +123,17 @@ 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=[ if ($this->off_activity == 1) {
// 'off_activity' => $off_activity, $price = 'cost';
// 'price' => 'cost', $op_price = 'price';
// 'op_price' => 'price', }
// ]; $data = [
// }else{ 'off_activity' => $this->off_activity,
$data=[ 'price' => $price,
'off_activity' => 0, 'op_price' => $op_price,
'price' => 'price', ];
'op_price' => 'price',
];
// }
return $data; return $data;
} }
} }

View File

@ -93,10 +93,17 @@ class SystemStoreLists extends BaseAdminDataLists implements ListsSearchInterfac
} }
}else{ }else{
foreach ($data as &$value){ if($latitude && $longitude){
$value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude); foreach ($data as &$value){
$value['distance'] = haversineDistance($value['latitude'],$value['longitude'],$latitude,$longitude);
}
}else{
foreach ($data as &$values){
$values['distance'] = 0;
}
} }
} }
usort($data, function ($a, $b) { usort($data, function ($a, $b) {

View File

@ -47,6 +47,7 @@ class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface
{ {
$type=$this->request->get('type',1); $type=$this->request->get('type',1);
$mark=$this->request->get('mark',''); $mark=$this->request->get('mark','');
$uid=$this->request->get('uid','');
if($type==1){ if($type==1){
$this->searchWhere[]=['type','in',[1,7,3]]; $this->searchWhere[]=['type','in',[1,7,3]];
$this->searchWhere[]=['status','=',1]; $this->searchWhere[]=['status','=',1];
@ -56,7 +57,11 @@ class UserSignLogLists extends BaseApiDataLists implements ListsSearchInterface
}elseif($mark==2){ }elseif($mark==2){
$this->searchWhere[]=['financial_pm','=',0]; $this->searchWhere[]=['financial_pm','=',0];
} }
$this->searchWhere[]=['uid','=',$this->userId]; if($uid){
$this->searchWhere[]=['uid','=',$uid];
}else{
$this->searchWhere[]=['uid','=',$this->userId];
}
$list=UserSignLog::where($this->searchWhere)->order('id desc') $list=UserSignLog::where($this->searchWhere)->order('id desc')
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->select()->each(function ($item){ ->select()->each(function ($item){

View File

@ -21,6 +21,7 @@ use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo; use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct; use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_attr_value\StoreProductAttrValue; use app\common\model\store_product_attr_value\StoreProductAttrValue;
use app\common\model\store_product_log\StoreProductLog;
use app\common\model\store_product_unit\StoreProductUnit; use app\common\model\store_product_unit\StoreProductUnit;
use app\common\model\system_store\SystemStore; use app\common\model\system_store\SystemStore;
use app\common\model\system_store\SystemStoreStaff; use app\common\model\system_store\SystemStoreStaff;
@ -54,7 +55,7 @@ class OrderLogic extends BaseLogic
public static $store_price; //门店零售价 public static $store_price; //门店零售价
public static $activity_price; public static $activity_price;
public static $deduction_price; public static $deduction_price;
public static $frozen_money;//返还金额 public static $frozen_money; //返还金额
/** /**
* @notes 获取购物车商品信息 * @notes 获取购物车商品信息
@ -76,32 +77,32 @@ class OrderLogic extends BaseLogic
self::$profit = 0; //利润 self::$profit = 0; //利润
self::$activity_price = 0; //活动减少 self::$activity_price = 0; //活动减少
self::$store_price = 0; //商户价 self::$store_price = 0; //商户价
self::$deduction_price =0; self::$deduction_price = 0;
self::$frozen_money =0;//返还金额 self::$frozen_money = 0; //返还金额
$deduction_price = 0; //抵扣金额 $deduction_price = 0; //抵扣金额
/** 计算价格 */ /** 计算价格 */
$off_activity = Config::where('name', 'off_activity')->value('value'); $off_activity = Config::where('name', 'off_activity')->value('value');
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id'; $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
foreach ($cart_select as $k => $v) { foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find(); $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
if (!$find) { if (!$find) {
// unset($cart_select[$k]); // unset($cart_select[$k]);
// continue; // continue;
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id'; $field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id';
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->withTrashed()->find(); $find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
$cart_select[$k]['status'] = 1;//缺货标识 $cart_select[$k]['status'] = 1; //缺货标识
} }
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 || in_array($user['user_ship'], [4, 5, 6, 7])) {
// $price = $find['cost']; $price = $find['cost'];
// } else { } 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;
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name')??''; //单位名称 $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name') ?? ''; //单位名称
//利润 //利润
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
@ -109,23 +110,23 @@ class OrderLogic extends BaseLogic
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价 $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价 $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){ if ($cart_select[$k]['total_price'] > $cart_select[$k]['pay_price']) {
$deduction_price=bcsub($cart_select[$k]['total_price'],$cart_select[$k]['pay_price'],2); $deduction_price = bcsub($cart_select[$k]['total_price'], $cart_select[$k]['pay_price'], 2);
$cart_select[$k]['deduction_price'] =$deduction_price;//抵扣金额 $cart_select[$k]['deduction_price'] = $deduction_price; //抵扣金额
} }
$cart_select[$k]['product_id'] = $find['product_id']; $cart_select[$k]['product_id'] = $find['product_id'];
$cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['old_cart_id'] = $v['id'];
$cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['cart_num'] = $v['cart_num'];
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
$cart_select[$k]['vip_frozen_price']=0; $cart_select[$k]['vip_frozen_price'] = 0;
//会员待返回金额 //会员待返回金额
if ($user && $off_activity==0){ if ($user && $off_activity == 0) {
if($user['user_ship']==4){ if ($user['user_ship'] == 4) {
//商户 //商户
$cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['store_price'], 2); $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['store_price'], 2);
}else{ } else {
//其他会员 //其他会员
$cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'], 2); $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['vip_price'], 2);
} }
} }
// d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] ); // d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] );
@ -143,8 +144,8 @@ class OrderLogic extends BaseLogic
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价 self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
self::$deduction_price=bcadd(self::$deduction_price,$deduction_price,2);//抵扣金额 self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额
self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2);//返还金额 self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额
// self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
} }
//加支付方式限制 //加支付方式限制
@ -152,7 +153,7 @@ class OrderLogic extends BaseLogic
// if ($user && $user['user_ship'] == 1 && $pay_type != 17) { // if ($user && $user['user_ship'] == 1 && $pay_type != 17) {
// $pay_price = self::$pay_price; // $pay_price = self::$pay_price;
// } else { // } else {
$pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
// } // }
//成本价 收益 //成本价 收益
$order = [ $order = [
@ -172,7 +173,7 @@ class OrderLogic extends BaseLogic
'activity_price' => self::$activity_price, 'activity_price' => self::$activity_price,
'activities' => self::$activity_price > 0 ? 1 : 0, 'activities' => self::$activity_price > 0 ? 1 : 0,
'deduction_price' => self::$deduction_price, 'deduction_price' => self::$deduction_price,
'frozen_money' => self::$frozen_money,//返还金额(活动关闭得时候有) 'frozen_money' => self::$frozen_money, //返还金额(活动关闭得时候有)
'source' => 0, 'source' => 0,
'is_storage' => $params['is_storage'] ?? 0, 'is_storage' => $params['is_storage'] ?? 0,
]; ];
@ -185,18 +186,18 @@ class OrderLogic extends BaseLogic
} }
//处理返回最近的店铺 //处理返回最近的店铺
$store_check = 0; $store_check = 0;
if(empty($user)){ if (empty($user)) {
$store_id = getenv('STORE_ID') ?? 1; $store_id = getenv('STORE_ID') ?? 1;
$store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; $store['near_store'] = SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? [];
}else{ } else {
$checkOrderStore = StoreOrder::where('uid',$user['id'])->field('id,store_id') $checkOrderStore = StoreOrder::where('uid', $user['id'])->field('id,store_id')
->order('id','desc')->find(); ->order('id', 'desc')->find();
if($checkOrderStore){ if ($checkOrderStore) {
$store['near_store'] =SystemStore::where('id', $checkOrderStore['store_id'])->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; $store['near_store'] = SystemStore::where('id', $checkOrderStore['store_id'])->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? [];
$store_check = 1; $store_check = 1;
}else{ } else {
$store_id = getenv('STORE_ID') ?? 1; $store_id = getenv('STORE_ID') ?? 1;
$store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; $store['near_store'] = SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? [];
} }
} }
if (empty($store_check)) { if (empty($store_check)) {
@ -211,7 +212,7 @@ class OrderLogic extends BaseLogic
$nearestStore = $value; $nearestStore = $value;
} }
} }
$store['near_store'] =[]; $store['near_store'] = [];
if ($nearestStore) { if ($nearestStore) {
$store['near_store'] = $nearestStore; $store['near_store'] = $nearestStore;
} }
@ -280,10 +281,10 @@ class OrderLogic extends BaseLogic
$goods_list[$k]['uid'] = $uid; $goods_list[$k]['uid'] = $uid;
$goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['cart_id'] = implode(',', $cartId);
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
// $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find(); // $StoreBranchProduct = StoreBranchProduct::where('id', $v['branch_product_id'])->withTrashed()->find();
// if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) { // if ($StoreBranchProduct['stock'] - $v['cart_num'] <= 0) {
// Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]); // Db::name('store_product_cate')->where(['cate_id' => $StoreBranchProduct['cate_id'], 'store_id' => $params['store_id']])->update(['count' => 0]);
// } // }
} }
(new StoreOrderCartInfo())->saveAll($goods_list); (new StoreOrderCartInfo())->saveAll($goods_list);
$where = ['is_pay' => 0]; $where = ['is_pay' => 0];
@ -450,7 +451,7 @@ class OrderLogic extends BaseLogic
$find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id']) $find['goods_list'] = StoreOrderCartInfo::where('oid', $find['id'])
->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) { ->field('product_id,cart_num nums,store_id')->select()->each(function ($item) use ($find) {
$find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find(); $find = StoreBranchProduct::where('product_id', $item['product_id'])->where('store_id', $find['store_id'])->find();
if(empty($find)){ if (empty($find)) {
$find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find(); $find = StoreProduct::where('id', $item['product_id'])->withTrashed()->find();
} }
$item['store_name'] = $find['store_name']; $item['store_name'] = $find['store_name'];
@ -529,6 +530,13 @@ class OrderLogic extends BaseLogic
'store_id' => $params['store_id'], 'store_id' => $params['store_id'],
'staff_id' => $params['staff_id'] ?? 0, 'staff_id' => $params['staff_id'] ?? 0,
], ['id' => $order['id']]); ], ['id' => $order['id']]);
//修改商品统计记录标识
(new StoreProductLog())->update(
[
'store_id' => $params['store_id']
],
['oid' => $order['id']]
);
(new StoreOrderCartInfo())->update([ (new StoreOrderCartInfo())->update([
'verify_code' => $params['verify_code'] . '-1', 'verify_code' => $params['verify_code'] . '-1',
'writeoff_time' => time(), 'writeoff_time' => time(),
@ -552,11 +560,11 @@ class OrderLogic extends BaseLogic
$financeFlowLogic->updateStatusUser($spread_find['id'], $order['spread_uid'], $spread_find['number'], $order['id']); $financeFlowLogic->updateStatusUser($spread_find['id'], $order['spread_uid'], $spread_find['number'], $order['id']);
} }
} }
$deposit = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 11])->value('number') ?? 0; $deposit = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 0, 'financial_type' => 11])->value('number') ?? 0;
$money = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 2])->value('number') ?? 0; $money = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 2])->value('number') ?? 0;
$financeFlowLogic->updateStatusStore($order['id'], $order['store_id'], $money, $deposit); $financeFlowLogic->updateStatusStore($order['id'], $order['store_id'], $money, $deposit);
//积分结算 //积分结算
if($order['is_storage']==0&&$order['source']==0){ if ($order['is_storage'] == 0 && $order['source'] == 0) {
UserSignLogic::WriteOff($order); UserSignLogic::WriteOff($order);
} }
Db::commit(); Db::commit();

View File

@ -42,10 +42,10 @@ class UserShipLists extends BaseAdminDataLists
if(!$this->request->__get('id')){ if(!$this->request->__get('id')){
$arr[]=['id'=>0,'title'=>'一般用户','limit'=>0]; $arr[]=['id'=>0,'title'=>'一般用户','limit'=>0];
} }
$type_id=$this->request->get('type_id',0); // $type_id=$this->request->get('type_id',0);
if($type_id!=4){ // if($type_id!=4){
$this->searchWhere[]=['id','<>',4]; // $this->searchWhere[]=['id','<>',4];
} // }
$lists = UserShip::where($this->searchWhere) $lists = UserShip::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->field($field) ->field($field)

View File

@ -20,7 +20,7 @@ class CommissionLogic extends BaseLogic
$platform = self::platform($order, 0.02, $transaction_id); //平台 $platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店 $store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id); self::suppliter($order, $moeny, $transaction_id);
@ -30,13 +30,13 @@ class CommissionLogic extends BaseLogic
*/ */
public static function setBrigade($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0) public static function setBrigade($order, $village_uid = 0, $brigade_uid = 0, $transaction_id = 0)
{ {
$user_1 = self::user($order, 0.05, $transaction_id, $brigade_uid, 14); //队长 $user_1 = self::user($order, 0.05, $transaction_id, $brigade_uid, 15); //队长
$user_2 = self::user($order, 0.03, $transaction_id, 0, 12); ////会员、厨师 $user_2 = self::user($order, 0.03, $transaction_id, 0, 12); ////会员、厨师
$user_3 = self::user($order, 0.01, $transaction_id, $village_uid, 15); //村长 $user_3 = self::user($order, 0.01, $transaction_id, $village_uid, 14); //村长
$platform = self::platform($order, 0.02, $transaction_id); //平台 $platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店 $store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id); self::suppliter($order, $moeny, $transaction_id);
@ -51,7 +51,7 @@ class CommissionLogic extends BaseLogic
$user_3 = self::user($order, 0.01, $transaction_id, $brigade_uid, 15); //队长 $user_3 = self::user($order, 0.01, $transaction_id, $brigade_uid, 15); //队长
$platform = self::platform($order, 0.02, $transaction_id); //平台 $platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.05, $transaction_id, 0); //门店 $store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 $attrition = self::attrition($order, 0.02, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2);
self::suppliter($order, $moeny, $transaction_id); self::suppliter($order, $moeny, $transaction_id);
} }
@ -61,9 +61,9 @@ class CommissionLogic extends BaseLogic
*/ */
public static function setStore($order, $transaction_id = 0) public static function setStore($order, $transaction_id = 0)
{ {
$platform = self::platform($order, 0.05, $transaction_id); //平台 $platform = self::platform($order, 0.02, $transaction_id); //平台
$store = self::store($order, 0.02, $transaction_id, 0); //门店 $store = self::store($order, 0.05, $transaction_id, 0); //门店
$attrition = self::attrition($order, 0.01,$transaction_id,16); //损耗 $attrition = self::attrition($order, 0.01, $transaction_id, 16); //损耗
$moeny = bcadd(bcadd($platform, $store, 2), $attrition, 2); $moeny = bcadd(bcadd($platform, $store, 2), $attrition, 2);
self::suppliter($order, $moeny, $transaction_id); self::suppliter($order, $moeny, $transaction_id);
} }
@ -78,8 +78,8 @@ class CommissionLogic extends BaseLogic
$financeLogic->order = $order; $financeLogic->order = $order;
$financeLogic->user['uid'] = $order['uid']; $financeLogic->user['uid'] = $order['uid'];
$pay_price = $order['pay_price']; $pay_price = $order['pay_price'];
if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); $pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
} }
$fees = bcdiv(bcmul($pay_price, $platformRate, 2), 1, 2); $fees = bcdiv(bcmul($pay_price, $platformRate, 2), 1, 2);
if ($fees > 0) { if ($fees > 0) {
@ -98,8 +98,8 @@ class CommissionLogic extends BaseLogic
$financeLogic->order = $order; $financeLogic->order = $order;
$financeLogic->user['uid'] = $order['uid']; $financeLogic->user['uid'] = $order['uid'];
$pay_price = $order['pay_price']; $pay_price = $order['pay_price'];
if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); $pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
} }
$fees = bcsub($pay_price, $platformRate, 2); $fees = bcsub($pay_price, $platformRate, 2);
if ($fees > 0) { if ($fees > 0) {
@ -123,31 +123,27 @@ class CommissionLogic extends BaseLogic
$money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find();
$deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度
$pay_price = $order['pay_price']; $pay_price = $order['pay_price'];
if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); $pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
} }
$store_profit = bcmul($pay_price, $platformRate, 2); $store_profit = bcmul($pay_price, $platformRate, 2);
if ($deposit > 0) { if ($deposit > 0) {
if ($deposit > $store_profit) { if ($deposit > $store_profit) {
if ($store_profit > 0) { if ($store_profit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $store_profit)->update();
$financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $store_profit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 $financeLogic->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
} }
} else { } else {
$money = bcsub($store_profit, $deposit, 2); $money = bcsub($store_profit, $deposit, 2);
if ($deposit > 0) { if ($deposit > 0) {
SystemStore::where('id', $order['store_id'])->inc('paid_deposit', $deposit)->update();
$financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $deposit, OrderEnum::ORDER_MARGIN, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
} }
if ($money) { if ($money) {
SystemStore::where('id', $order['store_id'])->inc('store_money', $money)->update();
$financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 $financeLogic->in($transaction_id, $money, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
} }
} }
} else { } else {
if ($store_profit > 0) { if ($store_profit > 0) {
SystemStore::where('id', $order['store_id'])->inc('store_money', $store_profit)->update();
$financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 $financeLogic->in($transaction_id, $store_profit, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费
} }
} }
@ -162,18 +158,34 @@ class CommissionLogic extends BaseLogic
{ {
$financeLogic = new StoreFinanceFlowLogic(); $financeLogic = new StoreFinanceFlowLogic();
$pay_price = $order['pay_price']; $pay_price = $order['pay_price'];
if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); $pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
} }
$fees = bcmul($pay_price, $userRate, 2); $fees = bcmul($pay_price, $userRate, 2);
if ($fees > 0) { if ($fees > 0) {
//记录用户余额收入 //记录用户余额收入
if ($uid) { if ($uid) {
$GiveUser = User::where('id', $order['uid'])->find(); if(in_array($enum,[14,15])&&$userRate==0.05){
if($GiveUser['user_ship'] != 5){//新限制 不为种养殖 $purchase_funds=User::where('id', $uid)->value('purchase_funds');
$capitalFlowDao = new CapitalFlowLogic($GiveUser); if($purchase_funds>0){
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees); $fees_two = bcmul($purchase_funds, $userRate, 2);
if($fees_two<$fees){
$fees=$fees_two;
}
}
} }
if($enum==12&&$userRate==0.07){
$purchase_funds=User::where('id', $uid)->value('purchase_funds');
if($purchase_funds>0){
$fees_two = bcmul($purchase_funds, $userRate, 2);
if($fees_two<$fees){
$fees=$fees_two;
}
}
}
$GiveUser = User::where('id', $order['uid'])->find();
$capitalFlowDao = new CapitalFlowLogic($GiveUser);
$capitalFlowDao->userIncome('system_balance_add', 'order', $order['id'], $fees);
} }
$financeLogic->user['uid'] = $order['uid']; $financeLogic->user['uid'] = $order['uid'];
$financeLogic->other_arr['vip_uid'] = $uid; $financeLogic->other_arr['vip_uid'] = $uid;
@ -194,14 +206,14 @@ class CommissionLogic extends BaseLogic
$financeLogic->order = $order; $financeLogic->order = $order;
$financeLogic->user['uid'] = $order['uid']; $financeLogic->user['uid'] = $order['uid'];
$pay_price = $order['pay_price']; $pay_price = $order['pay_price'];
if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ if (isset($order['dealVipAmount']) && $order['dealVipAmount'] > 0) {
$pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); $pay_price = bcsub($order['pay_price'], $order['dealVipAmount'], 2);
} }
$fees = bcmul($pay_price, $userRate, 2); $fees = bcmul($pay_price, $userRate, 2);
if ($fees > 0) { if ($fees > 0) {
SystemStore::where('id', $order['store_id'])->inc('attrition', $fees)->update();
$financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
$financeLogic->save();
} }
return $fees; return $fees;
} }

View File

@ -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) {
@ -603,9 +603,9 @@ class PayNotifyLogic extends BaseLogic
} }
//如果是会员需要返回会员金额 //如果是会员需要返回会员金额
if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) { // if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) {
$order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']); // $order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']);
} // }
if ($order['spread_uid'] > 0 || $user_ship > 0) { if ($order['spread_uid'] > 0 || $user_ship > 0) {
if ($order['spread_uid'] > 0 && $user_ship == 0) { if ($order['spread_uid'] > 0 && $user_ship == 0) {
$user_ship = User::where('id', $order['spread_uid'])->value('user_ship'); $user_ship = User::where('id', $order['spread_uid'])->value('user_ship');
@ -627,6 +627,18 @@ class PayNotifyLogic extends BaseLogic
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0; $village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
} }
} }
}else{
$address = UserAddress::where(['uid' => $order['spread_uid'], 'is_default' => 1])->find();
if ($address) {
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
if ($arr1) {
$village_uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id') ?? 0;
}
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
if ($arr2) {
$brigade_uid = User::where('id', 'in', $arr2)->where('user_ship', 3)->value('id') ?? 0;
}
}
} }
} else { } else {
//查询用户对应的村长和队长 //查询用户对应的村长和队长
@ -644,10 +656,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;

View File

@ -45,7 +45,7 @@ class UserSignLogic extends BaseLogic
return false; return false;
} }
$count = UserRecharge::where(['uid'=>$order->uid,'paid'=>YesNoEnum::YES])->count(); $count = UserRecharge::where(['uid'=>$order->uid,'paid'=>YesNoEnum::YES])->count();
if ($count ==1 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { if ($count ==1 && $user_ship>0) {
//首充 //首充
$write = self::write($order, $total_vip, 0, 1, 9); $write = self::write($order, $total_vip, 0, 1, 9);
self::write_log($write, $total_vip, 0, 7); self::write_log($write, $total_vip, 0, 7);

View File

@ -71,7 +71,7 @@ class UserProductStorageLogic extends BaseLogic
if($price){ if($price){
$price=bcmul($price,$v['nums'],2); $price=bcmul($price,$v['nums'],2);
$rate=bcdiv($price,100,2); $rate=bcdiv($price,100,2);
$order_id= StoreOrder::where('id',$cart_info['oid'])->value('order_id'); $order_id= StoreOrder::where('id',$find['oid'])->value('order_id');
UserSignLogic::storage($order_id,$rate); UserSignLogic::storage($order_id,$rate);
} }

View File

@ -0,0 +1,29 @@
<?php
namespace app\store\controller\user_product_storage_log;
use app\admin\lists\user_product_storage_log\UserProductStorageLogLists;
use app\store\controller\BaseAdminController;
/**
* 用户商品储存控制器
* Class UserProductStorageLogController
* @package app\admin\controller\user_product_storage
*/
class UserProductStorageLogController extends BaseAdminController
{
/**
* @notes 获取用户商品储存列表
* @return
* @author admin
* @date 2024/06/28 11:05
*/
public function lists()
{
return $this->dataLists(new UserProductStorageLogLists());
}
}

View File

@ -23,6 +23,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
protected $total_price = 0; protected $total_price = 0;
protected $activity_price = 0; protected $activity_price = 0;
protected $off_activity = 0; protected $off_activity = 0;
protected $pay_price = 0;
/** /**
* @notes 设置搜索条件 * @notes 设置搜索条件
* @return \string[][] * @return \string[][]
@ -42,7 +43,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
*/ */
public function lists($where = []): array public function lists($where = []): array
{ {
$userId = $this->request->get('uid');
$where = [ $where = [
'staff_id' => $this->adminId, 'staff_id' => $this->adminId,
'is_pay' => 0 'is_pay' => 0
@ -55,24 +55,35 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
return $item; return $item;
}) })
->toArray(); ->toArray();
// $off_activity = Config::where('name', 'off_activity')->value('value'); $off_activity = Config::where('name', 'off_activity')->value('value');
$off_activity = 0; $off_activity = 0;
$this->off_activity = $off_activity; $this->off_activity = $off_activity;
$uid = 0;
if ($this->request->get('uid')) {
$uid = $this->request->get('uid');
}
if ($uid > 0) {
$user_ship = User::where('id', $uid)->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')
->withTrashed() ->withTrashed()
->find(); ->find();
if ($find) { if ($find) {
if($off_activity==1){ if ($off_activity == 1) {
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2); $this->activity_price = bcadd(bcmul($find['cost'], $item['cart_num'], 2), $this->activity_price, 2);
$item['price'] = $find['cost']; $item['price'] = $find['cost'];
}else{ } else {
$item['price'] = $find['price']; $item['price'] = $find['price'];
} }
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $item['pay_price'] = bcmul($item['cart_num'], $item['price'], 2);
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); $item['total_price'] = bcmul($item['cart_num'], $find['price'], 2);
$this->total_price = bcadd($this->total_price, $item['total_price'], 2);
$this->pay_price = bcadd($this->pay_price, $item['pay_price'], 2);
$item['image'] = $find['image']; $item['image'] = $find['image'];
$item['cost'] = $find['cost']; $item['cost'] = $find['cost'];
$item['store_name'] = $find['store_name']; $item['store_name'] = $find['store_name'];
@ -105,7 +116,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
'off_activity' => $this->off_activity, 'off_activity' => $this->off_activity,
'total_price' => $this->total_price, 'total_price' => $this->total_price,
'msg' => '', 'msg' => '',
'pay_price' => $this->total_price 'pay_price' => $this->pay_price
]; ];
if ($this->off_activity == 1) { if ($this->off_activity == 1) {
$data['pay_price'] = $this->activity_price; $data['pay_price'] = $this->activity_price;

View File

@ -28,7 +28,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
public function setSearch(): array public function setSearch(): array
{ {
return [ return [
'=' => ['pay_type', 'paid'], '=' => ['pay_type', 'paid','reservation'],
'%like%' => ['order_id'], '%like%' => ['order_id'],
'between_time' => 'create_time', 'between_time' => 'create_time',
]; ];
@ -71,7 +71,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
} }
return StoreOrder::where($this->searchWhere)->with(['user']) return StoreOrder::where($this->searchWhere)->with(['user'])
->field(['id', 'order_id', 'pay_price', 'pay_time','uid', 'pay_type', 'status', 'paid', 'total_num']) ->field(['id', 'order_id', 'pay_price', 'pay_time','uid', 'pay_type',
'status', 'paid', 'total_num','reservation','reservation_time'])
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select()->each(function ($item){ ->select()->each(function ($item){