123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace app\expand\controller;
- use app\common\service\HelperService;
- use think\Validate;
- /**
- * 销售数据
- * Class Sales
- * @package app\expand\controller
- */
- class Sales extends BaseAuth
- {
- private $_Account = null;
- private $_redisKey = 'sales_list';
- public function __construct(){
-
- parent::__construct();
- $this->_Account = $this->getKey($this->_apiCode);
- //验证是否具有访问这个接口的权限
- if(!isset($this->_Account['Sales'])){
- HelperService::returnJson(['code'=>400,'msg'=>'sales interface unauthorized access','data'=>[]]);
- }
- }
- /**
- * 入队列
- */
- public function pushSales(){
-
- $params = $this->_params;
- $rule = [
- 'company_no|集团编号'=>'require|max:100',
- 'store_no|门店编号'=>'require|max:100',
- 'sales_no|销售单号'=>'require|max:100',
- 'sales_detail|销售明细'=>'require|array',
- 'other|其他备注信息'=>'array'
- ];
- $validate = new Validate($rule);
- if(!$validate->check($params)){
- HelperService::returnJson(['code'=>400,'msg'=>$validate->getError(),'data'=>[]]);
- }
-
- if(!empty($params['detail'])){
- foreach($params['detail'] as $detail){
- if(!isset($detail['product_no']) || !isset($detail['sales_num']) || !isset($detail['is_refund'])){
- HelperService::returnJson(['code'=>400,'msg'=>"销售明细不合法",'data'=>[]]);
- }
- }
- }
-
- $this->connectionRedis();
- $this->_redisClient->lpush($this->_redisKey, json_encode($params));
- HelperService::returnJson(['code'=>200,'msg'=>'success','data'=>[]]);
- }
- }
|