Browse Source

商家明细

master
Lemon 5 years ago
parent
commit
f6f20397de
  1. 21
      app/Controller/v3/BalanceStatementController.php
  2. 7
      app/Controller/v3/CollectStoreController.php
  3. 101
      app/Model/v3/FinancialRecord.php
  4. 5
      app/Model/v3/Market.php
  5. 15
      app/Service/v3/Implementations/CollectStoreService.php
  6. 28
      app/Service/v3/Implementations/RevenueListService.php
  7. 2
      app/Service/v3/Interfaces/CollectStoreServiceInterface.php
  8. 14
      app/Service/v3/Interfaces/RevenueListServiceInterface.php
  9. 1
      config/autoload/dependencies.php
  10. 2
      config/routes.php

21
app/Controller/v3/BalanceStatementController.php

@ -0,0 +1,21 @@
<?php
namespace App\Controller\v3;
use App\Controller\BaseController;
use Hyperf\Di\Annotation\Inject;
use App\Service\v3\Interfaces\RevenueListServiceInterface;
class BalanceStatementController extends BaseController
{
/**
* @Inject
* @var RevenueListServiceInterface
*/
protected $revenueListService;
public function getRevenueListByUser()
{
$params = $this->request->all();
return $this->success($this->revenueListService->check(46));
}
}

7
app/Controller/v3/CollectStoreController.php

@ -28,4 +28,11 @@ class CollectStoreController extends BaseController
}
return $this->success($res);
}
public function getListByUser()
{
$params = $this->request->all();
$res = $this->collectStoreService->getListByUser($params['user_id']);
return $this->success($res);
}
}

101
app/Model/v3/FinancialRecord.php

@ -0,0 +1,101 @@
<?php
declare (strict_types=1);
namespace App\Model\v3;
use App\Model\Model;
/**
*/
class FinancialRecord extends Model
{
/**
* 当面付商户首单奖励限制的订单金额
*/
const OFL_FIRST_AWARD_LIMIT_AMOUNT = 3;
/**
* 虚拟账户
*/
const ACCOUNT_LEDGER = -1;
/**
* 账户类型
*
* 总账
* USER_TYPE_LEDGER / -1
*
* 用户
* USER_TYPE_USER / 1
*
* MP用户账户,服务商、市场经理、服务站点等
* USER_TYPE_MP / 2
* USER_TYPE_MM / 3
* USER_TYPE_CS / 4
*
* 商户账户
* USER_TYPE_STORE / 5
*/
const USER_TYPE_LEDGER = -1;
const USER_TYPE_USER = 1;
const USER_TYPE_MP = 2;
const USER_TYPE_MM = 3;
const USER_TYPE_CS = 4;
const USER_TYPE_STORE = 5;
/**
* 关联类型
*
* 订单
* SOURCE_TYPE_ORDER / 1
*/
const SOURCE_TYPE_ORDER = 1;
/**
* 流水类型,大的分类,<100是奖励分账等收入项 >=100是提现消费等支出项
*/
const MONEY_TYPE_CS_PLAT_NEW_USER = 1; // 社区服务点新用户奖励(线上订单完成)
const MONEY_TYPE_CS_FIRST_ORDER = 2; // 社区服务点新用户线上首单奖励(线上订单完成)
const MONEY_TYPE_CS_OL_ORDER = 3; // 社区服务点用户线上订单分账(线上订单完成)
const MONEY_TYPE_STORE_PLAT_NEW_USER = 4; // 商户平台新用户奖励
const MONEY_TYPE_STORE_FIRST_ORDER = 5; // 商户当日首单奖励
const MONEY_TYPE_STORE_OL_ORDER_COMP = 6; // 商户线上订单完成收入
const MONEY_TYPE_STORE_OFL_ORDER_COMP = 7; // 商户线下订单完成收入
const MONEY_TYPE_USER_OL_ORDER_REFUND = 8; // 用户线上订单退款
const MONEY_TYPE_USER_OFL_ORDER = 100; // 用户线下支付订单
const MONEY_TYPE_USER_OL_ORDER = 101; // 用户线上支付订单
/**
* 状态
*/
const STATUS_NORMAL = 1;
const STATUS_ABNORMAL = 2;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'lanzu_financial_record';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'user_type',
'money',
'money_type',
'source_id',
'source_type',
'desc',
'comment',
'status',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [];
}

