commit
af23ac1b44
@ -14,6 +14,7 @@
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\admin\lists\config\ConfigLists;
|
||||
use app\admin\logic\auth\AuthLogic;
|
||||
use app\admin\logic\ConfigLogic;
|
||||
use think\facade\Db;
|
||||
|
95
app/admin/controller/config/ConfigController.php
Normal file
95
app/admin/controller/config/ConfigController.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller\config;
|
||||
|
||||
|
||||
use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\config\ConfigLists;
|
||||
use app\admin\logic\ConfigLogic;
|
||||
use app\admin\validate\config\ConfigValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 配置表控制器
|
||||
* Class ConfigController
|
||||
* @package app\admin\controller\config
|
||||
*/
|
||||
class ConfigController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置表列表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new ConfigLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加配置表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new ConfigValidate())->post()->goCheck('add');
|
||||
$result = ConfigLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ConfigLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑配置表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new ConfigValidate())->post()->goCheck('edit');
|
||||
$result = ConfigLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(ConfigLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除配置表
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new ConfigValidate())->post()->goCheck('delete');
|
||||
ConfigLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置表详情
|
||||
* @return \think\response\Json
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new ConfigValidate())->goCheck('detail');
|
||||
$result = ConfigLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -122,12 +122,12 @@ class StoreOrderController extends BaseAdminController
|
||||
$refund = (new \app\common\logic\store_order\StoreOrderLogic())
|
||||
->refund($params['order_id'],$money,$money);
|
||||
if($refund){
|
||||
$arr = [
|
||||
'amount'=>[
|
||||
'refund'=>$money
|
||||
]
|
||||
];
|
||||
PayNotifyLogic::refund($params['order_id'],$arr);
|
||||
// $arr = [
|
||||
// 'amount'=>[
|
||||
// 'refund'=>$money
|
||||
// ]
|
||||
// ];
|
||||
// PayNotifyLogic::refund($params['order_id'],$arr);
|
||||
return $this->success();
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ class StoreOrderController extends BaseAdminController
|
||||
PayNotifyLogic::cash_refund($params['order_id']);
|
||||
return $this->success();
|
||||
}
|
||||
//支付包支付
|
||||
//todo 支付包支付
|
||||
|
||||
return $this->fail('退款失败');
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ use app\admin\controller\BaseAdminController;
|
||||
use app\admin\lists\user_recharge\UserRechargeLists;
|
||||
use app\admin\logic\user_recharge\UserRechargeLogic;
|
||||
use app\admin\validate\user_recharge\UserRechargeValidate;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\user\UserRecharge;
|
||||
|
||||
|
||||
/**
|
||||
@ -91,5 +93,33 @@ class UserRechargeController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
public function refund()
|
||||
{
|
||||
$params = (new UserRechargeValidate())->post()->goCheck('refund');
|
||||
$detail = UserRecharge::where('id',$params['id'])->findOrEmpty();
|
||||
if(empty($detail)){
|
||||
return $this->fail('无该充值订单请检查');
|
||||
}
|
||||
//现金
|
||||
if($detail['recharge_type'] =='CASH_PAY'){
|
||||
PayNotifyLogic::recharge_cash_refund($params['id']);
|
||||
return $this->success();
|
||||
}
|
||||
//微信
|
||||
if($detail['recharge_type'] == 'INDUSTRYMEMBERS'){
|
||||
$money = (int)bcmul($detail['price'],100);
|
||||
(new \app\common\logic\store_order\StoreOrderLogic())
|
||||
->refund($detail['order_id'],$money,$money);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
//支付宝
|
||||
if($detail['recharge_type'] == 'ALI_INDUSTRYMEMBERS'){
|
||||
|
||||
}
|
||||
|
||||
return $this->success();
|
||||
|
||||
}
|
||||
|
||||
}
|
64
app/admin/lists/config/ConfigLists.php
Normal file
64
app/admin/lists/config/ConfigLists.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\lists\config;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\app_update\AppUpdate;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\Config;
|
||||
|
||||
/**
|
||||
* 配置列表
|
||||
* Class ConfigLists
|
||||
* @package app\admin\lists\config
|
||||
*/
|
||||
class ConfigLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2024/05/30 10:25
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['name', 'type'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2024/05/30 10:25
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Config::where($this->searchWhere)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2024/05/30 10:25
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return AppUpdate::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -61,8 +61,8 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
||||
//2或者1
|
||||
$where[]=['cate_id','=',$class_all];
|
||||
}
|
||||
|
||||
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||
$this->searchWhere[]=$where;
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost','purchase', 'status','batch','vip_price','manufacturer_information'])
|
||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->adminInfo['store_id']);
|
||||
@ -99,17 +99,7 @@ class StoreBranchProductLists extends BaseAdminDataLists implements ListsSearchI
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$status = $this->params['status'] ?? '';
|
||||
$class_all=$this->request->get('class_all');
|
||||
$where=[];
|
||||
if($class_all){
|
||||
$arr=Cate::where('pid',$class_all)->column('id');
|
||||
if($arr){
|
||||
$arr2=Cate::where('pid','in',$arr)->column('id');
|
||||
$where[]=['cate_id','in',array_merge($arr,$arr2)];
|
||||
}
|
||||
}
|
||||
return StoreBranchProduct::where($this->searchWhere)->where($where)
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->when(!empty($this->adminInfo['store_id']), function ($query) {
|
||||
$query->where('store_id', $this->adminInfo['store_id']);
|
||||
})
|
||||
|
@ -81,57 +81,57 @@ class StoreFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInt
|
||||
$item['pay_type_name'] = PayEnum::getPaySceneDesc($item['pay_type']);
|
||||
})->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');
|
||||
// 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;
|
||||
}
|
||||
// // 对 financial_pm 数组进行排序,这将影响原始数组
|
||||
// array_multisort($financial_pm, SORT_ASC, $list3);
|
||||
// $data[$key]['list']=$list3;
|
||||
// }
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -69,10 +69,10 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
}
|
||||
$product = StoreOrderCartInfo::where('oid', $item['id'])->field(['id', 'oid', 'product_id', 'cart_info'])
|
||||
->limit(3)->select();
|
||||
foreach ($product as &$items) {
|
||||
$items['store_name'] = $items['cart_info']['name'];
|
||||
$items['image'] = $items['cart_info']['image'];
|
||||
}
|
||||
foreach ($product as &$items) {
|
||||
$items['store_name'] = $items['cart_info']['name'];
|
||||
$items['image'] = $items['cart_info']['image'];
|
||||
}
|
||||
$item['product'] = $product;
|
||||
return $item;
|
||||
})
|
||||
|
@ -4,6 +4,7 @@ namespace app\admin\lists\store_product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\store_category\StoreCategory;
|
||||
@ -45,6 +46,17 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
*/
|
||||
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];
|
||||
}
|
||||
}
|
||||
return StoreProduct::where($this->searchWhere)
|
||||
->field(['id', 'image', 'store_name','swap', 'cate_id','batch', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code','manufacturer_information'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
|
@ -44,7 +44,7 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
public function lists(): array
|
||||
{
|
||||
return UserRecharge::where($this->searchWhere)
|
||||
->field(['id', 'uid', 'order_id', 'price', 'recharge_type', 'paid', 'pay_time'])
|
||||
->field(['id', 'uid', 'order_id', 'price', 'recharge_type', 'paid', 'pay_time','status','refund_time'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
@ -54,11 +54,19 @@ class UserRechargeLists extends BaseAdminDataLists implements ListsSearchInterfa
|
||||
}else{
|
||||
$item['pay_time']='';
|
||||
}
|
||||
if($item['refund_time']>0){
|
||||
$item['refund_time']=date('Y-m-d H:i:s',$item['refund_time']);
|
||||
}else{
|
||||
$item['refund_time']='';
|
||||
}
|
||||
if($item['paid']==1){
|
||||
$item['paid_name']='已充值';
|
||||
}else{
|
||||
$item['paid_name']='未充值';
|
||||
}
|
||||
if($item['status']== -1){
|
||||
$item['paid_name']='已退款';
|
||||
}
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
|
@ -14,17 +14,97 @@
|
||||
|
||||
namespace app\admin\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\service\{FileService, ConfigService};
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 配置类逻辑层
|
||||
* Class ConfigLogic
|
||||
* @package app\admin\logic
|
||||
*/
|
||||
class ConfigLogic
|
||||
class ConfigLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 添加配置表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
Config::create([
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑配置表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
Config::where('id', $params['id'])->update([
|
||||
'type' => $params['type'],
|
||||
'name' => $params['name'],
|
||||
'value' => $params['value']
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除配置表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return Config::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取配置表详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return Config::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
/**
|
||||
* @notes 获取配置
|
||||
* @return array
|
||||
@ -68,7 +148,7 @@ class ConfigLogic
|
||||
if (!is_string($type)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
$type = explode(',', $type);
|
||||
$lists = DictData::whereIn('type_value', $type)->select()->toArray();
|
||||
|
||||
@ -86,7 +166,4 @@ class ConfigLogic
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ class StoreProductLogic extends BaseLogic
|
||||
$data = [
|
||||
'store_name' => $params['store_name'],
|
||||
'image' => $params['image'],
|
||||
'store_info' => $params['store_info'] ?? '',
|
||||
'bar_code' => $params['bar_code'] ?? '',
|
||||
'cate_id' => $params['cate_id'],
|
||||
'unit' => $params['unit'],
|
||||
@ -52,6 +53,7 @@ class StoreProductLogic extends BaseLogic
|
||||
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||
'swap' => $params['swap'] ?? 0,
|
||||
'batch' => $params['batch'] ?? 0,
|
||||
'product_type' => $params['product_type'] ?? 0,
|
||||
];
|
||||
// if ($params['rose'] > 0) {
|
||||
// $rose_price = bcmul($params['cost'], $params['rose'], 2);
|
||||
@ -140,6 +142,7 @@ class StoreProductLogic extends BaseLogic
|
||||
'store_name' => $params['store_name'],
|
||||
'image' => $params['image'],
|
||||
'bar_code' => $params['bar_code'] ?? '',
|
||||
'store_info' => $params['store_info'] ?? '',
|
||||
'cate_id' => $params['cate_id'],
|
||||
'unit' => $params['unit'],
|
||||
'stock' => $params['stock'],
|
||||
@ -152,7 +155,6 @@ class StoreProductLogic extends BaseLogic
|
||||
'batch' => $params['batch'],
|
||||
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||
'swap' => $params['swap'] ?? 0,
|
||||
|
||||
];
|
||||
|
||||
StoreProduct::where('id', $params['id'])->update($data);
|
||||
@ -181,6 +183,7 @@ class StoreProductLogic extends BaseLogic
|
||||
'cost' => $params['cost'],'unit'=>$params['unit'],
|
||||
'batch'=>$params['batch'],'store_name'=>$params['store_name'],
|
||||
'manufacturer_information' => $params['manufacturer_information']??'',
|
||||
'store_info' => $params['store_info']??'',
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
|
@ -80,7 +80,6 @@ class UserLogic extends BaseLogic
|
||||
$password = create_password(123456, $passwordSalt);
|
||||
$defaultAvatar = config('project.default_image.admin_avatar');
|
||||
$avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar;
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data=[
|
||||
@ -104,13 +103,13 @@ class UserLogic extends BaseLogic
|
||||
UserAddress::create([
|
||||
'uid' => $res['id'],
|
||||
'real_name' => $params['real_name']??"",
|
||||
'mobile' => $params['mobile'],
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'area' => $params['area'],
|
||||
'street' => $params['street'],
|
||||
'village' => $params['village'],
|
||||
'brigade' => $params['brigade'],
|
||||
'mobile' => $params['mobile']??'',
|
||||
'province' => $params['province']??'',
|
||||
'city' => $params['city']??'',
|
||||
'area' => $params['area']??'',
|
||||
'street' => $params['street']??'',
|
||||
'village' => $params['village']??'',
|
||||
'brigade' => $params['brigade']??'',
|
||||
'is_default' => 1,
|
||||
]);
|
||||
Db::commit();
|
||||
|
86
app/admin/validate/config/ConfigValidate.php
Normal file
86
app/admin/validate/config/ConfigValidate.php
Normal file
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\config;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 配置表验证器
|
||||
* Class ConfigValidate
|
||||
* @package app\admin\validate\config
|
||||
*/
|
||||
class ConfigValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'name' => 'require',
|
||||
'value' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'name' => '名称',
|
||||
'value' => '值',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return ConfigValidate
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['name','value']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return ConfigValidate
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','name','value']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return ConfigValidate
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return ConfigValidate
|
||||
* @author admin
|
||||
* @date 2024/06/24 17:52
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -35,6 +35,7 @@ class UserValidate extends BaseValidate
|
||||
'brigade' => 'require',
|
||||
'user_ship' => 'require',
|
||||
'type' => 'require|number',
|
||||
'code' => 'require|number',
|
||||
];
|
||||
|
||||
|
||||
@ -59,8 +60,8 @@ class UserValidate extends BaseValidate
|
||||
'brigade' => ' 队',
|
||||
'user_ship' => ' 会员类型',
|
||||
'type' => '查询类型',
|
||||
'code' => '验证码',
|
||||
];
|
||||
|
||||
public function sceneFund()
|
||||
{
|
||||
return $this->only(['type','id']);
|
||||
|
@ -32,6 +32,12 @@ class UserRechargeValidate extends BaseValidate
|
||||
];
|
||||
|
||||
|
||||
public function sceneRefund()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return UserRechargeValidate
|
||||
|
@ -10,8 +10,12 @@ use app\common\model\Config as ModelConfig;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\service\pay\PayService;
|
||||
use app\common\service\PushService;
|
||||
use app\common\service\wechat\WechatTemplate;
|
||||
use app\statistics\logic\OrderLogic;
|
||||
use Exception;
|
||||
use Overtrue\EasySms\EasySms;
|
||||
use Overtrue\EasySms\Exceptions\NoGatewayAvailableException;
|
||||
use support\Cache;
|
||||
use think\facade\Db;
|
||||
use Webman\Config;
|
||||
@ -28,18 +32,60 @@ class IndexController extends BaseApiController
|
||||
|
||||
public function index()
|
||||
{
|
||||
$order = [
|
||||
'out_trade_no' => 'CZ1719197818549414',
|
||||
$config = [
|
||||
// HTTP 请求的超时时间(秒)
|
||||
'timeout' => 5.0,
|
||||
|
||||
// 默认发送配置
|
||||
'default' => [
|
||||
// 网关调用策略,默认:顺序调用
|
||||
'strategy' => \Overtrue\EasySms\Strategies\OrderStrategy::class,
|
||||
|
||||
// 默认可用的发送网关
|
||||
'gateways' => [
|
||||
'yunpian', 'aliyun',
|
||||
],
|
||||
],
|
||||
// 可用的网关配置
|
||||
'gateways' => [
|
||||
'errorlog' => [
|
||||
'file' => runtime_path() . '/logs/' . date('Ymd') . '/easy-sms.log',
|
||||
],
|
||||
'aliyun' => [
|
||||
'access_key_id' => 'LTAI5t7mhH3ij2cNWs1zhPmv',
|
||||
'access_key_secret' => 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu',
|
||||
'sign_name' => '里海科技',
|
||||
],
|
||||
//...
|
||||
],
|
||||
];
|
||||
$app = new PayService(0);
|
||||
|
||||
try {
|
||||
$res = $app->wechat->query($order);
|
||||
} catch (\Exception $e) {
|
||||
return $this->fail($e->extra['message']);
|
||||
$easySms = new EasySms($config);
|
||||
$template = getenv('SMS_TEMPLATE');
|
||||
$a = $easySms->send(18715753257, [
|
||||
'content' => '您的验证码为: 6379',
|
||||
'template' => $template,
|
||||
'data' => [
|
||||
'code' => 6379
|
||||
],
|
||||
]);
|
||||
// d($a);
|
||||
}catch (NoGatewayAvailableException $exception){
|
||||
throw new \Exception($exception->getExceptions());
|
||||
}
|
||||
d($res);
|
||||
|
||||
d($a,getenv('SMS_TEMPLATE'));
|
||||
|
||||
|
||||
|
||||
|
||||
$all_where['paid'] = 1;
|
||||
d(OrderLogic::dayPayPrice($all_where,date('Y-m-d',time())));
|
||||
$uid=9;
|
||||
$a= PushService::push('wechat_mmp_'.$uid, $uid, ['type'=>'INDUSTRYMEMBERS','msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>5]]);
|
||||
|
||||
return json($a);
|
||||
|
||||
|
||||
|
||||
|
@ -47,6 +47,7 @@ class PayController extends BaseApiController
|
||||
} else {
|
||||
if ($result && $result->event_type == 'REFUND.SUCCESS') {
|
||||
$ciphertext = $result->resource['ciphertext'];
|
||||
Cache::set('6logC'.time(),json_encode($ciphertext));
|
||||
if ($ciphertext['refund_status'] === 'SUCCESS') {
|
||||
//处理订单 -1判断是退的一单还是拆分的订单
|
||||
$out_trade_no = $ciphertext['out_trade_no'] . '-1';
|
||||
|
@ -12,9 +12,11 @@ use app\api\validate\UserValidate;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\PaymentLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user_create_log\UserCreateLog;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use support\Cache;
|
||||
use Webman\RedisQueue\Redis;
|
||||
|
||||
class StoreController extends BaseApiController
|
||||
@ -47,10 +49,9 @@ class StoreController extends BaseApiController
|
||||
if($store_id){
|
||||
$where['id'] = $store_id;
|
||||
}
|
||||
|
||||
$info = StoreLogic::search($where);
|
||||
if ($info) {
|
||||
return $this->success('ok',$info??[]);
|
||||
return $this->success('ok',$info);
|
||||
} else {
|
||||
return $this->fail('店铺不存在');
|
||||
}
|
||||
@ -64,6 +65,18 @@ class StoreController extends BaseApiController
|
||||
$params = (new UserValidate())->post()->goCheck('rechargeStoreMoney');
|
||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$recharge_type = $this->request->post('recharge_type',''); //微信支付条码
|
||||
$code = $this->request->post('code','');//验证码
|
||||
$phone = $params['mobile'];
|
||||
if($code && $phone){
|
||||
$remark = $phone.'_reporting';
|
||||
$codeCache = Cache::get($remark);
|
||||
if(empty($codeCache)){
|
||||
return $this->fail('验证码不存在');
|
||||
}
|
||||
if ($codeCache != $code) {
|
||||
return $this->fail('验证码错误');
|
||||
}
|
||||
}
|
||||
$find=User::where('mobile',$params['mobile'])->find();
|
||||
if(!$find){
|
||||
$params['create_uid']=$this->userId;
|
||||
@ -72,15 +85,19 @@ class StoreController extends BaseApiController
|
||||
$find['real_name']=$params['real_name'];
|
||||
$find->save();
|
||||
}
|
||||
if($find === false){
|
||||
return $this->fail(UserUserLogic::getError());
|
||||
}
|
||||
if($recharge_type!='INDUSTRYMEMBERS'){
|
||||
return $this->success('添加用户成功');
|
||||
}
|
||||
$data=[
|
||||
'store_id'=>$params['store_id'],
|
||||
'uid'=>$find['id'],
|
||||
'other_uid'=>$this->userId,
|
||||
'staff_id'=>0,
|
||||
'order_id'=>getNewOrderId('CZ'),
|
||||
'price'=>1000,
|
||||
'price'=>Config::where('name','recharge')->value('value')??1000,
|
||||
'recharge_type'=>'INDUSTRYMEMBERS',
|
||||
];
|
||||
$order = UserRecharge::create($data);
|
||||
@ -99,6 +116,35 @@ class StoreController extends BaseApiController
|
||||
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重新充值会员
|
||||
*/
|
||||
public function again_recharge()
|
||||
{
|
||||
$auth_code = $this->request->post('auth_code'); //微信支付条码
|
||||
$id = $this->request->post('id',0); //id
|
||||
$order = UserRecharge::where('id', $id)->where('paid',0)->find();
|
||||
if(!$order){
|
||||
return $this->fail('订单不存在');
|
||||
}
|
||||
$order_id=getNewOrderId('CZ');
|
||||
UserRecharge::where('id', $id)->update(['order_id'=>$order_id]);
|
||||
$order['order_id']=$order_id;
|
||||
$order['pay_price']=$order['price'];
|
||||
$result = PaymentLogic::codepay($auth_code, $order,'条码支付');
|
||||
if (PaymentLogic::hasError()) {
|
||||
return $this->fail(PaymentLogic::getError());
|
||||
}
|
||||
if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') {
|
||||
PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result);
|
||||
} else {
|
||||
Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']);
|
||||
return $this->success('用户支付中');
|
||||
}
|
||||
return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 门店会员充值数量
|
||||
*/
|
||||
|
@ -4,9 +4,12 @@ namespace app\api\controller\user;
|
||||
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\api\logic\user\UserLogic;
|
||||
use app\api\service\UserTokenService;
|
||||
use app\api\validate\UserValidate;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\PaymentLogic;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user_sign\UserSign;
|
||||
use support\Cache;
|
||||
use think\Exception;
|
||||
|
||||
@ -36,7 +39,14 @@ class UserController extends BaseApiController
|
||||
if ($result === false) {
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
$data = UserLogic::info($this->userId);
|
||||
if($result && is_numeric($result)){
|
||||
$data = UserLogic::info($result);
|
||||
$userInfo = UserTokenService::setToken($result, 1);
|
||||
$data['token'] = $userInfo['token'];
|
||||
}else{
|
||||
$data = UserLogic::info($this->userId);
|
||||
}
|
||||
|
||||
return $this->success('绑定成功', $data, 1, 1);
|
||||
}
|
||||
|
||||
@ -145,6 +155,7 @@ class UserController extends BaseApiController
|
||||
return $this->fail('发送失败');
|
||||
}
|
||||
|
||||
//登录
|
||||
public function login_sms()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('login');
|
||||
@ -155,6 +166,18 @@ class UserController extends BaseApiController
|
||||
return $this->fail('发送失败');
|
||||
|
||||
}
|
||||
|
||||
//报备
|
||||
public function reporting_sms()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('login');
|
||||
$res = (new UserLogic())->dealReportingSms($params['account']);
|
||||
if ($res){
|
||||
return $this->success('发送成功',[],1,1);
|
||||
}
|
||||
return $this->fail('发送失败');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -164,7 +187,7 @@ class UserController extends BaseApiController
|
||||
$remark = $this->userId.'_payPassword';
|
||||
$code = Cache::get($remark);
|
||||
if ($code && isset($params['code']) && $code !== $params['code']) {
|
||||
throw new Exception('验证码错误');
|
||||
return $this->fail('验证码错误');
|
||||
}
|
||||
if ($params['rePassword'] !== $params['password'])
|
||||
return $this->fail('两次密码不一致');
|
||||
@ -207,8 +230,16 @@ class UserController extends BaseApiController
|
||||
$params['page_no'] = $page_no > 0 ? $page_no : 1;
|
||||
$params['page_size'] = $page_size > 0 ? $page_size : 15;
|
||||
$res = UserLogic::dealDetails($params,$this->userId);
|
||||
$integral = User::where('id',$this->userId)->value('integral');
|
||||
$number = UserSign::where('id',$this->userId)->where('status',0)->sum('number');
|
||||
$GetNumber = UserSign::where('id',$this->userId)->where('status',1)->sum('number');
|
||||
$res['page_no'] = $params['page_no'];
|
||||
$res['page_size'] = $params['page_size'];
|
||||
$res['extend'] = [
|
||||
'integral'=>$integral,
|
||||
'number'=>$number,
|
||||
'get_number'=>$GetNumber
|
||||
];
|
||||
return $this->success('ok', $res);
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||
@ -23,6 +24,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
|
||||
protected $total_price = 0;
|
||||
protected $activity_price = 0;
|
||||
protected $off_activity = 0;
|
||||
|
||||
|
||||
/**
|
||||
@ -60,31 +62,23 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
// $check = DictType::where('type', 'activities')->find();
|
||||
$user = User::where('id', $userId)->find();
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$this->off_activity=$off_activity;
|
||||
foreach ($list as $key => &$item) {
|
||||
|
||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']])
|
||||
->field('product_id,image,cost price,cost,store_name,unit,delete_time,vip_price')
|
||||
$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')
|
||||
->withTrashed()
|
||||
->find();
|
||||
|
||||
if ($find) {
|
||||
// if ($user && $user['user_ship'] == 1) {
|
||||
// //更新 会员为1的时候原价减去会员价
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2);
|
||||
// $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2);
|
||||
// }elseif ($user && $user['user_ship'] == 4) {
|
||||
// //更新 为4商户的时候减去商户价格
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2);
|
||||
// $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2);
|
||||
// }else{
|
||||
// $this->activity_price =0;
|
||||
// }
|
||||
if($off_activity==1){
|
||||
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2);
|
||||
}
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
$item['imgs'] = $find['image'];
|
||||
$item['sell'] = $find['price'];
|
||||
$item['price'] = $find['price'];
|
||||
$item['cost'] = $find['cost'];
|
||||
$item['goods_name'] = $find['store_name'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
}
|
||||
@ -111,10 +105,19 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
|
||||
public function extend()
|
||||
{
|
||||
return [
|
||||
$data= [
|
||||
'off_activity' => $this->off_activity,
|
||||
'total_price' => $this->total_price,
|
||||
'activity_price' => $this->activity_price,
|
||||
'pay_price'=> bcsub($this->total_price, $this->activity_price, 2)
|
||||
'msg' => '',
|
||||
'pay_price' => $this->total_price
|
||||
];
|
||||
if($this->off_activity==1){
|
||||
$data['pay_price']=$this->activity_price;
|
||||
if($this->activity_price<500){
|
||||
$data['msg']='还差'.bcsub(500,$this->activity_price,2).'元可获得10%品牌礼品券';
|
||||
$data['pay_price']= $this->activity_price;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -46,18 +46,20 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
$userId = $this->request->userId;
|
||||
if (!$userId) return [];
|
||||
$data = StoreOrder::with(['store'])->where($this->searchWhere)->where('uid', $userId)
|
||||
$data = StoreOrder::with(['store'])->where($this->searchWhere)->where(['uid'=>$userId])
|
||||
->whereIn('shipping_type',[1,2])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
|
||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select()
|
||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select()
|
||||
->each(function ($v) use ($item) {
|
||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
|
||||
$v['store_name'] = $find['store_name'];
|
||||
$v['image'] = $find['image'];
|
||||
$v['price'] = $find['price'];
|
||||
// $v['price'] = $find['price'];
|
||||
$v['price'] = $v['cart_info']['price'];
|
||||
$v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
});
|
||||
$item['goods_count'] = count(explode(',', $item['cart_id']));
|
||||
@ -85,6 +87,6 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function count(): int
|
||||
{
|
||||
$userId = $this->request->userId;
|
||||
return StoreOrder::where($this->searchWhere)->where('uid', $userId)->count();
|
||||
return StoreOrder::where($this->searchWhere)->whereIn('shipping_type',[1,2])->where('uid', $userId)->count();
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ namespace app\api\lists\product;
|
||||
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\lists\ListsSortInterface;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\cate\Cate;
|
||||
use app\common\model\Config;
|
||||
//use app\common\model\goods\GoodsLabel;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -18,7 +20,7 @@ use think\facade\Db;
|
||||
* Class goods
|
||||
* @package app\api\goods
|
||||
*/
|
||||
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
|
||||
class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface, ListsExtendInterface
|
||||
{
|
||||
|
||||
|
||||
@ -34,6 +36,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
'=' => ['store_id', 'cate_id'],
|
||||
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
|
||||
];
|
||||
return [
|
||||
'=' => ['store_id', 'cate_id'],
|
||||
'%pipe_like%' => ['store_name' => 'store_name|bar_code'],
|
||||
];
|
||||
}
|
||||
/**
|
||||
* @notes 设置支持排序字段
|
||||
@ -54,7 +60,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
*/
|
||||
public function setDefaultOrder(): array
|
||||
{
|
||||
return [ 'price' => 'asc','id' => 'desc'];
|
||||
return ['price' => 'asc', 'id' => 'desc'];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,21 +81,28 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
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];
|
||||
} 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;
|
||||
}else{
|
||||
$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';
|
||||
|
||||
$this->searchWhere[] = ['status', '=', 1];
|
||||
$this->searchWhere[] = ['stock', '>', 0];
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'cost price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch'])
|
||||
->field($fields)
|
||||
->with(['className', 'unitName'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order($this->sortOrder)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
->order($order)
|
||||
// ->page($this->limitOffset +1,$this->limitLength)
|
||||
->select()->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -104,4 +117,22 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L
|
||||
return StoreBranchProduct::where($this->searchWhere)
|
||||
->count();
|
||||
}
|
||||
public function extend()
|
||||
{
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
if($off_activity==1){
|
||||
$data=[
|
||||
'off_activity' => $off_activity,
|
||||
'price' => 'cost',
|
||||
'op_price' => 'price',
|
||||
];
|
||||
}else{
|
||||
$data=[
|
||||
'off_activity' => $off_activity,
|
||||
'price' => 'price',
|
||||
'op_price' => 'price',
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CapitalFlowLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\logic\StoreFinanceFlowLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\order\Cart;
|
||||
@ -24,6 +25,7 @@ use app\common\model\system_store\SystemStoreStaff;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\model\user\UserShip;
|
||||
use app\common\model\user_sign\UserSign;
|
||||
use app\common\model\user_spread_log\UserSpreadLog;
|
||||
use Picqer\Barcode\BarcodeGeneratorJPG;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
@ -72,46 +74,38 @@ class OrderLogic extends BaseLogic
|
||||
self::$activity_price = 0; //活动减少
|
||||
self::$store_price = 0; //门店零售价
|
||||
/** 计算价格 */
|
||||
|
||||
$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';
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id')->withTrashed()->find();
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
unset($cart_select[$k]['id']);
|
||||
|
||||
$cart_select[$k]['price'] = $find['price'];
|
||||
if($off_activity==1){
|
||||
$price=$find['cost'];
|
||||
}else{
|
||||
$price=$find['price'];
|
||||
}
|
||||
$cart_select[$k]['price'] = $price;
|
||||
$cart_select[$k]['cost'] = $find['cost'];
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
$cart_select[$k]['vip'] = 0;
|
||||
// if ($user && $user['user_ship'] == 1) {
|
||||
// //更新 会员为1的时候原价减去会员价
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// $cart_select[$k]['vip'] =1;
|
||||
// }
|
||||
// if ($user && $user['user_ship'] == 4) {
|
||||
// //更新 为4商户的时候减去商户价格
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// }
|
||||
|
||||
//利润
|
||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['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]['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售价
|
||||
|
||||
$cart_select[$k]['product_id'] = $find['product_id'];
|
||||
$cart_select[$k]['old_cart_id'] = $v['id'];
|
||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
|
||||
//vip1待返回金额
|
||||
$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'] );
|
||||
$cartInfo = $cart_select[$k];
|
||||
$cartInfo['name'] = $find['store_name'];
|
||||
@ -147,7 +141,6 @@ class OrderLogic extends BaseLogic
|
||||
'order_id' => $params['order_id'] ?? getNewOrderId('PF'),
|
||||
'total_price' => self::$total_price, //总价
|
||||
'cost' => self::$cost, //成本价1-
|
||||
'profit' =>0, //利润
|
||||
'pay_price' => $pay_price, //后期可能有降价抵扣
|
||||
'vip_price' => 0,
|
||||
'total_num' => count($cart_select), //总数
|
||||
@ -161,6 +154,7 @@ class OrderLogic extends BaseLogic
|
||||
'activities' => self::$activity_price>0?1:0,
|
||||
'deduction_price' => self::$activity_price,
|
||||
'is_vip' => 0,
|
||||
'is_storage' => $params['is_storage']??0,
|
||||
];
|
||||
$order['default_delivery'] = 0;
|
||||
if ($params['store_id']) {
|
||||
@ -192,11 +186,12 @@ class OrderLogic extends BaseLogic
|
||||
if (!$orderInfo) {
|
||||
return false;
|
||||
}
|
||||
$uid=$user['id']??0;
|
||||
$_order = $orderInfo['order'];
|
||||
$_order['uid'] = $user['id'];
|
||||
$_order['uid'] = $uid;
|
||||
$_order['spread_uid'] =$params['spread_uid']??0;
|
||||
$_order['real_name'] = $user['real_name'];
|
||||
$_order['mobile'] = $user['mobile'];
|
||||
$_order['real_name'] = $user['real_name']??'';
|
||||
$_order['mobile'] = $user['mobile']??'';
|
||||
$_order['pay_type'] = $orderInfo['order']['pay_type'];
|
||||
$_order['verify_code'] = $verify_code;
|
||||
$_order['reservation_time'] = null;
|
||||
@ -204,8 +199,8 @@ class OrderLogic extends BaseLogic
|
||||
$_order['reservation_time'] = $params['reservation_time'];
|
||||
$_order['reservation'] = YesNoEnum::YES;
|
||||
}
|
||||
if ($addressId > 0) {
|
||||
$address = UserAddress::where(['id' => $addressId, 'uid' => $user['id']])->find();
|
||||
if ($addressId > 0 &&$uid>0 ) {
|
||||
$address = UserAddress::where(['id' => $addressId, 'uid' => $uid])->find();
|
||||
if ($address) {
|
||||
$_order['real_name'] = $address['real_name'];
|
||||
$_order['user_phone'] = $address['phone'];
|
||||
@ -228,7 +223,7 @@ class OrderLogic extends BaseLogic
|
||||
$goods_list = $orderInfo['cart_list'];
|
||||
foreach ($goods_list as $k => $v) {
|
||||
$goods_list[$k]['oid'] = $order->id;
|
||||
$goods_list[$k]['uid'] = $user['id'];
|
||||
$goods_list[$k]['uid'] = $uid;
|
||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
||||
$StoreBranchProduct = StoreBranchProduct::where('id',$v['branch_product_id'])->withTrashed()->find();
|
||||
@ -442,11 +437,17 @@ class OrderLogic extends BaseLogic
|
||||
$order=StoreOrder::where('id',$data['id'])->find();
|
||||
PayNotifyLogic::afterPay($order);
|
||||
PayNotifyLogic::descStock($order['id']);
|
||||
|
||||
if($order['uid'] && $order['total_price'] > 500){
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
|
||||
UserSign::where(['uid' => $order['uid'],'order_id' => $order['order_id']])->update(['status'=>1]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
d($e);
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
@ -12,15 +12,13 @@ class StoreLogic extends BaseLogic
|
||||
|
||||
public static function search($param)
|
||||
{
|
||||
return SystemStore::where($param)
|
||||
$data = SystemStore::where($param)
|
||||
->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show',
|
||||
'day_time', 'is_store', 'latitude', 'longitude', 'day_start', 'day_end', 'is_store'
|
||||
, 'is_send'
|
||||
])
|
||||
->find()
|
||||
->toArray();
|
||||
|
||||
|
||||
->find();
|
||||
return $data ? $data->toArray() : [];
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,8 +59,8 @@ class AddressLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$is_default = $params['is_default']??0;
|
||||
if($is_default){
|
||||
$is_default = $params['is_default'] ??0;
|
||||
if($is_default==1){
|
||||
UserAddress::where('uid',$params['uid'])->update(['is_default'=>0]);
|
||||
}
|
||||
$data = [
|
||||
@ -68,6 +68,8 @@ class AddressLogic extends BaseLogic
|
||||
'phone' => $params['phone'],
|
||||
'detail' => $params['detail']??'',
|
||||
'is_default' => $params['is_default']??0,
|
||||
'detail' => $params['detail']??'',
|
||||
'is_default' => $params['is_default']??0,
|
||||
'province' => $params['province'],
|
||||
'city' => $params['city'],
|
||||
'area' => $params['area'],
|
||||
@ -111,6 +113,7 @@ class AddressLogic extends BaseLogic
|
||||
return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
|
||||
public static function info($params): array
|
||||
{
|
||||
return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where($params)->findOrEmpty()->toArray();
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace app\api\logic\user;
|
||||
|
||||
|
||||
use app\api\service\UserTokenService;
|
||||
use app\common\{logic\BaseLogic,
|
||||
model\dict\DictData,
|
||||
model\finance\CapitalFlow,
|
||||
@ -53,8 +54,15 @@ class UserLogic extends BaseLogic
|
||||
['id', '<>', $params['user_id']]
|
||||
])->findOrEmpty();
|
||||
|
||||
|
||||
if (!$user->isEmpty()) {
|
||||
throw new \Exception('手机号已被其他账号绑定');
|
||||
//切换被绑定账号删除该账号并且以新的账号登录
|
||||
UserAuth::where('user_id',$params['user_id'])->update([
|
||||
'user_id'=>$user['id']
|
||||
]);
|
||||
User::destroy($params['user_id']);
|
||||
return $user['id'];
|
||||
// throw new \Exception('手机号已被其他账号绑定');
|
||||
}
|
||||
|
||||
// 绑定手机号
|
||||
@ -105,6 +113,12 @@ class UserLogic extends BaseLogic
|
||||
'is_writeoff'=>0,'uid'=>$uid
|
||||
])->whereIn('shipping_type',[1,2])->count();
|
||||
$data['openid'] = UserAuth::where(['user_id'=>$uid,'terminal'=>1])->value('openid');
|
||||
$number=UserSign::where('uid',$uid)->where('status',0)->sum('number');
|
||||
$data['integral']=bcadd($data['integral'],$number,2);
|
||||
$number = UserSign::where('uid',$uid)->where('status',0)->sum('number');
|
||||
$GetNumber = UserSign::where('uid',$uid)->where('status',1)->sum('number');
|
||||
$data['number'] =bcadd($number,0,2);
|
||||
$data['GetNumber'] =bcadd($GetNumber,0,2);
|
||||
}else{
|
||||
$data = [];
|
||||
}
|
||||
@ -209,6 +223,22 @@ class UserLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public function dealReportingSms($phone,$string = '_reporting')
|
||||
{
|
||||
$code = generateRandomCode();
|
||||
$template = getenv('SMS_LOGIN_TEMPLATE');
|
||||
$check =(new SmsService())->client($phone,$template,$code);
|
||||
if($check){
|
||||
$remark = $phone.$string;
|
||||
Cache::set($remark,$code,5*60);
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function dealPayPassword($params,$uid)
|
||||
@ -272,10 +302,10 @@ class UserLogic extends BaseLogic
|
||||
//礼品券明细
|
||||
$query = UserSign::where(['uid'=>$uid]);
|
||||
if($params['mark'] == 1){
|
||||
$query->where('financial_pm',1);
|
||||
$query->where('financial_pm',0);
|
||||
}
|
||||
if($params['mark'] == 2){
|
||||
$query->where('financial_pm',0);
|
||||
$query->where('financial_pm',1);
|
||||
}
|
||||
$count = $query->count();
|
||||
$data =$query
|
||||
@ -287,10 +317,10 @@ class UserLogic extends BaseLogic
|
||||
//返还金明细 -todo back
|
||||
$query = VipFlow::with('store')->where(['user_id'=>$uid]);
|
||||
if($params['mark'] == 1){
|
||||
$query->where('status',1);
|
||||
$query->where('status',0);
|
||||
}
|
||||
if($params['mark'] == 2){
|
||||
$query->where('status',0);
|
||||
$query->where('status',1);
|
||||
}
|
||||
$count = $query->count();
|
||||
$data = $query
|
||||
|
@ -4,6 +4,7 @@
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
@ -19,8 +20,8 @@ class UserValidate extends BaseValidate
|
||||
'store_id' => 'require',
|
||||
'mobile' => 'require',
|
||||
'phone' => 'require|number',
|
||||
'password' => 'require',
|
||||
'rePassword' => 'require',
|
||||
'password' => 'require|length:6',
|
||||
'rePassword' => 'require|requireWith:password|confirm:password',
|
||||
'type' => 'require',
|
||||
'account' => 'require',
|
||||
|
||||
@ -32,8 +33,8 @@ class UserValidate extends BaseValidate
|
||||
'mobile.require' => '手机',
|
||||
'phone.require' => '手机',
|
||||
'account.require' => '手机',
|
||||
'password.require' => '密码',
|
||||
'rePassword.require' => '确认密码',
|
||||
'password.require' => '密码缺失',
|
||||
'rePassword.require' => '确认密码缺失',
|
||||
'type' => '查询类型',
|
||||
];
|
||||
|
||||
|
@ -46,6 +46,7 @@ class OrderEnum
|
||||
const CASHIER_FACE_PAY = 17;//现金收银
|
||||
|
||||
const PURCHASE_FUNDS = 18;//采购款收银
|
||||
const PAY_BACK =-1;
|
||||
|
||||
|
||||
/**
|
||||
@ -183,10 +184,10 @@ class OrderEnum
|
||||
public static function getOrderType($value = true)
|
||||
{
|
||||
$data = [
|
||||
self::RECEIVED_GOODS => '已收货',
|
||||
self::RECEIVED_GOODS => '已完成',
|
||||
self::WAIT_EVALUATION => '待评价',
|
||||
self::WAIT_DELIVERY => '待发货',
|
||||
self::WAIT_RECEIVING => '待收货',
|
||||
self::WAIT_RECEIVING => '待核销',
|
||||
self::RETURN_SUCCESS => '退货成功',
|
||||
self::ALREADY_REFUND => '已退款',
|
||||
self::RECEIVED_BACK => '已退款',
|
||||
|
@ -22,23 +22,6 @@ trait ListsSearchTrait
|
||||
return [];
|
||||
}
|
||||
$where = [];
|
||||
$class_key = $this->request->__get('class_key');
|
||||
if ($class_key !== null) {
|
||||
foreach ($class_key as $key => $value) {
|
||||
if (isset($search[$key])) {
|
||||
foreach ($value as $v) { // 遍历class_key的值,添加到search数组中
|
||||
array_push($search[$key], $v); // 添加class_key的搜索条件
|
||||
}
|
||||
} else {
|
||||
$search[$key] = [$value[0]]; // 创建新的搜索条件
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$class_value = $this->request->__get('class_value'); // 获取class_value的值
|
||||
if ($class_value !== null) {
|
||||
$this->params = array_merge($this->params, $class_value);
|
||||
}
|
||||
foreach ($search as $whereType => $whereFields) {
|
||||
switch ($whereType) {
|
||||
case '=':
|
||||
|
195
app/common/logic/CommissionLogic.php
Normal file
195
app/common/logic/CommissionLogic.php
Normal file
@ -0,0 +1,195 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
|
||||
class CommissionLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* 走村长分润
|
||||
*/
|
||||
public static function setVillage($order, $transaction_id)
|
||||
{
|
||||
self::user($order, 0.05, $transaction_id,$order['uid'],14);
|
||||
$village_uid=0;
|
||||
$brigade_uid=0;
|
||||
if ($order['uid'] > 0) {
|
||||
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
|
||||
if ($address) {
|
||||
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
|
||||
if ($arr1) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
|
||||
if ($uid) {
|
||||
$village_uid = $uid;
|
||||
}
|
||||
}
|
||||
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
|
||||
if ($arr2) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
|
||||
if ($uid) {
|
||||
$brigade_uid = $uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self::user($order, 0.03, $transaction_id,$village_uid,12);//会员
|
||||
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
|
||||
self::user($order, 0.01, $transaction_id,0,16);//其他
|
||||
}
|
||||
/**
|
||||
* 走队长分润
|
||||
*/
|
||||
public static function setBrigade($order, $transaction_id)
|
||||
{
|
||||
self::user($order, 0.05, $transaction_id,$order['uid'],14);
|
||||
$village_uid=0;
|
||||
$brigade_uid=0;
|
||||
if ($order['uid'] > 0) {
|
||||
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
|
||||
if ($address) {
|
||||
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
|
||||
if ($arr1) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
|
||||
if ($uid) {
|
||||
$village_uid = $uid;
|
||||
}
|
||||
}
|
||||
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
|
||||
if ($arr2) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
|
||||
if ($uid) {
|
||||
$brigade_uid = $uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self::user($order, 0.03, $transaction_id,$village_uid,12);//会员
|
||||
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
|
||||
self::user($order, 0.01, $transaction_id,0,16);//其他
|
||||
}
|
||||
/**
|
||||
* 走厨师分润
|
||||
*/
|
||||
public static function setCook($order, $transaction_id)
|
||||
{
|
||||
self::user($order, 0.07, $transaction_id,$order['uid'],12);//改到带返还金中
|
||||
$village_uid=0;
|
||||
$brigade_uid=0;
|
||||
if ($order['uid'] > 0) {
|
||||
$address = UserAddress::where(['uid' => $order['uid'], 'is_default' => 1])->find();
|
||||
if ($address) {
|
||||
$arr1 = UserAddress::where(['village' => $address['village'], 'is_default' => 1])->column('uid');
|
||||
if ($arr1) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 2)->value('id');
|
||||
if ($uid) {
|
||||
$village_uid = $uid;
|
||||
}
|
||||
}
|
||||
$arr2 = UserAddress::where(['village' => $address['village'], 'brigade' => $address['brigade'], 'is_default' => 1])->column('uid');
|
||||
if ($arr2) {
|
||||
$uid = User::where('id', 'in', $arr1)->where('user_ship', 3)->value('id');
|
||||
if ($uid) {
|
||||
$brigade_uid = $uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
self::user($order, 0.01, $transaction_id,$village_uid,14);//村长
|
||||
self::user($order, 0.01, $transaction_id,$brigade_uid,15);//队长
|
||||
self::user($order, 0.01, $transaction_id,0,16);//其他
|
||||
}
|
||||
|
||||
/**
|
||||
* 走线下分润
|
||||
*/
|
||||
public static function setStore($order, $transaction_id)
|
||||
{
|
||||
self::platform($order, 0.05, $transaction_id);//平台
|
||||
self::store($order, 0.02, $transaction_id,0);//门店
|
||||
self::user($order, 0.01, $transaction_id,0,16);//其他
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 平台分润
|
||||
*/
|
||||
public static function platform($order, $platformRate, $transaction_id)
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$financeLogic->order=$order;
|
||||
$fees = bcdiv(bcmul($order['pay_price'], $platformRate, 2), 1, 2);
|
||||
if ($fees > 0) {
|
||||
$financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
|
||||
$financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 门店分润
|
||||
*/
|
||||
public static function store($order, $platformRate, $transaction_id,$uid)
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$financeLogic->user['uid']=$order['uid'];
|
||||
$financeLogic->other_arr['vip_uid']=$uid;
|
||||
$financeLogic->order=$order;
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
|
||||
//缴纳齐全了就加商户没有就加到平台
|
||||
$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); //保证金剩余额度
|
||||
$store_profit = bcdiv(bcmul($order['pay_price'], $platformRate, 2), 1, 2);
|
||||
if ($deposit > 0) {
|
||||
if ($deposit > $store_profit) {
|
||||
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->in($transaction_id, 0, OrderEnum::MERCHANT_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
} else {
|
||||
$money = bcsub($store_profit, $deposit, 2);
|
||||
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']);
|
||||
}
|
||||
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'], 0, 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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'], 0, 0, $order['pay_type']); //平台手续费
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分给用户
|
||||
*/
|
||||
public static function user($order, $userRate, $transaction_id,$uid=0,$enum = 0)
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$fees = bcmul($order['pay_price'], $userRate, 2);
|
||||
if ($fees > 0) {
|
||||
//记录用户余额收入
|
||||
if ($uid) {
|
||||
$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->other_arr['vip_uid']=$uid;
|
||||
$financeLogic->order=$order;
|
||||
$financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
$financeLogic->out($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\user\UserShipEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\user_product_storage\UserProductStorageLogic;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\finance\CapitalFlow;
|
||||
use app\common\model\finance\PayNotifyLog;
|
||||
@ -40,14 +42,6 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
if ($action != 'cash_pay' && $action != 'balancePay' && $action != 'purchase_funds' && $action != 'gift_pay') {
|
||||
$payNotifyLogLogic = new PayNotifyLogLogic();
|
||||
if ($action == 'refund') {
|
||||
$payNotifyLogLogic->insert($action, $extra, PayNotifyLog::TYPE_REFUND);
|
||||
} else {
|
||||
$payNotifyLogLogic->insert($action, $extra);
|
||||
}
|
||||
}
|
||||
self::$action($orderSn, $extra, $type);
|
||||
Db::commit();
|
||||
return true;
|
||||
@ -80,6 +74,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
if (!$order->save()) {
|
||||
throw new \Exception('订单保存出错');
|
||||
}
|
||||
if($order['is_storage']==1){
|
||||
$order->status=2;
|
||||
UserProductStorageLogic::add($order);
|
||||
}
|
||||
// 减去余额
|
||||
$user->now_money = bcsub($user['now_money'], $order['pay_price'], 2);
|
||||
$user->save();
|
||||
@ -90,6 +88,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
$order['pay_price'] = $oldUser;
|
||||
}
|
||||
}
|
||||
self::addUserSing($order);
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$capitalFlowDao->userExpense('user_order_balance_pay', 'order', $order['id'], $order['pay_price'], '', 0, $order['store_id']);
|
||||
self::dealProductLog($order);
|
||||
@ -173,6 +172,10 @@ class PayNotifyLogic extends BaseLogic
|
||||
if (!$order->save()) {
|
||||
throw new \Exception('订单保存出错');
|
||||
}
|
||||
if($order['is_storage']==1){
|
||||
$order->status=2;
|
||||
UserProductStorageLogic::add($order);
|
||||
}
|
||||
// 减去采购款
|
||||
$user->purchase_funds = bcsub($user['purchase_funds'], $order['pay_price'], 2);
|
||||
$user->save();
|
||||
@ -182,7 +185,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
// if ($user['user_ship'] == 1) {
|
||||
// self::dealVipAmount($order, PayEnum::PURCHASE_FUNDS);
|
||||
// }
|
||||
|
||||
self::addUserSing($order);
|
||||
if ($extra && $extra['store_id']) {
|
||||
$params = [
|
||||
'verify_code' => $order['verify_code'],
|
||||
@ -214,12 +217,15 @@ class PayNotifyLogic extends BaseLogic
|
||||
if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) {
|
||||
return true;
|
||||
}
|
||||
$order->status = 1;
|
||||
$order->paid = 1;
|
||||
$order->pay_time = time();
|
||||
if($order['is_storage']==1){
|
||||
$order->status=2;
|
||||
UserProductStorageLogic::add($order);
|
||||
}
|
||||
if ($order->pay_type != 10) {
|
||||
$order->pay_price = bcdiv($extra['amount']['payer_total'], 100, 2);
|
||||
$order->paid = 1;
|
||||
$order->pay_time = time();
|
||||
$order->status = 1;
|
||||
$order->save();
|
||||
} else {
|
||||
$extra['transaction_id'] = time();
|
||||
}
|
||||
@ -232,21 +238,11 @@ class PayNotifyLogic extends BaseLogic
|
||||
//微信支付和用户余额无关
|
||||
$capitalFlowDao->userExpense('user_order_pay', 'order', $order['id'], $order->pay_price, '', 1, $order['store_id']);
|
||||
}
|
||||
|
||||
$order->save();
|
||||
self::dealProductLog($order);
|
||||
if ($order['shipping_type'] == 3) {
|
||||
self::descStock($order['id']);
|
||||
}
|
||||
|
||||
// if ($order->pay_type == 9) {
|
||||
// $extra['create_time'] = $order['create_time'];
|
||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'cash_register', 'msg' => '您有一笔订单已支付', 'data' => $extra]);
|
||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||
// }
|
||||
// else {
|
||||
// PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']);
|
||||
// Db::name('order_middle')->insert(['c_order_id' => $order['id']]);
|
||||
// }
|
||||
if (!empty($extra['payer']['openid']) && $order->pay_type == 7) {
|
||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid']], 4);
|
||||
}
|
||||
@ -259,6 +255,17 @@ class PayNotifyLogic extends BaseLogic
|
||||
//更新状态
|
||||
$order = StoreOrder::where('order_id', $orderSn)->findOrEmpty();
|
||||
if ($order->isEmpty() || $order->status == OrderEnum::REFUND_PAY) {
|
||||
//充值
|
||||
$orderRe = UserRecharge::where('order_id', $orderSn)->findOrEmpty();
|
||||
if ($orderRe->isEmpty() || $orderRe->status == -1) {
|
||||
return true;
|
||||
}
|
||||
$orderRe->status = -1;
|
||||
$orderRe->refund_price = $orderRe->price;
|
||||
$orderRe->refund_time = time();
|
||||
$orderRe->remarks = '';
|
||||
$orderRe->save();
|
||||
|
||||
return true;
|
||||
}
|
||||
$order->status = OrderEnum::REFUND_PAY;
|
||||
@ -272,6 +279,8 @@ class PayNotifyLogic extends BaseLogic
|
||||
$user = User::where('id', $order['uid'])->findOrEmpty();
|
||||
$capitalFlowDao = new CapitalFlowLogic($user);
|
||||
$deal_money = bcdiv($extra['amount']['refund'], 100, 2);
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
||||
if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) {
|
||||
if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额
|
||||
$user->now_money = bcadd($user->now_money, $deal_money, 2);
|
||||
@ -281,6 +290,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
//退款
|
||||
$capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money);
|
||||
}
|
||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
||||
if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款
|
||||
$user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2);
|
||||
$user->save();
|
||||
@ -292,11 +302,37 @@ class PayNotifyLogic extends BaseLogic
|
||||
}
|
||||
//微信日志 user_order_refund
|
||||
$capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1);
|
||||
//处理财务流水退还
|
||||
self::store_finance_back($orderSn);
|
||||
self::addStock($order['id']); //微信
|
||||
|
||||
return true;
|
||||
// self::afterPay($order,$extra['transaction_id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 财务退还金额相关
|
||||
* @param $orderSn
|
||||
* @return void
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function store_finance_back($orderSn)
|
||||
{
|
||||
$data = StoreFinanceFlow::where('order_sn', $orderSn)
|
||||
->where(['financial_pm' => 1])
|
||||
->select()->toArray();
|
||||
foreach ($data as &$value) {
|
||||
unset($value['id']);
|
||||
$value['financial_record_sn'] = (new StoreFinanceFlowLogic)->getSn();
|
||||
$value['financial_pm'] = 0;
|
||||
$value['financial_type'] = OrderEnum::PAY_BACK;
|
||||
$value['create_time'] = time();
|
||||
}
|
||||
(new StoreFinanceFlow)->saveAll($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 现金退款相关
|
||||
* @param $orderSn
|
||||
@ -320,6 +356,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
//日志记录
|
||||
$model = new StoreCashFinanceFlow();
|
||||
$model->store_id = $order['store_id'] ?? 0;
|
||||
$model->store_id = $order['store_id'] ?? 0;
|
||||
$model->cash_price = $order->pay_price;
|
||||
$model->receivable = $order->pay_price;
|
||||
$model->remark = '退款';
|
||||
@ -331,6 +368,45 @@ class PayNotifyLogic extends BaseLogic
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值现金退款相关
|
||||
* @param $orderId
|
||||
* @param $extra
|
||||
* @return true
|
||||
*/
|
||||
public static function recharge_cash_refund($orderId, $extra = [])
|
||||
{
|
||||
$order = UserRecharge::where('id', $orderId)->findOrEmpty();
|
||||
if ($order->isEmpty() || $order->status == -1) {
|
||||
return true;
|
||||
}
|
||||
$order->status = -1;
|
||||
$order->refund_price = $order->price;
|
||||
$order->refund_time = time();
|
||||
$order->remarks = '';
|
||||
$order->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
//入冻结礼品券
|
||||
public static function addUserSing($order)
|
||||
{
|
||||
$user_sing = new UserSign();
|
||||
if ($order['uid'] > 0 && $order['total_price'] > 500) {
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*/
|
||||
@ -361,14 +437,17 @@ class PayNotifyLogic extends BaseLogic
|
||||
bcscale(2);
|
||||
// $user->now_money = bcadd($user->now_money, $price, 2);//v.1
|
||||
//更新等级
|
||||
if ($price >= 0.01) {
|
||||
if ($price >= Config::where('name','recharge')->value('value')) {
|
||||
$user->user_ship = 1; //v.1
|
||||
}
|
||||
$user->purchase_funds = bcadd($user->purchase_funds, $price, 2);
|
||||
$user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2);
|
||||
$user->save();
|
||||
|
||||
|
||||
if($order['other_uid']>0){
|
||||
$uid=$order['other_uid'];
|
||||
}
|
||||
PushService::push('wechat_mmp_' . $uid, $uid, ['type'=>'INDUSTRYMEMBERS','msg'=>'订单支付成功','data'=>['id'=>$order['id'],'paid'=>1]]);
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type'=>'INDUSTRYMEMBERS','msg'=>'订单支付成功','data'=>['id'=>$order['id'],'paid'=>1]]);
|
||||
if (!empty($extra['payer']['openid'])) {
|
||||
Redis::send('push-delivery', ['order_id' => $order['order_id'], 'openid' => $extra['payer']['openid'], 'logistics_type' => 3], 4);
|
||||
}
|
||||
@ -399,6 +478,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
self::descStock($order['id']);
|
||||
}
|
||||
// Redis::send('push-platform-print', ['id' => $order['id']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -453,24 +533,28 @@ class PayNotifyLogic extends BaseLogic
|
||||
{
|
||||
$financeLogic = new StoreFinanceFlowLogic();
|
||||
$user_sing = new UserSign();
|
||||
//-----活动价结算更改
|
||||
$financeLogic->order = $order;
|
||||
$financeLogic->user = ['uid' => $order['uid']];
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
if ($order['uid'] > 0) {
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
if ($off_activity == 1) {
|
||||
//-----活动价结算更改
|
||||
$financeLogic->order = $order;
|
||||
$financeLogic->user = ['uid' => $order['uid']];
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付
|
||||
$financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']);
|
||||
$financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']);
|
||||
if ($order['uid'] > 0 && $order['total_price'] > 500 && $order['pay_type'] !=18
|
||||
&& $order['pay_type'] !=3) {
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
$vipFen = 0;
|
||||
if ($order['uid'] > 0) {
|
||||
// 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去
|
||||
@ -492,17 +576,21 @@ class PayNotifyLogic extends BaseLogic
|
||||
$order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2);
|
||||
self::dealVipAmount($order, $order['pay_type']);
|
||||
}
|
||||
if($order['total_price'] > 500 && $order['pay_type'] !=18
|
||||
&& $order['pay_type'] !=3){
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
'status' => 0,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
}
|
||||
|
||||
$user_number = bcmul($order['pay_price'], '0.10', 2);
|
||||
$sing = [
|
||||
'uid' => $order['uid'],
|
||||
'order_id' => $order['order_id'],
|
||||
'title' => '购买商品获得兑换券',
|
||||
'store_id' => $order['store_id'],
|
||||
'number' => $user_number,
|
||||
];
|
||||
$user_sing->save($sing);
|
||||
User::where('id', $order['uid'])->inc('integral', $user_number)->update();
|
||||
// User::where('id', $order['uid'])->inc('integral', $user_number)->update();
|
||||
}
|
||||
|
||||
|
||||
@ -852,6 +940,7 @@ class PayNotifyLogic extends BaseLogic
|
||||
'id' => $StoreBranchProduct['id'],
|
||||
'stock' => $StoreBranchProduct['stock'] + $v['cart_num'],
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
// 'sales' => ['inc', $v['cart_num']]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class StoreFinanceFlowLogic extends BaseLogic
|
||||
'order_id' => $this->order['id'],
|
||||
'transaction_id' => $transaction_id,
|
||||
'order_sn' => $this->order['order_id'],
|
||||
'user_id' => $this->user['uid'],
|
||||
'user_id' => $this->user['uid']??0,
|
||||
'other_uid' => $this->other_arr['vip_uid']??0,
|
||||
'financial_type' => $financialType,
|
||||
'financial_pm' => $pm,
|
||||
|
@ -19,6 +19,7 @@ use app\common\service\SmsService;
|
||||
use Exception;
|
||||
use support\Cache;
|
||||
use think\facade\Db;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
|
||||
class StoreOrderLogic extends BaseLogic
|
||||
{
|
||||
@ -32,6 +33,11 @@ class StoreOrderLogic extends BaseLogic
|
||||
* @notes 获取购物车商品信息
|
||||
* @param $params
|
||||
* @return array|bool
|
||||
*/
|
||||
/**
|
||||
* @notes 获取购物车商品信息
|
||||
* @param $params
|
||||
* @return array|bool
|
||||
*/
|
||||
static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = [])
|
||||
{
|
||||
@ -45,14 +51,19 @@ class StoreOrderLogic extends BaseLogic
|
||||
try {
|
||||
self::$total_price = 0;
|
||||
self::$pay_price = 0;
|
||||
self::$cost = 0; //成本
|
||||
self::$cost = 0; //成本由采购价替代原成本为门店零售价
|
||||
self::$profit = 0; //利润
|
||||
self::$activity_price = 0; //活动减少
|
||||
self::$store_price = 0; //门店零售价
|
||||
/** 计算价格 */
|
||||
$pay_type = isset($params['pay_type'])?$params['pay_type']:0;
|
||||
// $off_activity=Config::where('name','off_activity')->value('value');
|
||||
// if($off_activity==1){
|
||||
// $field='id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id';
|
||||
// }else{
|
||||
$field='id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id';
|
||||
// }
|
||||
foreach ($cart_select as $k => $v) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'],'store_id'=>$params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,swap')->withTrashed()->find();
|
||||
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
|
||||
if (!$find) {
|
||||
continue;
|
||||
}
|
||||
@ -63,47 +74,39 @@ class StoreOrderLogic extends BaseLogic
|
||||
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
|
||||
$cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额
|
||||
$cart_select[$k]['vip'] = 0;
|
||||
if ($user && $user['user_ship'] == 1) {
|
||||
//更新 会员为1的时候原价减去会员价
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
$cart_select[$k]['vip'] =1;
|
||||
}
|
||||
// if($off_activity!=1){
|
||||
// if ($user && $user['user_ship'] == 1) {
|
||||
// //更新 会员为1的时候原价减去会员价
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// $cart_select[$k]['vip'] =1;
|
||||
// }
|
||||
// if ($user && $user['user_ship'] == 4) {
|
||||
// //更新 为4商户的时候减去商户价格
|
||||
// $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||
// $cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
// self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
// }
|
||||
// }
|
||||
|
||||
if ($user && $user['user_ship'] == 4) {
|
||||
//更新 为4商户的时候减去商户价格
|
||||
$deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2);
|
||||
$cart_select[$k]['deduction_price'] =$deduction_price_count;
|
||||
self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2);
|
||||
}
|
||||
if($pay_type ==19){
|
||||
if ($find['swap'] < $cart_select[$k]['cart_num']) {
|
||||
throw new \Exception('兑换数量不足');
|
||||
}
|
||||
}
|
||||
//利润
|
||||
// $cart_select[$k]['profit'] = bcmul($cart_select[$k]['total_price'],0.05,2); //利润
|
||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||
$cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单支付金额
|
||||
$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]['product_id'] = $find['product_id'];
|
||||
$cart_select[$k]['old_cart_id'] = $v['id'];
|
||||
$cart_select[$k]['cart_num'] = $v['cart_num'];
|
||||
$cart_select[$k]['verify_code'] = $params['verify_code'] ?? '';
|
||||
//vip1待返回金额
|
||||
|
||||
$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'] );
|
||||
$cartInfo = $cart_select[$k];
|
||||
$cartInfo['name'] = $find['store_name'];
|
||||
$cartInfo['image'] = $find['image'];
|
||||
//计算好vip价格
|
||||
// $vipPrice = self::dealVip($find['price']);
|
||||
// if ($vipPrice) {
|
||||
// $cartInfo['price'] = $vipPrice;
|
||||
// }
|
||||
//$cart_select[$k]['total'] - $vipPrice ?? 0;
|
||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||
$cart_select[$k]['branch_product_id'] = $find['branch_product_id'];
|
||||
//理论上每笔都是拆分了
|
||||
@ -113,53 +116,52 @@ class StoreOrderLogic extends BaseLogic
|
||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['cost'], 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::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2);
|
||||
}
|
||||
if ($user && $user['user_ship'] == 1 && $pay_type !=17) {
|
||||
$pay_price = self::$pay_price;
|
||||
$activity_string = '';
|
||||
}else{
|
||||
$pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||
$activity_string = '减免';
|
||||
}
|
||||
if($pay_type == 19){
|
||||
$pay_price = self::$pay_price;
|
||||
$activity_string = '';
|
||||
}
|
||||
//加支付方式限制
|
||||
// $pay_type = isset($params['pay_type'])?$params['pay_type']:0;
|
||||
// if ($user && $user['user_ship'] == 1 && $pay_type !=17) {
|
||||
// $pay_price = self::$pay_price;
|
||||
// }else{
|
||||
// $pay_price =bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额
|
||||
// }
|
||||
$pay_price = self::$pay_price;
|
||||
|
||||
// if($pay_price < 500){
|
||||
// throw new \think\Exception('金额低于500');
|
||||
// throw new Exception('金额低于500');
|
||||
// }
|
||||
|
||||
$vipPrice = 0;
|
||||
|
||||
//成本价 收益
|
||||
$order = [
|
||||
'create_time' => time(),
|
||||
'order_id' =>$params['order_id'] ?? getNewOrderId('PF'),
|
||||
'order_id' => $params['order_id'] ?? getNewOrderId('PF'),
|
||||
'total_price' => self::$total_price, //总价
|
||||
'cost' => self::$cost,//成本价
|
||||
'profit' => 0,//利润
|
||||
'pay_price' => $pay_price,//后期可能有降价抵扣
|
||||
'vip_price' => $vipPrice,
|
||||
'total_num' => count($cart_select),//总数
|
||||
'cost' => self::$cost, //成本价1-
|
||||
'pay_price' => $pay_price, //后期可能有降价抵扣
|
||||
'vip_price' => 0,
|
||||
'total_num' => count($cart_select), //总数
|
||||
'pay_type' => $params['pay_type'] ?? 0,
|
||||
'reservation_time' => $params['reservation_time'] ?? null,
|
||||
'cart_id' => implode(',', $cartId),
|
||||
'store_id' => $params['store_id'] ?? 0,
|
||||
'shipping_type' =>3,//配送方式 1=快递 ,2=门店自提
|
||||
'activity' =>$activity_string,
|
||||
'activity_price' =>self::$activity_price,//活动优惠价
|
||||
'shipping_type' => $params['shipping_type'] ?? 2, //配送方式 1=快递 ,2=门店自提
|
||||
'activity' => '减免',
|
||||
'activity_price' => self::$activity_price,
|
||||
'activities' => self::$activity_price>0?1:0,
|
||||
'default_delivery'=>1,
|
||||
'original_price'=>self::$total_price,
|
||||
'deduction_price' => self::$activity_price,//抵扣金额
|
||||
'deduction_price' => self::$activity_price,
|
||||
'is_vip' => 0,
|
||||
'is_storage' => $params['is_storage']??0,
|
||||
];
|
||||
if($user && $user['user_ship']!=4){
|
||||
$order['is_vip']=1;
|
||||
$order['default_delivery'] = 0;
|
||||
if ($params['store_id']) {
|
||||
$order['default_delivery'] = SystemStore::where('id', $params['store_id'])->value('is_send');
|
||||
}
|
||||
if($user && $user['user_ship']>=1 &&$user['user_ship']<=3){
|
||||
$order['is_vip'] = 1;
|
||||
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
@ -256,12 +258,16 @@ class StoreOrderLogic extends BaseLogic
|
||||
$pageNo = $params['page_no'];
|
||||
$pageSize = $params['page_size'];
|
||||
unset($params['page_no'],$params['page_size']);
|
||||
if($params['verify_code']==''){
|
||||
unset($params['verify_code']);
|
||||
}
|
||||
$params['paid'] = YesNoEnum::YES;
|
||||
$params['is_writeoff'] = YesNoEnum::YES;
|
||||
$order = StoreOrder::with(['user', 'staff', 'product' => function ($query) {
|
||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||
}])->where($params)->whereIn('shipping_type',OrderEnum::ONLINE)
|
||||
}])->where($params)
|
||||
->page($pageNo, $pageSize)
|
||||
->order('id desc')
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($order as &$value){
|
||||
@ -286,6 +292,9 @@ class StoreOrderLogic extends BaseLogic
|
||||
*/
|
||||
public function storeOrderCount($storeId, $status, $paid = 1)
|
||||
{
|
||||
if(empty($storeId)){
|
||||
return StoreOrder::where(['status' => $status, 'paid' => $paid])->count();
|
||||
}
|
||||
return StoreOrder::where(['store_id' => $storeId, 'status' => $status, 'paid' => $paid])->count();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\user_product_storage;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\user_product_storage\UserProductStorage;
|
||||
use app\common\model\user_product_storage_log\UserProductStorageLog;
|
||||
|
||||
class UserProductStorageLogic extends BaseLogic
|
||||
{
|
||||
public static function add($order){
|
||||
$arr=StoreOrderCartInfo::where('oid',$order['id'])->field('product_id,cart_num nums')->select();
|
||||
if($arr){
|
||||
$data=$arr;
|
||||
$data_log=$arr;
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
$data[$k]['uid']=$order['uid'];
|
||||
$data[$k]['oid']=$order['id'];
|
||||
$data[$k]['status']=1;
|
||||
$data_log[$k]['uid']=$order['uid'];
|
||||
$data_log[$k]['oid']=$order['id'];
|
||||
$data_log[$k]['financial_pm']=1;
|
||||
}
|
||||
UserProductStorage::insertAll($data);
|
||||
UserProductStorageLog::insertAll($data_log);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\logic\user_product_storage_log;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
|
||||
class UserProductStorageLogLogic extends BaseLogic
|
||||
{
|
||||
|
||||
}
|
20
app/common/model/user_product_storage/UserProductStorage.php
Normal file
20
app/common/model/user_product_storage/UserProductStorage.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\user_product_storage;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 用户商品储存
|
||||
* Class UserProductStorage
|
||||
* @package app\common\model\user_product_storage
|
||||
*/
|
||||
class UserProductStorage extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'user_product_storage';
|
||||
protected $deleteTime = 'delete_time';
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model\user_product_storage_log;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* 用户商品储存操作日志
|
||||
* Class UserProductStorageLog
|
||||
* @package app\common\model\user_product_storage_log
|
||||
*/
|
||||
class UserProductStorageLog extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'user_product_storage_log';
|
||||
protected $deleteTime = 'delete_time';
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use support\Log;
|
||||
use Webman\Push\Api;
|
||||
|
||||
class PushService
|
||||
@ -15,6 +16,7 @@ class PushService
|
||||
*/
|
||||
public static function push($subscription, $uid, $content)
|
||||
{
|
||||
Log::info('PushService::push', [$subscription, $uid, $content]);
|
||||
$api = new Api(
|
||||
getenv('PUSH_URL'),
|
||||
config('plugin.webman.push.app.app_key'),
|
||||
|
@ -75,7 +75,8 @@ class SmsService
|
||||
return false;
|
||||
}
|
||||
}catch(NoGatewayAvailableException $e){
|
||||
throw new BusinessException($e->getMessage());
|
||||
|
||||
throw new BusinessException($e->getExceptions());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace app\queue\redis;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\retail\Cashierclass;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\service\pay\PayService;
|
||||
use app\common\service\PushService;
|
||||
use Webman\RedisQueue\Consumer;
|
||||
@ -44,17 +45,29 @@ class CodePaySend implements Consumer
|
||||
{
|
||||
// 直接更改消息队列数据结构,将最大重试次数max_attempts字段设置为0,即不再重试。
|
||||
if($package['attempts'] ==$exception['max_attempts']){
|
||||
$pay = new PayService();
|
||||
$data = [
|
||||
'order_id' => $package['data']['order_id'],
|
||||
'paid' => 0,
|
||||
];
|
||||
$find=StoreOrder::where($data)->find();
|
||||
if($find){
|
||||
$order = StoreOrder::update($data);
|
||||
if($package['data']['pay_type']=='recharge'){
|
||||
$order=UserRecharge::where($data)->find();
|
||||
if($order){
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type'=>'cash_register','msg'=>'支付超时,订单已被取消,请重新提交订单']);
|
||||
$res=UserRecharge::where($data)->update(['status'=>-1]);
|
||||
if($res){
|
||||
PushService::push('wechat_mmp_' . $order['uid'], $order['uid'], ['type'=>'INDUSTRYMEMBERS','msg'=>'支付超时,订单已被取消,请重新提交订单','data'=>['id'=>$data['id'],'paid'=>0]]);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
$order=StoreOrder::where($data)->find();
|
||||
if($order){
|
||||
PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type'=>'cash_register','msg'=>'支付超时,订单已被取消,请重新提交订单']);
|
||||
}
|
||||
}
|
||||
$pay->wechat->close(['out_trade_no'=>$order['order_id']]);
|
||||
|
||||
|
||||
}
|
||||
return $package;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class StoreStorageSend implements Consumer
|
||||
'batch' => $find['batch'],
|
||||
'store_id' => $store_id,
|
||||
'sales' => 0,
|
||||
'product_type' => $find['product_type'],
|
||||
'stock' => 0,
|
||||
];
|
||||
$branch = StoreBranchProduct::create($product);
|
||||
|
@ -2,7 +2,10 @@
|
||||
|
||||
namespace app\statistics\controller;
|
||||
|
||||
use app\admin\logic\statistic\TradeStatisticLogic;
|
||||
use app\common\controller\BaseLikeController;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user_recharge\UserRecharge;
|
||||
use app\statistics\logic\OrderLogic;
|
||||
use app\statistics\logic\ProductLogic;
|
||||
use app\statistics\logic\UserLogic;
|
||||
@ -11,25 +14,27 @@ use DateTime;
|
||||
class IndexController extends BaseLikeController
|
||||
{
|
||||
|
||||
public $store_id=3;
|
||||
public $store_id = 0;
|
||||
|
||||
public function index()
|
||||
{
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$store_id = $this->store_id;
|
||||
if($store_id){
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$where['paid'] = 1;
|
||||
$res = OrderLogic::dayPayPrice($where);
|
||||
$res = OrderLogic::dayPayPrice($where, $time);
|
||||
if (OrderLogic::hasError()) {
|
||||
return $this->fail(OrderLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
return $this->success('ok', ['dayPayPrice' => $res,'title'=>'百合镇农(特)产品交易大数据']);
|
||||
return $this->success('ok', ['dayPayPrice' => $res, 'title' => '百合镇农(特)产品交易大数据']);
|
||||
}
|
||||
public function user()
|
||||
{
|
||||
$today = strtotime(date('Y-m-d'));
|
||||
$dates=[];
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$today = strtotime($time);
|
||||
$dates = [];
|
||||
// 循环输出前5天的日期
|
||||
for ($i = 0; $i <= 4; $i++) {
|
||||
// 计算前第$i天的日期时间戳
|
||||
@ -37,14 +42,14 @@ class IndexController extends BaseLikeController
|
||||
|
||||
// 将时间戳格式化为日期
|
||||
$date = date('Y-m-d', $timestamp);
|
||||
$dates[]=$date;
|
||||
$dates[] = $date;
|
||||
}
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where = [];
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = UserLogic::userCount($where,$dates);
|
||||
$res = UserLogic::userCount($where, $dates);
|
||||
if (UserLogic::hasError()) {
|
||||
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
@ -56,12 +61,13 @@ class IndexController extends BaseLikeController
|
||||
*/
|
||||
public function product_count()
|
||||
{
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where = [];
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = ProductLogic::Count($where);
|
||||
$res = ProductLogic::Count($where, $time);
|
||||
if (ProductLogic::hasError()) {
|
||||
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
@ -72,28 +78,40 @@ class IndexController extends BaseLikeController
|
||||
*/
|
||||
public function order_user_num_count()
|
||||
{
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where = [];
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = OrderLogic::Count($where);
|
||||
if (ProductLogic::hasError()) {
|
||||
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
return $this->success('ok', $res);
|
||||
$where['recharge_type']='INDUSTRYMEMBERS';
|
||||
$where['status']=1;
|
||||
$where['paid']=1;
|
||||
// $res = OrderLogic::Count($where,$time);
|
||||
// if (ProductLogic::hasError()) {
|
||||
// return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
|
||||
// }
|
||||
$res = UserRecharge::where($where)->whereTime('create_time', $time)->select()->each(function ($item) {
|
||||
if($item['uid']){
|
||||
$item['nickname']=User::where('id',$item['uid'])->value('nickname');
|
||||
}else{
|
||||
$item['nickname']='';
|
||||
}
|
||||
});
|
||||
return $this->success('ok', $res?->toArray());
|
||||
}
|
||||
/**
|
||||
* 商品销量排行榜统计
|
||||
*/
|
||||
public function sales_ranking()
|
||||
{
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where = [];
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = ProductLogic::sales($where);
|
||||
$res = OrderLogic::sales($where, $time);
|
||||
if (ProductLogic::hasError()) {
|
||||
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
@ -104,38 +122,31 @@ class IndexController extends BaseLikeController
|
||||
*/
|
||||
public function user_trade_count()
|
||||
{
|
||||
$dates = [];
|
||||
$logic = (new TradeStatisticLogic());
|
||||
$leftToday = $logic->getTopLeftTrade(['create_time' => 'today']);
|
||||
$leftyestoday = $logic->getTopLeftTrade(['create_time' => 'yestoday']);
|
||||
$totalleft = [$leftToday, $leftyestoday];
|
||||
foreach ($totalleft as $k => $v) {
|
||||
$left['name'] = "当日订单金额";
|
||||
$left['x'] = $v['curve']['x'];
|
||||
$left['series'][$k]['money'] = round($v['total_money'], 2);
|
||||
$left['series'][$k]['value'] = array_values($v['curve']['y']);
|
||||
}
|
||||
|
||||
$today = new DateTime();
|
||||
$thirtyDaysAgo = new DateTime($today->format('Y-m-d'));
|
||||
$thirtyDaysAgo->modify('-30 days');
|
||||
for ($i = 0; $i < 31; $i++) {
|
||||
$date = new DateTime($thirtyDaysAgo->format('Y-m-d'));
|
||||
$date->modify('+' . $i . ' days');
|
||||
$dates[] = $date->format('Y-m-d');
|
||||
}
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = UserLogic::TradeCount($where, $dates);
|
||||
if (UserLogic::hasError()) {
|
||||
return $this->fail(UserLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
return $this->success('ok', $res);
|
||||
return $this->data($left);
|
||||
}
|
||||
/**
|
||||
* 当日订单金额
|
||||
*/
|
||||
public function street_currday_order_count()
|
||||
{
|
||||
$time = $this->request->get('date', date('Y-m-d'));
|
||||
$store_id = $this->store_id;
|
||||
$where=[];
|
||||
if($store_id){
|
||||
$where = [];
|
||||
if ($store_id) {
|
||||
$where['store_id'] = $store_id;
|
||||
}
|
||||
$res = OrderLogic::Currday($where);
|
||||
$res = OrderLogic::Currday($where, $time);
|
||||
if (ProductLogic::hasError()) {
|
||||
return $this->fail(ProductLogic::getError()); //获取错误信息并返回错误信息
|
||||
}
|
||||
|
@ -26,9 +26,8 @@ class OrderLogic extends BaseLogic
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
public static function Currday($where)
|
||||
public static function Currday($where,$date)
|
||||
{
|
||||
$date = date("Y-m-d");
|
||||
$startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳
|
||||
$endTime = strtotime($date . ' 23:59:59'); // 当天的结束时间戳
|
||||
|
||||
@ -57,14 +56,19 @@ class OrderLogic extends BaseLogic
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public static function dayPayPrice($where)
|
||||
public static function dayPayPrice($where,$time)
|
||||
{
|
||||
$todayAmount = UserRecharge::where($where)
|
||||
->whereDay('create_time')
|
||||
->whereDay('create_time',$time)
|
||||
->sum('price');
|
||||
$pay_price = StoreOrder::where($where)
|
||||
->whereDay('create_time')
|
||||
->whereDay('create_time',$time)
|
||||
->sum('pay_price');
|
||||
return bcadd($todayAmount, $pay_price, 2);
|
||||
}
|
||||
|
||||
public static function sales($where,$time){
|
||||
$select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select();
|
||||
return $select?->toArray();
|
||||
}
|
||||
}
|
||||
|
@ -7,22 +7,22 @@ use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
|
||||
class ProductLogic extends BaseLogic
|
||||
{
|
||||
public static function Count($where)
|
||||
public static function Count($where,$time)
|
||||
{
|
||||
$todayProductCount=StoreBranchProduct::where($where)->count();
|
||||
$yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime(date('Y-md'))-1)->count();
|
||||
$todayProductCount=StoreBranchProduct::where($where)->whereDay('create_time',$time)->count();
|
||||
$yestertodayProductCount=StoreBranchProduct::where($where)->where('create_time', '<',strtotime($time)-1)->count();
|
||||
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
|
||||
$weeklyProductTotalGrowthRate = 0;
|
||||
} else {
|
||||
$weeklyProductTotalGrowthRate = ($todayProductCount - $yestertodayProductCount) / $yestertodayProductCount * 100;
|
||||
$weeklyProductTotalGrowthRate =bcdiv(($todayProductCount - $yestertodayProductCount) ,$yestertodayProductCount) * 100;
|
||||
}
|
||||
|
||||
$todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time')->count();
|
||||
$yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', 'yesterday')->count();
|
||||
if ($yestertodayProductCount == 0 ||$todayProductCount==0) {
|
||||
$todayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time',$time)->count();
|
||||
$yestertodayNewProductCount=StoreBranchProduct::where($where)->whereDay('create_time', date('Y-m-d',strtotime($time)-1))->count();
|
||||
if ($todayNewProductCount == 0 ||$yestertodayNewProductCount==0) {
|
||||
$weeklyNewProductTotalGrowthRate = 0;
|
||||
} else {
|
||||
$weeklyNewProductTotalGrowthRate = ($todayNewProductCount - $yestertodayNewProductCount) / $yestertodayNewProductCount * 100;
|
||||
$weeklyNewProductTotalGrowthRate =bcdiv(($todayNewProductCount - $yestertodayNewProductCount),$yestertodayNewProductCount) * 100;
|
||||
}
|
||||
$data = [
|
||||
"totalProductCounInfo" => [
|
||||
|
@ -18,6 +18,7 @@ use app\common\logic\store_order\StoreOrderLogic;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_order\StoreOrder;
|
||||
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
||||
use app\common\model\store_product\StoreProduct;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\system_store\SystemStore;
|
||||
use app\common\model\system_store\SystemStoreStaff;
|
||||
@ -59,9 +60,9 @@ class StoreOrderController extends BaseAdminController
|
||||
'pay_type' => PayEnum::getPaySceneDesc(),
|
||||
'order_status' => [
|
||||
'wait_send' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 0),
|
||||
'to_be_paid' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 0, 0),
|
||||
'wait_receive' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 1),
|
||||
'finish' => $orderLogic->storeOrderCount($this->request->adminInfo['store_id'], 2),
|
||||
'to_be_paid' => $orderLogic->storeOrderCount(0, 0, 0),
|
||||
'wait_receive' => $orderLogic->storeOrderCount(0, 1),
|
||||
'finish' => $orderLogic->storeOrderCount(0, 2),
|
||||
],
|
||||
]);
|
||||
}
|
||||
@ -85,13 +86,13 @@ class StoreOrderController extends BaseAdminController
|
||||
$params = $this->request->post();
|
||||
$params['store_id'] = $this->adminInfo['store_id'];
|
||||
$user = User::where('id', $params['uid'])->find();
|
||||
$res = StoreOrderLogic::cartIdByOrderInfo($cartId, null, $user, $params);
|
||||
$res = OrderLogic::cartIdByOrderInfo($cartId, null, $user, $params);
|
||||
if ($res == false) {
|
||||
$msg = StoreOrderLogic::getError();
|
||||
$msg = OrderLogic::getError();
|
||||
if ($msg == '购物车为空') {
|
||||
return $this->data([]);
|
||||
}
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($res);
|
||||
}
|
||||
@ -105,9 +106,9 @@ class StoreOrderController extends BaseAdminController
|
||||
if (empty($user)) {
|
||||
return $this->fail('无该用户请检查');
|
||||
}
|
||||
$order = StoreOrderLogic::cartIdByOrderInfo($params['cart_id'], null, $user, $params);
|
||||
$order = OrderLogic::cartIdByOrderInfo($params['cart_id'], null, $user, $params);
|
||||
if (!$order) {
|
||||
return $this->fail(StoreOrderLogic::getError());
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
if ($params['type'] == 1) {
|
||||
if ($order['order']['pay_price'] > $user['purchase_funds']) {
|
||||
@ -169,7 +170,8 @@ class StoreOrderController extends BaseAdminController
|
||||
$user = User::where('id', $uid)->find();
|
||||
}
|
||||
$params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单
|
||||
$order = StoreOrderLogic::createOrder($cartId, $addressId, $user, $params);
|
||||
$params['shipping_type'] =3;
|
||||
$order = OrderLogic::createOrder($cartId, $addressId, $user, $params);
|
||||
if ($order != false) {
|
||||
switch ($pay_type) {
|
||||
case PayEnum::PURCHASE_FUNDS:
|
||||
@ -320,15 +322,11 @@ class StoreOrderController extends BaseAdminController
|
||||
// ]
|
||||
public function writeoff_list(StoreOrderLogic $orderLogic)
|
||||
{
|
||||
$page_no = (int)$this->request->post('page_no', 1);
|
||||
$page_size = (int)$this->request->post('page_size', 15);
|
||||
$params = $this->request->post();
|
||||
$page_no = (int)$this->request->get('page_no', 1);
|
||||
$page_size = (int)$this->request->get('page_size', 15);
|
||||
$params = $this->request->get();
|
||||
$params['page_no'] = $page_no;
|
||||
$params['page_size'] = $page_size;
|
||||
if (empty($page_no) || empty($page_size)) {
|
||||
$params['page_no'] = 1;
|
||||
$params['page_size'] = 15;
|
||||
}
|
||||
$params['store_id'] = $this->request->adminInfo['store_id'];
|
||||
$result = $orderLogic->writeList($params);
|
||||
|
||||
@ -436,7 +434,7 @@ class StoreOrderController extends BaseAdminController
|
||||
$find['nickname'] = $user['nickname'] ?? '';
|
||||
$find['user_mobile'] = $user['mobile'] ?? '';
|
||||
$find['info'] = StoreOrderCartInfo::where('oid', $find['id'])->field('store_id,product_id,cart_num,cart_info')->select()->each(function ($item) {
|
||||
$goods = StoreBranchProduct::where(['store_id' => $item['store_id'], 'product_id' => $item['product_id']])->field('store_name,unit')->find();
|
||||
$goods = StoreProduct::where(['id' => $item['product_id']])->field('store_name,unit')->find();
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $goods['unit'])->value('name');
|
||||
$item['store_name'] = $goods['store_name'];
|
||||
$item['total_price'] = $item['cart_info']['total_price'];
|
||||
|
@ -19,31 +19,9 @@ use app\store\validate\store_product\StoreProductValidate;
|
||||
// #[ApiDoc\title('商品列表')]
|
||||
class StoreProductController extends BaseAdminController
|
||||
{
|
||||
|
||||
// #[
|
||||
// ApiDoc\Title('商品列表'),
|
||||
// ApiDoc\url('/store/store_product/storeProduct/lists'),
|
||||
// ApiDoc\Method('GET'),
|
||||
// ApiDoc\NotHeaders(),
|
||||
// ApiDoc\Query(name: 'cate_id', type: 'int', require: false, desc: '分类id'),
|
||||
// ApiDoc\Query(name: 'store_name', type: 'string', require: false, desc: '商品名称'),
|
||||
// ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:1上架,2下架,3售罄,4库存告警'),
|
||||
// ApiDoc\Header(ref: [Definitions::class, "token"]),
|
||||
// ApiDoc\Query(ref: [Definitions::class, "page"]),
|
||||
// ApiDoc\ResponseSuccess("data", type: "array", children: [
|
||||
// ['name' => 'id', 'desc' => 'ID', 'type' => 'int'],
|
||||
// ['name' => 'product_id', 'desc' => '商品ID', 'type' => 'int'],
|
||||
// ['name' => 'image', 'desc' => '图片', 'type' => 'string'],
|
||||
// ['name' => 'store_name', 'desc' => '商品名称', 'type' => 'string'],
|
||||
// ['name' => 'price', 'desc' => '零售价', 'type' => 'float'],
|
||||
// ['name' => 'cost', 'desc' => '成本价', 'type' => 'float'],
|
||||
// ['name' => 'sales', 'desc' => '销量', 'type' => 'int'],
|
||||
// ['name' => 'stock', 'desc' => '库存', 'type' => 'int'],
|
||||
// ['name' => 'unit_name', 'desc' => '单位', 'type' => 'string'],
|
||||
// ['name' => 'cate_name', 'desc' => '分类', 'type' => 'string'],
|
||||
// ['name' => 'status', 'desc' => '状态:1上架,0下架', 'type' => 'string'],
|
||||
// ]),
|
||||
// ]
|
||||
/**
|
||||
* 商品列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new StoreBranchProductLists());
|
||||
@ -194,5 +172,4 @@ class StoreProductController extends BaseAdminController
|
||||
StoreBranchProductLogic::stock($params);
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,11 +4,13 @@
|
||||
namespace app\store\controller\user;
|
||||
|
||||
|
||||
use app\common\service\SmsService;
|
||||
use app\store\controller\BaseAdminController;
|
||||
use app\store\lists\user\UserLists;
|
||||
use app\admin\logic\user\UserLogic;
|
||||
use app\admin\validate\user\UserValidate;
|
||||
use app\common\model\user\User;
|
||||
use support\Cache;
|
||||
|
||||
class UserController extends BaseAdminController
|
||||
{
|
||||
@ -18,10 +20,36 @@ class UserController extends BaseAdminController
|
||||
return $this->dataLists(new UserLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户档案短信
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function archives_sms()
|
||||
{
|
||||
$mobile = $this->request->post('mobile','');
|
||||
if (empty($mobile))
|
||||
return $this->fail('手机号缺失');
|
||||
$res = (new \app\api\logic\user\UserLogic())->dealReportingSms($mobile,'_userArchives');
|
||||
if ($res){
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
return $this->fail('发送失败');
|
||||
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('storeAdd');
|
||||
$code = $params['code'];
|
||||
if($code && $params['mobile']){
|
||||
$remark = $params['mobile'].'_userArchives';
|
||||
$codeCache = Cache::get($remark);
|
||||
if(empty($codeCache)){
|
||||
return $this->fail('验证码不存在');
|
||||
}
|
||||
if ($codeCache != $code) {
|
||||
return $this->fail('验证码错误');
|
||||
}
|
||||
}
|
||||
UserLogic::StoreAdd($params);
|
||||
if (UserLogic::hasError() ) {
|
||||
return $this->fail(UserLogic::getError());
|
||||
|
@ -6,10 +6,12 @@ namespace app\store\lists\cart;
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\Config;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
use app\common\model\user\User;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
|
||||
/**
|
||||
* 购物车列表
|
||||
@ -18,10 +20,9 @@ use app\common\model\store_product_unit\StoreProductUnit;
|
||||
*/
|
||||
class CartList extends BaseAdminDataLists implements ListsSearchInterface, ListsExtendInterface
|
||||
{
|
||||
|
||||
protected $total_price = 0;
|
||||
|
||||
|
||||
protected $activity_price = 0;
|
||||
protected $off_activity = 0;
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
@ -31,8 +32,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 购物车列表
|
||||
* @return array
|
||||
@ -43,27 +42,42 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
*/
|
||||
public function lists($where = []): array
|
||||
{
|
||||
$this->searchWhere[]=['staff_id','=',$this->adminId];
|
||||
$this->searchWhere[]=['is_pay','=',0];
|
||||
$list = Cart::where($this->searchWhere)
|
||||
->field('id,product_id,cart_num,store_id')
|
||||
$userId = $this->request->get('uid');
|
||||
$where = [
|
||||
'staff_id' => $this->adminId,
|
||||
'is_pay' => 0
|
||||
];
|
||||
$list = Cart::where($this->searchWhere)->where($where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) {
|
||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id'=>$item['store_id']])
|
||||
->field('product_id,image,price,store_name,unit')
|
||||
->find();
|
||||
if ($find) {
|
||||
$item['total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$item['image'] = $find['image'];
|
||||
$item['price'] = $find['price'];
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
}
|
||||
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$this->off_activity = $off_activity;
|
||||
foreach ($list as $key => &$item) {
|
||||
$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')
|
||||
->withTrashed()
|
||||
->find();
|
||||
|
||||
if ($find) {
|
||||
if($off_activity==1){
|
||||
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2);
|
||||
$item['price'] = $find['cost'];
|
||||
}else{
|
||||
$item['price'] = $find['price'];
|
||||
}
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
$item['image'] = $find['image'];
|
||||
$item['cost'] = $find['cost'];
|
||||
$item['store_name'] = $find['store_name'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
@ -75,11 +89,30 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Cart::where($this->searchWhere)->count();
|
||||
$userId = $this->request->userId;
|
||||
if (!$userId) return 0;
|
||||
$where = [
|
||||
'uid' => $userId,
|
||||
'is_pay' => 0
|
||||
];
|
||||
return Cart::where($this->searchWhere)->where($where)->count();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
// return ['total_price' => $this->total_price];
|
||||
$data = [
|
||||
'off_activity' => $this->off_activity,
|
||||
'total_price' => $this->total_price,
|
||||
'msg' => '',
|
||||
'pay_price' => $this->total_price
|
||||
];
|
||||
if ($this->off_activity == 1) {
|
||||
$data['pay_price'] = $this->activity_price;
|
||||
if ($this->activity_price < 500) {
|
||||
$data['msg'] = '还差' . bcsub(500, $this->activity_price, 2) . '元可获得10%品牌礼品券';
|
||||
$data['pay_price'] = $this->activity_price;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -54,8 +54,24 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
} elseif ($is_sashier == 2) { //小程序订单
|
||||
$this->searchWhere[] = ['pay_type', 'in', [7, 3, 18,19]];
|
||||
}
|
||||
return StoreOrder::where($this->searchWhere)
|
||||
->field(['id', 'order_id', 'pay_price', 'pay_time', 'pay_type', 'status', 'paid', 'total_num'])
|
||||
$status = $this->request->get('status','');
|
||||
switch ($status){
|
||||
case -1:
|
||||
$this->searchWhere[] = ['status', '=', 0];
|
||||
$this->searchWhere[] = ['paid', '=', 0];
|
||||
break;
|
||||
case 1:
|
||||
$this->searchWhere[] = ['status', '=', 1];
|
||||
$this->searchWhere[] = ['paid', '=', 1];
|
||||
break;
|
||||
case 2:
|
||||
$this->searchWhere[] = ['status', '=', 2];
|
||||
$this->searchWhere[] = ['paid', '=', 1];
|
||||
break;
|
||||
}
|
||||
|
||||
return StoreOrder::where($this->searchWhere)->with(['user'])
|
||||
->field(['id', 'order_id', 'pay_price', 'pay_time','uid', 'pay_type', 'status', 'paid', 'total_num'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['id' => 'desc'])
|
||||
->select()->each(function ($item) use ($store_id) {
|
||||
|
@ -5,6 +5,7 @@ namespace app\store\lists\user;
|
||||
|
||||
|
||||
use app\common\model\store_finance_flow\StoreFinanceFlow;
|
||||
use app\common\model\user_sign\UserSign;
|
||||
use app\store\lists\BaseAdminDataLists;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserShip;
|
||||
@ -50,6 +51,8 @@ class UserLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$data['return_money'] = StoreFinanceFlow::
|
||||
where(['user_id'=>$data['id'],'status'=>0,'financial_pm'=>0])
|
||||
->sum('number');
|
||||
$data['amount_frozen'] = UserSign::where('uid',$data['id'])->where('status',0)->sum('number');
|
||||
$data['get_frozen'] = UserSign::where('uid',$data['id'])->where('status',1)->sum('number');
|
||||
|
||||
})->toArray();
|
||||
return $lists;
|
||||
|
@ -36,6 +36,7 @@ use app\common\model\user_recharge\UserRecharge;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use app\statistics\logic\OrderLogic;
|
||||
use app\statistics\logic\OrderLogic;
|
||||
|
||||
|
||||
/**
|
||||
@ -84,7 +85,7 @@ class WorkbenchLogic extends BaseLogic
|
||||
$data['income_amount'] = StoreFinanceFlow::where($storeFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');
|
||||
//门店收款金额
|
||||
$all_where['paid'] = 1;
|
||||
$data['receipt_amount'] = OrderLogic::dayPayPrice($all_where);
|
||||
$data['receipt_amount'] = OrderLogic::dayPayPrice($all_where,date('Y-m-d',time()));
|
||||
// $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price');
|
||||
//保证金金额
|
||||
$data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number');
|
||||
|
Loading…
x
Reference in New Issue
Block a user