diff --git a/app/admin/lists/warehouse_product/WarehouseProductLists.php b/app/admin/lists/warehouse_product/WarehouseProductLists.php index 3dd0c0f88..f63a3799e 100644 --- a/app/admin/lists/warehouse_product/WarehouseProductLists.php +++ b/app/admin/lists/warehouse_product/WarehouseProductLists.php @@ -29,7 +29,7 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt public function setSearch(): array { return [ - '=' => ['warehouse_id', 'product_id', 'financial_pm'], + '=' => ['warehouse_id', 'financial_pm','store_id'], ]; } @@ -52,12 +52,15 @@ class WarehouseProductLists extends BaseAdminDataLists implements ListsSearchInt ->select()->each(function ($item){ if($item->financial_pm==0){ $item->financial_pm_name='出库'; - if($item->store_id>0){ - $item->financial_pm_name='出库=>'.SystemStore::where('id',$item->store_id)->value('name'); - } }else{ $item->financial_pm_name='入库'; } + if($item->store_id>0){ + $item->system_store_name=SystemStore::where('id',$item->store_id)->value('name'); + }else{ + $item->system_store_name=''; + + } if($item->status==0){ $item->status_name='未确认'; }elseif($item->status==1){ diff --git a/app/admin/logic/warehouse_product/WarehouseProductLogic.php b/app/admin/logic/warehouse_product/WarehouseProductLogic.php index 3426c50c6..1a79b54e8 100644 --- a/app/admin/logic/warehouse_product/WarehouseProductLogic.php +++ b/app/admin/logic/warehouse_product/WarehouseProductLogic.php @@ -118,7 +118,7 @@ class WarehouseProductLogic extends BaseLogic $find = WarehouseProduct::where('id', $id)->find(); $find->status = 1; - $find->batch = WarehouseProduct::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id'], 'financial_pm' => $financial_pm])->count(); + $find->batch = WarehouseProduct::where(['product_id' => $find['product_id'], 'warehouse_id' => $find['warehouse_id'], 'financial_pm' => $financial_pm,'store_id'=>$find['store_id']])->count(); $find->save(); $storege = WarehouseProductStorege::where('warehouse_id', $find['warehouse_id'])->where('product_id', $find['product_id'])->find(); diff --git a/app/api/controller/product/ProductController.php b/app/api/controller/product/ProductController.php index 2d2e94f13..b7f5af617 100644 --- a/app/api/controller/product/ProductController.php +++ b/app/api/controller/product/ProductController.php @@ -33,7 +33,7 @@ class ProductController extends BaseApiController{ $this->request->__set('store_id',$store_id); return $this->dataLists(new StoreProductLists()); }else{ - return $this->dataLists(); + return $this->data(['lists'=>[]]); } } diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index e66171fde..bbc180b01 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -10,6 +10,7 @@ use app\api\service\UserTokenService; use app\api\validate\UserValidate; use app\common\enum\PayEnum; use app\common\logic\PaymentLogic; +use app\common\model\store_extract\StoreExtract; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user_ship\UserShip; @@ -43,11 +44,11 @@ class UserController extends BaseApiController if ($result === false) { return $this->fail(UserLogic::getError()); } - if($result && is_numeric($result)){ + if ($result && is_numeric($result)) { $data = UserLogic::info($result); $userInfo = UserTokenService::setToken($result, 1); $data['token'] = $userInfo['token']; - }else{ + } else { $data = UserLogic::info($this->userId); } @@ -67,7 +68,6 @@ class UserController extends BaseApiController public function info() { return $this->success('success', UserLogic::info($this->userId)); - } // #[ @@ -82,7 +82,7 @@ class UserController extends BaseApiController public function rechange_amount() { $res = UserLogic::rechange_level(); - return $this->success('ok',$res); + return $this->success('ok', $res); } // #[ @@ -120,19 +120,19 @@ class UserController extends BaseApiController // ] public function capital_flow() { - $page_no = (int)$this->request->post('page_no',1); - $page_size = (int)$this->request->post('page_size',15); + $page_no = (int)$this->request->post('page_no', 1); + $page_size = (int)$this->request->post('page_size', 15); $params['page_no'] = $page_no; $params['page_size'] = $page_size; - if(empty($page_no) || empty($page_size)){ + if (empty($page_no) || empty($page_size)) { $params['page_no'] = 1; $params['page_size'] = 15; } - $res = UserLogic::capital_list($this->userId,$params); + $res = UserLogic::capital_list($this->userId, $params); - $res['page_no'] =$params['page_no']; - $res['page_size'] =$params['page_size']; - return $this->success('ok',$res); + $res['page_no'] = $params['page_no']; + $res['page_size'] = $params['page_size']; + return $this->success('ok', $res); } // #[ @@ -147,13 +147,13 @@ class UserController extends BaseApiController public function capital_count() { $res = UserLogic::capital_count($this->userId); - return $this->success('ok',$res); + return $this->success('ok', $res); } public function send_sms() { $res = (new UserLogic())->dealSendSms($this->userId); - if ($res){ + if ($res) { return $this->success('发送成功'); } return $this->fail('发送失败'); @@ -164,11 +164,10 @@ class UserController extends BaseApiController { $params = (new UserValidate())->post()->goCheck('login'); $res = (new UserLogic())->dealLoginSms($params['account']); - if ($res){ + if ($res) { return $this->success('发送成功'); } return $this->fail('发送失败'); - } //报备 @@ -176,26 +175,25 @@ class UserController extends BaseApiController { $params = (new UserValidate())->post()->goCheck('login'); $res = (new UserLogic())->dealReportingSms($params['account']); - if ($res){ - return $this->success('发送成功',[],1,1); + if ($res) { + return $this->success('发送成功', [], 1, 1); } return $this->fail('发送失败'); - } - - + + public function set_payPassword() { $params = (new UserValidate())->post()->goCheck('setPayPassword'); - $remark = $this->userId.'_payPassword'; + $remark = $this->userId . '_payPassword'; $code = Cache::get($remark); if ($code && isset($params['code']) && $code !== $params['code']) { return $this->fail('验证码错误'); } if ($params['rePassword'] !== $params['password']) return $this->fail('两次密码不一致'); - $result = UserLogic::dealPayPassword($params,$this->userId); + $result = UserLogic::dealPayPassword($params, $this->userId); if (!$result) { return $this->fail('设置失败'); } @@ -205,24 +203,24 @@ class UserController extends BaseApiController //修改 -// public function withdrawalPassword() -// { -// $data = $this->request->params(['repassword', 'password', 'sms_code']); -// $sms_code = app()->make(SmsService::class)->checkSmsCode($this->user->phone, $data['sms_code'], 'change_pwd'); -// if (!$data['sms_code'] || !$sms_code) { -// return app('json')->fail('验证码不正确'); -// } -// if (!$this->user->phone) -// return app('json')->fail('请先绑定手机号'); -// if (empty($data['repassword']) || empty($data['password'])) -// return app('json')->fail('请输入提现密码'); -// if ($data['repassword'] !== $data['password']) -// return app('json')->fail('两次密码不一致'); -// $password = $this->repository->encodePassword($data['password']); -// $this->repository->update($this->request->uid(), ['withdrawal_pwd' => $password]); -// return app('json')->success('绑定成功'); -// -// } + // public function withdrawalPassword() + // { + // $data = $this->request->params(['repassword', 'password', 'sms_code']); + // $sms_code = app()->make(SmsService::class)->checkSmsCode($this->user->phone, $data['sms_code'], 'change_pwd'); + // if (!$data['sms_code'] || !$sms_code) { + // return app('json')->fail('验证码不正确'); + // } + // if (!$this->user->phone) + // return app('json')->fail('请先绑定手机号'); + // if (empty($data['repassword']) || empty($data['password'])) + // return app('json')->fail('请输入提现密码'); + // if ($data['repassword'] !== $data['password']) + // return app('json')->fail('两次密码不一致'); + // $password = $this->repository->encodePassword($data['password']); + // $this->repository->update($this->request->uid(), ['withdrawal_pwd' => $password]); + // return app('json')->success('绑定成功'); + // + // } //采购款明细、余额明细、礼品券明细、返还金明细 public function fundList() @@ -233,19 +231,18 @@ class UserController extends BaseApiController $params = $this->request->get(); $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 = 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 + 'integral' => $integral, + 'number' => $number, + 'get_number' => $GetNumber ]; return $this->success('ok', $res); - } /** @@ -255,39 +252,99 @@ class UserController extends BaseApiController { (new UserValidate())->get()->goCheck('fund'); $type = (int)$this->request->get('type', 1); - if($type==1){ + if ($type == 1) { return $this->dataLists(new UserSignLists()); - }else{ + } else { return $this->dataLists(new UserSignLogLists()); } - } /** * 用户信息 */ - public function other_user_info(){ - $mobile=$this->request->get('mobile'); - if($mobile){ - $user=User::where('mobile',$mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds,label_id')->find(); - if($user){ - $address=UserAddress::where('uid',$user['id'])->where('is_default',1)->find(); - if($address){ - $city_name=Db::name('geo_city')->where('city_code',$address['city'])->value('city_name'); - $area_name=Db::name('geo_area')->where('area_code',$address['area'])->value('area_name'); - $street_name=Db::name('geo_street')->where('street_code',$address['street'])->value('street_name'); - $village_name=Db::name('geo_village')->where('village_code',$address['village'])->value('village_name'); - $brigade_name=Db::name('geo_brigade')->where('id',$address['brigade'])->value('brigade_name'); - $address['address_like']=$city_name.$area_name.$street_name.$village_name.$brigade_name; + public function other_user_info() + { + $mobile = $this->request->get('mobile'); + if ($mobile) { + $user = User::where('mobile', $mobile)->field('id,avatar,real_name,nickname,mobile,user_ship,purchase_funds,label_id')->find(); + if ($user) { + $address = UserAddress::where('uid', $user['id'])->where('is_default', 1)->find(); + if ($address) { + $city_name = Db::name('geo_city')->where('city_code', $address['city'])->value('city_name'); + $area_name = Db::name('geo_area')->where('area_code', $address['area'])->value('area_name'); + $street_name = Db::name('geo_street')->where('street_code', $address['street'])->value('street_name'); + $village_name = Db::name('geo_village')->where('village_code', $address['village'])->value('village_name'); + $brigade_name = Db::name('geo_brigade')->where('id', $address['brigade'])->value('brigade_name'); + $address['address_like'] = $city_name . $area_name . $street_name . $village_name . $brigade_name; } - $user['ship_name']=$user['user_ship']>0?UserShip::where('id',$user['user_ship'])->value('title'):''; - $user['address_info']=$address; - return $this->success('ok',$user->toArray()); - }else{ - return $this->fail('用户不存在',[],0,0); + $user['ship_name'] = $user['user_ship'] > 0 ? UserShip::where('id', $user['user_ship'])->value('title') : ''; + $user['address_info'] = $address; + return $this->success('ok', $user->toArray()); + } else { + return $this->fail('用户不存在', [], 0, 0); } } - return $this->success('ok',[]); + return $this->success('ok', []); } + /** + * 提现信息 + */ + public function cash_info() + { + $info = User::where('id', $this->userId)->field('id,now_money')->find(); + $info['notes'] = '提现金额需大于1元,提现到微信零钱,并财务审核,审核通过后,提现金额将自动到账'; + return $this->data($info); + } + + /** + * 提交提现申请 + */ + public function cash_application() + { + $money = $this->request->post('money'); + $find = User::where('id', $this->userId)->find(); + if ($find &&$money > $find['now_money']) { + return $this->fail('提现金额不能大于余额'); + } + if ($money < 1) { + return $this->fail('提现金额不能小于1元'); + } + $data['uid'] = $this->userId; + $data['create_time'] = time(); + $data['status'] = 0; + $data['extract_price'] =$money; + $data['balance'] =bcsub($find['now_money'],$money,2); + $data['before_balance'] =$find['now_money']; + $data['extract_type'] = 'wx'; + $res = StoreExtract::create($data); + if ($res) { + User::where('id', $this->userId)->dec('now_money', $money)->update(); + return $this->success('申请成功,等待审核'); + } else { + return $this->success('申请失败'); + } + } + + /** + * 提现申请记录 + */ + public function cash_record() + { + $list = StoreExtract::where('uid', $this->userId)->order('id desc') + ->field('id,extract_price price,status,pay_status,create_time') + ->select()->each(function ($item) { + if($item->status==-1){ + $item->status_name='未通过'; + }elseif($item->status==0){ + $item->status_name='审核中'; + }elseif($item->status==1){ + $item->status_name='已通过'; + } + $item->title='申请提现'.$item->price.'元'; + $item->pay_status_name=$item->status==1?'已打款':'未打款'; + + })->toArray(); + return $this->data($list); + } } diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 8eb727c10..eafd5c873 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -129,6 +129,8 @@ class UserLogic extends BaseLogic $share_name=SystemStore::where('id',4)->value('abbreviation'); } $data['share_name']= $share_name.'No.'.preg_replace('/4/','*', $data['id']); + + $data['system_store_id']=SystemStoreStaff::where('uid',$uid)->value('store_id'); }else{ $data = []; } diff --git a/composer.json b/composer.json index 79400ddac..134d77291 100644 --- a/composer.json +++ b/composer.json @@ -62,6 +62,9 @@ "ext-event": "For better performance. " }, "autoload": { + "psr-0": { + "": "extend/" + }, "psr-4": { "": "./", "app\\": "./app", @@ -83,4 +86,4 @@ "support\\Plugin::uninstall" ] } -} +} \ No newline at end of file diff --git a/extend/liankenet/CloudPrinter.php b/extend/liankenet/CloudPrinter.php new file mode 100644 index 000000000..d15f51229 --- /dev/null +++ b/extend/liankenet/CloudPrinter.php @@ -0,0 +1,178 @@ +api_key = $api_key; + $this->timeout = $timeout; + $this->device_id = $device_id; + $this->device_key = $device_key; + $this->debug = $debug; + } + + private function requests($method, $endpoint, $fields = array(), $content_type = 'application/json') + { + if ($method == 'POST' && $content_type == 'application/json') { + $fields = json_encode($fields); + } + $curl = curl_init(); + + $headers = array( + "ApiKey: " . $this->api_key + ); + if ($method == "POST") { + array_push($headers, 'Content-Type: ' . $content_type); + } + + curl_setopt_array($curl, array( + CURLOPT_URL => $this->server . $endpoint, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_MAXREDIRS => 1, + CURLOPT_TIMEOUT => $this->timeout, + CURLOPT_FOLLOWLOCATION => true, + CURLINFO_HEADER_OUT => $this->debug, + CURLOPT_VERBOSE => $this->debug, + CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_POSTFIELDS => $fields, + CURLOPT_HTTPHEADER => $headers, + )); + + $response = curl_exec($curl); + + $info = curl_getinfo($curl); + if ($this->debug) { + print_r($info); + } + + if (false === $response) { + die(curl_error($curl)); + throw new Exception(curl_error($curl), curl_errno($curl)); + } else if ($info['http_code'] != 200) { + throw new HttpException(curl_error($curl), $info['http_code']); + } + $data = json_decode($response); + if ($data->code != 200) { + throw new ApiException($data->msg, $data->code); + } + return $data; + } + + public function getDeviceInfo() + /* + * 设备信息 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + ); + $response = $this->requests("GET", 'api/device/device_info?' . http_build_query($data)); + return $response->data; + } + + public function asyncRefreshDeviceInfo() + /* + * 异步刷新设备信息,包括打印机信息 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + ); + $response = $this->requests("GET", 'api/device/async_refresh_device_info?' . http_build_query($data)); + return $response; + } + + public function getPrinterList() + /* + * 打印机列表 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + ); + $response = $this->requests("GET", 'api/external_api/printer_list?' . http_build_query($data)); + return $response->data->row; + } + + public function getPrinterParams($printer_model) + /** + * 打印参数 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + "printerModel" => $printer_model, + ); + $response = $this->requests("GET", 'api/print/printer_params?' . http_build_query($data)); + return $response->data; + } + + public function addJob($device_port, $printer_model, $paper_size, $file, $optional_array = array()) + /* + * 发起打印任务 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + "devicePort" => $device_port, + "printerModel" => $printer_model, + "dmPaperSize" => $paper_size, + "jobFile" => $file + ); + $data = array_merge($data, $optional_array); + $response = $this->requests("POST", 'api/print/job', $data, "multipart/form-data"); + return $response->data; + } + + public function getJobStatus($device_port, $task_id) + /* + * 获取任务状态 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + "devicePort" => $device_port, + "task_id" => $task_id, + ); + $response = $this->requests("GET", 'api/print/job?' . http_build_query($data)); + return $response->data; + } + + public function cancelJob($device_port, $task_id) + /* + * 取消任务 + */ + { + $data = array( + "deviceId" => $this->device_id, + "deviceKey" => $this->device_key, + "devicePort" => $device_port, + "task_id" => $task_id, + ); + $response = $this->requests("DELETE", 'api/print/job?' . http_build_query($data)); + return $response; + } +} \ No newline at end of file diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index be11dd8ff..0fb2bbd39 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -8,4 +8,5 @@ $baseDir = dirname($vendorDir); return array( 'Pimple' => array($vendorDir . '/pimple/pimple/src'), 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), + '' => array($baseDir . '/extend'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 2bed12016..490c635f7 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -683,6 +683,10 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc ), ); + public static $fallbackDirsPsr0 = array ( + 0 => __DIR__ . '/../..' . '/extend', + ); + public static $classMap = array ( 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', 'CURLStringFile' => __DIR__ . '/..' . '/symfony/polyfill-php81/Resources/stubs/CURLStringFile.php', @@ -714,6 +718,7 @@ class ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc $loader->prefixDirsPsr4 = ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc::$prefixDirsPsr4; $loader->fallbackDirsPsr4 = ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc::$fallbackDirsPsr4; $loader->prefixesPsr0 = ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc::$prefixesPsr0; + $loader->fallbackDirsPsr0 = ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc::$fallbackDirsPsr0; $loader->classMap = ComposerStaticInitcefecbcff919f3c1c8084830bbb72adc::$classMap; }, null, ClassLoader::class);