5
app/Model/v3/Market.php

@ -7,4 +7,9 @@ use App\Model\Model;
class Market extends Model
{
protected $table = 'lanzu_market';
public function stores()
{
return $this->hasMany(Store::class,'market_id','id');
}
}

15
app/Service/v3/Implementations/CollectStoreService.php

@ -1,9 +1,12 @@
<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\Market;
use App\Model\v3\Store;
use App\Service\v3\Interfaces\CollectStoreServiceInterface;
use App\Constants\v3\SsdbKeys;
use App\TaskWorker\SSDBTask;
use Hyperf\DbConnection\Db;
use Hyperf\Utils\ApplicationContext;
class CollectStoreService implements CollectStoreServiceInterface
@ -51,4 +54,16 @@ class CollectStoreService implements CollectStoreServiceInterface
$count = $ssdb->exec('get',SsdbKeys::COUNT_COLLECT_STORE.$storeId);
return $count;
}
public function getListByUser($userId)
{
$marketIds = Db::table('lanzu_user_collection')->where('user_id',$userId)->pluck('market_id')->toArray();
$storeIds = Db::table('lanzu_user_collection')->where('user_id',$userId)->pluck('store_id')->toArray();
$res = Market::query()->with(['stores' => function($query) use ($storeIds) {
$query->whereIn('lanzu_store.id',$storeIds);
}])
->whereIn('id',$marketIds)
->get();
return $res;
}
}

28
app/Service/v3/Implementations/RevenueListService.php

@ -0,0 +1,28 @@
<?php
namespace App\Service\v3\Implementations;
use App\Model\v3\FinancialRecord;
use App\Service\v3\Interfaces\RevenueListServiceInterface;
class RevenueListService implements RevenueListServiceInterface
{
public function do()
{
// TODO: Implement do() method.
}
public function check($userId)
{
$financialRecord = new FinancialRecord();
$mod = bcmod((string)$userId, '5', 0);
$financialRecord->suffix($mod);
return $financialRecord::query()->get();
}
public function undo()
{
// TODO: Implement undo() method.
}
}

2
app/Service/v3/Interfaces/CollectStoreServiceInterface.php

@ -13,4 +13,6 @@ interface CollectStoreServiceInterface
public function countByUser($userId);
public function countByStore($storeId);
public function getListByUser($userId);
}

14
app/Service/v3/Interfaces/RevenueListServiceInterface.php

@ -0,0 +1,14 @@
<?php
namespace App\Service\v3\Interfaces;
interface RevenueListServiceInterface
{
public function do();
public function check($userId);
public function undo();
}

1
config/autoload/dependencies.php

@ -61,4 +61,5 @@ return [
\App\Service\v3\Interfaces\TabsServiceInterface::class => \App\Service\v3\Implementations\TabsService::class,
\App\Service\v3\Interfaces\LocationServiceInterface::class => \App\Service\v3\Implementations\LocationService::class,
\App\Service\v3\Interfaces\GoodsActivityServiceInterface::class => \App\Service\v3\Implementations\GoodsActivityService::class,
\App\Service\v3\Interfaces\RevenueListServiceInterface::class => \App\Service\v3\Implementations\RevenueListService::class,
];

2
config/routes.php

@ -112,4 +112,6 @@ Router::addGroup('/v3/', function () {
Router::post('home/storeIndex', 'App\Controller\v3\HomeController@storeIndex');
Router::post('orderList/onlineForStore', 'App\Controller\v3\OrderListController@onlineForStore');
Router::post('orderList/offlineForStore', 'App\Controller\v3\OrderListController@offlineForStore');
Router::post('collectStore/getListByUser', 'App\Controller\v3\CollectStoreController@getListByUser');
Router::post('balanceStatement/getRevenueListByUser', 'App\Controller\v3\BalanceStatementController@getRevenueListByUser');
},['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]);
Loading…
Cancel
Save