Browse Source
Merge branch 'develop' of http://120.24.33.109:11081/hyzjshwo/mp_lanzu_cat into develop
master
Merge branch 'develop' of http://120.24.33.109:11081/hyzjshwo/mp_lanzu_cat into develop
master
188 changed files with 14424 additions and 834 deletions
-
8.gitignore
-
1Envoy.blade.php
-
39app/Admin/Actions/Grid/GoodsCopy.php
-
58app/Admin/Actions/ModifyOrderState.php
-
78app/Admin/Actions/Show/OrderDetail.php
-
76app/Admin/Actions/Tree/CategoryTie.php
-
12app/Admin/Common/Auth.php
-
41app/Admin/Common/FinancialRecord.php
-
47app/Admin/Common/Images.php
-
32app/Admin/Common/Rpc.php
-
63app/Admin/Common/Sms.php
-
122app/Admin/Common/StoreQRCode.php
-
80app/Admin/Controllers/CouponSettingController.php
-
8app/Admin/Controllers/CouponTieController.php
-
28app/Admin/Controllers/HomeController.php
-
38app/Admin/Controllers/ImsCjdcMarketController.php
-
126app/Admin/Controllers/ImsCjdcOrderMainController.php
-
8app/Admin/Controllers/ImsCjdcStoreController.php
-
23app/Admin/Controllers/LanzuCsInfoController.php
-
2app/Admin/Controllers/LanzuCsWithdrawController.php
-
19app/Admin/Controllers/LanzuFinancialRecord.php
-
82app/Admin/Controllers/LanzuMmInfoController.php
-
44app/Admin/Controllers/LanzuMmWithdrawController.php
-
98app/Admin/Controllers/LanzuMpInfoController.php
-
59app/Admin/Controllers/LanzuMpWithdrawController.php
-
88app/Admin/Controllers/LanzuServiceHorsemanController.php
-
92app/Admin/Controllers/Test.php
-
39app/Admin/Controllers/Type.php
-
120app/Admin/Controllers/v3/BannersController.php
-
92app/Admin/Controllers/v3/CategoryController.php
-
250app/Admin/Controllers/v3/CouponController.php
-
86app/Admin/Controllers/v3/CouponSettingController.php
-
206app/Admin/Controllers/v3/GoodsActivityController.php
-
97app/Admin/Controllers/v3/GoodsCategoryController.php
-
226app/Admin/Controllers/v3/GoodsController.php
-
282app/Admin/Controllers/v3/StoreController.php
-
48app/Admin/Extensions/CheckRow.php
-
16app/Admin/Extensions/OrderDetail.php
-
100app/Admin/Extensions/OrderPrint.php
-
69app/Admin/Extensions/OrderStateHandle.php
-
73app/Admin/Forms/CategoryTieForm.php
-
105app/Admin/Forms/GoodsCopyForm.php
-
57app/Admin/Forms/SelectHorseman.php
-
41app/Admin/Metrics/Examples/Community/TotalAmount.php
-
3app/Admin/Metrics/Examples/Community/TotalCommunity.php
-
2app/Admin/Metrics/Examples/Community/TotalUser.php
-
15app/Admin/Metrics/Examples/ServiceCard/TotalMm.php
-
14app/Admin/Metrics/Examples/ServiceCard/TotalMp.php
-
44app/Admin/Metrics/Examples/ServiceCard/TotalStore.php
-
6app/Admin/Repositories/ImsCjdcMarket.php
-
11app/Admin/Repositories/ImsCjdcOrderMain.php
-
16app/Admin/Repositories/LanzuServiceHorseman.php
-
8app/Admin/Repositories/StoreUserReport.php
-
16app/Admin/Repositories/v3/Banners.php
-
60app/Admin/Repositories/v3/Coupon.php
-
4app/Admin/Repositories/v3/CouponSetting.php
-
16app/Admin/Repositories/v3/Goods.php
-
16app/Admin/Repositories/v3/GoodsActivity.php
-
16app/Admin/Repositories/v3/GoodsCategory.php
-
16app/Admin/Repositories/v3/Store.php
-
73app/Admin/bootstrap.php
-
27app/Admin/routes.php
-
45app/Console/Commands/EsTest.php
-
54app/Console/Commands/GenEsDicts.php
-
79app/Console/Commands/MigrateMarketData.php
-
146app/Console/Commands/MigrateOrder.php
-
80app/Console/Commands/MigrateOrderGoods.php
-
96app/Console/Commands/MigrateOrderMain.php
-
72app/Console/Commands/MigrateUserAddr.php
-
66app/Console/Commands/OnlineOrderStatis.php
-
65app/Console/Commands/SetGoodsMarketId.php
-
84app/Console/Commands/SetStoreBalance.php
-
71app/Console/Commands/setStoreUsers.php
-
2app/Console/Kernel.php
-
52app/Http/Controllers/TestController.php
-
338app/Libs/feier_print/api_php_demo.php
-
307app/Libs/feier_print/httpclient.php
-
46app/Libs/feier_print/飞鹅云打印说明文档.txt
-
1app/Models/AdminUsers.php
-
16app/Models/CouponSetting.php
-
11app/Models/EsDict.php
-
14app/Models/Feprint.php
-
17app/Models/ImsCjdcMarket.php
-
3app/Models/ImsCjdcOrder.php
-
44app/Models/ImsCjdcOrderMain.php
-
2app/Models/ImsCjdcStore.php
-
35app/Models/ImsCjdcUser.php
-
56app/Models/LanzuGoods.php
-
47app/Models/LanzuMmInfo.php
-
2app/Models/LanzuMpInfo.php
-
30app/Models/LanzuServiceHorseman.php
-
12app/Models/LanzuStore.php
-
4app/Models/MpBalance.php
-
5app/Models/StoreAccount.php
-
15app/Models/storeUserReport.php
-
72app/Models/v3/Banners.php
-
81app/Models/v3/Category.php
-
158app/Models/v3/Coupon.php
-
33app/Models/v3/CouponReceiveType.php
-
60app/Models/v3/CouponSetting.php
@ -0,0 +1,39 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Grid; |
|||
|
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use Dcat\Admin\Form; |
|||
use App\Models\v3\Goods as GoodsModel; |
|||
use App\Admin\Forms\GoodsCopyForm; |
|||
|
|||
class GoodsCopy extends RowAction |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '复制'; |
|||
|
|||
public function render() |
|||
{ |
|||
$id = $this->getKey(); |
|||
|
|||
$modal = Modal::make() |
|||
->xl() |
|||
->title($this->title) |
|||
->body(GoodsCopyForm::make()->setKey($id)) |
|||
->button($this->title); |
|||
|
|||
return $modal; |
|||
} |
|||
|
|||
public function parameters() |
|||
{ |
|||
|
|||
return [ |
|||
|
|||
]; |
|||
} |
|||
} |
|||
@ -0,0 +1,58 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions; |
|||
|
|||
use Dcat\Admin\Actions\Action; |
|||
use Dcat\Admin\Actions\Response; |
|||
use Dcat\Admin\Traits\HasPermissions; |
|||
use Illuminate\Contracts\Auth\Authenticatable; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class ModifyOrderState extends Action |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '状态'; |
|||
|
|||
/** |
|||
* Handle the action request. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
// dump($this->getKey());
|
|||
|
|||
return $this->response()->success('Processed successfully.')->redirect('/'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|array|void |
|||
*/ |
|||
public function confirm() |
|||
{ |
|||
// return ['Confirm?', 'contents'];
|
|||
} |
|||
|
|||
/** |
|||
* @param Model|Authenticatable|HasPermissions|null $user |
|||
* |
|||
* @return bool |
|||
*/ |
|||
protected function authorize($user): bool |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
protected function parameters() |
|||
{ |
|||
return []; |
|||
} |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Show; |
|||
|
|||
use Dcat\Admin\Actions\Response; |
|||
use Dcat\Admin\Show\AbstractTool; |
|||
use Dcat\Admin\Traits\HasPermissions; |
|||
use Illuminate\Contracts\Auth\Authenticatable; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class OrderDetail extends AbstractTool |
|||
{ |
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '订单订单详情'; |
|||
|
|||
/** |
|||
* Handle the action request. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
dd($this->getKey()); |
|||
|
|||
return $this->response() |
|||
->success('Processed successfully.') |
|||
->redirect('/'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|void |
|||
*/ |
|||
protected function href() |
|||
{ |
|||
return admin_url('auth/users'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|array|void |
|||
*/ |
|||
public function confirm() |
|||
{ |
|||
return ['Confirm?', 'contents']; |
|||
} |
|||
|
|||
/** |
|||
* @param Model|Authenticatable|HasPermissions|null $user |
|||
* |
|||
* @return bool |
|||
*/ |
|||
protected function authorize($user): bool |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
// 如果你想自定义动作按钮的HTML,可以重写此方法
|
|||
public function html() |
|||
{ |
|||
|
|||
return view('orderdetail'); |
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
/** |
|||
* @return array |
|||
*/ |
|||
protected function parameters() |
|||
{ |
|||
return []; |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Actions\Tree; |
|||
|
|||
use Dcat\Admin\Actions\Response; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Traits\HasPermissions; |
|||
use Dcat\Admin\Tree\AbstractTool; |
|||
use Illuminate\Contracts\Auth\Authenticatable; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Illuminate\Http\Request; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
|
|||
class CategoryTie extends AbstractTool |
|||
{ |
|||
|
|||
/** |
|||
* @return string |
|||
*/ |
|||
protected $title = '绑定分类到首页导航'; |
|||
|
|||
/** |
|||
* Handle the action request. |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
return $this->response() |
|||
->success('跳转到绑定页面' ) |
|||
->redirect('/categoryTie'); |
|||
} |
|||
|
|||
/** |
|||
* @return string|void |
|||
*/ |
|||
// public function href()
|
|||
// {
|
|||
// return admin_url('category/tie');
|
|||
// }
|
|||
|
|||
/** |
|||
* @return string|array|void |
|||
*/ |
|||
public function confirm() |
|||
{ |
|||
// return ['Confirm?', 'contents'];
|
|||
} |
|||
|
|||
// protected function actionScript()
|
|||
// {
|
|||
|
|||
// return <<<JS
|
|||
// function (data, target, action) {
|
|||
// console.log('发起请求之前', data, target, action);
|
|||
|
|||
// // return false; 在这里return false可以终止执行后面的操作
|
|||
|
|||
// // 更改传递到接口的主键值
|
|||
// action.options.key = 123;
|
|||
// }
|
|||
// JS;
|
|||
// }
|
|||
|
|||
/** |
|||
* @param Model|Authenticatable|HasPermissions|null $user |
|||
* |
|||
* @return bool |
|||
*/ |
|||
protected function authorize($user): bool |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Common; |
|||
|
|||
|
|||
use Dcat\Admin\Controllers\AdminController; |
|||
|
|||
class FinancialRecord extends AdminController |
|||
{ |
|||
/** |
|||
* @param $form |
|||
* @param $adminUserId |
|||
* @param $userType |
|||
* @param $mType |
|||
* @param $desc |
|||
* @param $comment |
|||
*/ |
|||
public static function addFinancialRecord($adminUserId,$userType,$money,$mType,$desc,$comment) |
|||
{ |
|||
//添加流水记录
|
|||
$model = \App\Models\FinancialRecord::getFinancialRecordModel($adminUserId); |
|||
$model->user_id = $adminUserId; |
|||
$model->user_type = $userType; |
|||
$model->money = $money; |
|||
$model->money_type = $mType; |
|||
$model->desc = $desc; |
|||
$model->comment = $comment; |
|||
$model->save(); |
|||
|
|||
//添加公司流水
|
|||
$model = new \App\Models\LanzuFinancialRecord(); |
|||
$model->user_id = -1; |
|||
$model->user_type = -1; |
|||
$model->money = $money; |
|||
$model->money_type = $mType; |
|||
$model->desc = $desc; |
|||
$model->comment = $comment; |
|||
$model->save(); |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Common; |
|||
|
|||
|
|||
use Graze\GuzzleHttp\JsonRpc\Client; |
|||
|
|||
class Rpc |
|||
{ |
|||
|
|||
const SEPARATE_ACCOUNTS = "/separateaccounts/orderOnlineCompleted"; |
|||
|
|||
|
|||
/** |
|||
* 订单完成时分账流水 |
|||
* @param $oid |
|||
* @param $uid |
|||
* @return string |
|||
*/ |
|||
public static function separateAccounts($oid,$uid){ |
|||
$client = Client::factory(env('RPC_SITE_HOST')); |
|||
$request = $client->request( |
|||
uniqid(), |
|||
self::SEPARATE_ACCOUNTS, |
|||
['orderMainId' => $oid,'userId'=>$uid]); |
|||
$response = $client->send($request); |
|||
return $response->getBody()->getContents(); |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Common; |
|||
|
|||
|
|||
use AlibabaCloud\Client\AlibabaCloud; |
|||
use AlibabaCloud\Client\Exception\ClientException; |
|||
use AlibabaCloud\Client\Exception\ServerException; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use Graze\GuzzleHttp\JsonRpc\Client; |
|||
|
|||
class Sms extends AdminController |
|||
{ |
|||
/** |
|||
* 发送短信 |
|||
* @throws ClientException |
|||
*/ |
|||
public static function sent($params) |
|||
{ |
|||
AlibabaCloud::accessKeyClient(env('ACCESS_KEY_ID'),env('ACCESS_SECRET')) |
|||
->regionId('cn-shenzhen') |
|||
->asDefaultClient(); |
|||
try { |
|||
$result = AlibabaCloud::rpc() |
|||
->product('Dysmsapi') |
|||
->version('2017-05-25') |
|||
->action('SendSms') |
|||
->method('POST') |
|||
->host('dysmsapi.aliyuncs.com') |
|||
->options([ |
|||
'query' => $params, |
|||
]) |
|||
->request(); |
|||
dd($result); |
|||
}catch (ClientException $e){ |
|||
echo $e->getErrorMessage() . PHP_EOL; |
|||
}catch (ServerException $e){ |
|||
echo $e->getErrorMessage() . PHP_EOL; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 远程RPC调用 |
|||
* @param $phone |
|||
* @param $template |
|||
* @param $templateParams |
|||
* @param string $signName |
|||
* @return string |
|||
*/ |
|||
public static function rpcSent($phone, $template, $templateParams, $signName='懒族生活') |
|||
{ |
|||
$client = Client::factory(env('RPC_SITE_HOST')); |
|||
$request = $client->request(uniqid(),'/alisms/sent', [ |
|||
'phone' => $phone, |
|||
'template'=>$template, |
|||
'templateParams'=> json_encode($templateParams), |
|||
'signName'=>$signName, |
|||
]); |
|||
$response = $client->send($request); |
|||
return $response->getBody()->getContents(); |
|||
} |
|||
} |
|||
@ -0,0 +1,122 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Common; |
|||
|
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use EasyWeChat\Factory; |
|||
use Intervention\Image\ImageManager; |
|||
|
|||
class StoreQRCode extends AdminController |
|||
{ |
|||
protected $images; |
|||
protected $imageManager; |
|||
|
|||
public function __construct() |
|||
{ |
|||
$this->images = new Images(); |
|||
// $this->imageManager = new ImageManager();
|
|||
} |
|||
|
|||
/** |
|||
* 生成小程序码 永久 还没完成 |
|||
* @param $scene 参数 |
|||
* @param $optional |
|||
*/ |
|||
public function getUnlimited(string $scene, array $optional = []) |
|||
{ |
|||
$wxCode = Factory::payment(config('wechat.mini_program.default')); |
|||
$res = $wxCode->app_code->getUnlimited($scene,$optional); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 生成店铺的微信小程序码 |
|||
*/ |
|||
public function SetStoreWeChatCode($id) |
|||
{ |
|||
$codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/takeout/takeoutindex'); |
|||
$storeImgPath = 'QR_code/code_store_img/wx_store_'.$id.'.jpg'; |
|||
$res = $this->images->uploadOss($codeStore,$storeImgPath); |
|||
if($res){ |
|||
return ['status' => true ,'path' => $storeImgPath]; |
|||
}else{ |
|||
return ['status' => false ,'path' => '']; |
|||
} |
|||
} |
|||
/** |
|||
* 生成店铺收银的微信二维码 |
|||
*/ |
|||
public function SetPayWeChatCode($id) |
|||
{ |
|||
// $isCREATE = env('IS_CREATE_WECHAT_MINI_QR_CODE',1);
|
|||
// if($isCREATE == 0){
|
|||
$codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/seller/fukuan'); |
|||
$storeImgPath = 'QR_code/code_minipay_img/wx_minipay_'.$id.'.jpg'; |
|||
// }else{
|
|||
// $codeStore = $this->images->createWeChatQrCode('?scene='.$id,'zh_cjdianc/pages/seller/fukuan');
|
|||
// $storeImgPath = 'QR_code/code_pay_img/wx_pay_'.$id.'.jpg';
|
|||
// // 裁剪
|
|||
|
|||
// }
|
|||
|
|||
// 裁剪测试
|
|||
// $this->imageManager->make()->resize(270,270)->insert($codeStore);
|
|||
|
|||
$res = $this->images->uploadOss($codeStore,$storeImgPath); |
|||
if($res){ |
|||
return ['status' => true ,'path' => $storeImgPath]; |
|||
}else{ |
|||
return ['status' => false ,'path' => '']; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 店铺收银码裁剪 |
|||
*/ |
|||
public function setStoreCodeImg($file_path,$storeId){ |
|||
|
|||
$save_path = './QR_code/wx_store_pay_cut/wx_pay_'.$storeId.'.jpg'; |
|||
|
|||
if(!file_exists($save_path)){ |
|||
//将图片进行裁剪
|
|||
if(file_exists($file_path)){ |
|||
$save_width = 270; |
|||
$start_spot_x = 5; |
|||
$start_spot_y = 5; |
|||
$width = 270; |
|||
$height = 270; |
|||
|
|||
$this->tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,1); |
|||
}else{ |
|||
return ''; |
|||
} |
|||
} |
|||
return $save_path; |
|||
} |
|||
|
|||
/** |
|||
* 裁剪图片 |
|||
*/ |
|||
public function tailoringImg($save_path,$file_path,$save_width,$start_spot_x,$start_spot_y,$width,$height,$display=1) |
|||
{ |
|||
if(file_exists($file_path) && is_readable($file_path)){ |
|||
//从字符串中的图像流新建一图像
|
|||
$src = imagecreatefromstring(file_get_contents($file_path)); |
|||
|
|||
//保存图片的高
|
|||
$save_height = round($save_width*$height/$width); |
|||
|
|||
//根据要保存的宽和高创建图片
|
|||
$new_image = imagecreatetruecolor($save_width, $save_height); |
|||
|
|||
//生成最后的图片
|
|||
imagecopyresampled($new_image, $src, 0, 0, $start_spot_x, $start_spot_y, $save_width, $save_height, $width, $height); |
|||
|
|||
// header('Content-Type: image/jpeg');
|
|||
imagejpeg($new_image,$save_path); |
|||
imagedestroy($src); |
|||
imagedestroy($new_image); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -1,80 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Repositories\CouponSetting; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
|
|||
class CouponSettingController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new CouponSetting(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->name; |
|||
$grid->category; |
|||
$grid->value; |
|||
$grid->desc; |
|||
$grid->sort; |
|||
$grid->status; |
|||
$grid->created_at; |
|||
$grid->updated_at->sortable(); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new CouponSetting(), function (Show $show) { |
|||
$show->id; |
|||
$show->name; |
|||
$show->category; |
|||
$show->value; |
|||
$show->desc; |
|||
$show->sort; |
|||
$show->status; |
|||
$show->created_at; |
|||
$show->updated_at; |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new CouponSetting(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('name'); |
|||
$form->text('category'); |
|||
$form->text('value'); |
|||
$form->text('desc'); |
|||
$form->text('sort'); |
|||
$form->text('status'); |
|||
|
|||
$form->display('created_at'); |
|||
$form->display('updated_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,126 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Extensions\CheckRow; |
|||
use App\Admin\Extensions\CouponTieEdit; |
|||
use App\Admin\Extensions\OrderDetail; |
|||
use App\Admin\Extensions\OrderPrint; |
|||
use App\Admin\Extensions\OrderStateHandle; |
|||
use App\Admin\Forms\CouponTieForm; |
|||
use App\Admin\Repositories\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController;; |
|||
|
|||
class ImsCjdcOrderMainController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) { |
|||
//>>1.只展示线上订单打√
|
|||
//>>2.不同服务站只能看到自己的市场订单
|
|||
//>>3.订单不允许有添加,编辑,删除
|
|||
//>>4.订单状态变更√
|
|||
//>>5.打印功能
|
|||
//>6.退款
|
|||
$grid->paginate(10);//每页展示数据10条
|
|||
//$grid->id;
|
|||
//$grid->user_id('用户信息');
|
|||
$grid->column('nick_name','用户信息'); |
|||
$grid->order_num; |
|||
|
|||
$grid->state('订单状态') |
|||
->using(config('order.state')) |
|||
->label([1=>'dark',2=>'danger',3=>'indigo',4=>'success']); |
|||
$grid->money; |
|||
$grid->column('market.name','所属市场'); |
|||
$grid->pay_time('支付时间')->display(function (){ |
|||
return date('Y-m-d H:i:s'); |
|||
}); |
|||
$grid->created_at('下单时间')->display(function (){ |
|||
return date('Y-m-d H:i:s'); |
|||
}); |
|||
|
|||
$grid->actions(function (Grid\Displayers\Actions $actions) use ($grid){ |
|||
|
|||
$state = $actions->row->state; |
|||
if ($state==2){ |
|||
$actions->append(new OrderStateHandle('接单',3)); |
|||
}elseif ($state==311){ |
|||
$actions->append(new OrderStateHandle('完成',4)); |
|||
$actions->append(new OrderPrint('打印')); |
|||
}elseif ($state==3){ |
|||
$actions->append(new OrderPrint('打印')); |
|||
$actions->append(new CheckRow($actions->row->id,$grid->model()->getCurrentPage(),'自送')); |
|||
} |
|||
$actions->append(new OrderDetail('详情')); |
|||
}); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
|
|||
$grid->disableViewButton(); |
|||
$grid->disableEditButton(); |
|||
$grid->disableDeleteButton(); |
|||
|
|||
|
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) { |
|||
$show->id; |
|||
$show->user_id; |
|||
$show->order_num; |
|||
$show->state; |
|||
$show->time; |
|||
$show->pay_time; |
|||
$show->money; |
|||
$show->tools(function (Show\Tools $tools) { |
|||
$tools->append(new \App\Admin\Actions\Show\OrderDetail()); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new ImsCjdcOrderMain(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('user_id'); |
|||
$form->text('order_num'); |
|||
$form->text('state'); |
|||
$form->text('time'); |
|||
$form->text('pay_time'); |
|||
$form->text('money'); |
|||
}); |
|||
} |
|||
|
|||
|
|||
public function orderDetail() |
|||
{ |
|||
echo 111; |
|||
} |
|||
} |
|||
@ -0,0 +1,88 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
use App\Admin\Repositories\LanzuServiceHorseman; |
|||
use App\Models\ImsCjdcMarket; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
|
|||
class LanzuServiceHorsemanController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new LanzuServiceHorseman(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->name; |
|||
$grid->tel; |
|||
$grid->market_id('所属市场')->display(function (){ |
|||
return ImsCjdcMarket::find($this->market_id)->name; |
|||
}); |
|||
$grid->status('状态')->using([1=>'正常',-1=>'禁用']); |
|||
$grid->head_url->image('',50,50); |
|||
$grid->created_at->display(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new LanzuServiceHorseman(), function (Show $show) { |
|||
$show->id; |
|||
$show->user_id('懒ID'); |
|||
$show->name; |
|||
$show->tel; |
|||
$show->market_id('所属市场')->as(function (){ |
|||
return ImsCjdcMarket::find($this->market_id)->name; |
|||
}); |
|||
$show->status('状态')->using([1=>'正常',-1=>'禁用']); |
|||
$show->head_url->image(); |
|||
$show->created_at->as(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
$show->updated_at->as(function ($time){ |
|||
return date('Y-m-d H:i',$time); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new LanzuServiceHorseman(), function (Form $form) { |
|||
$form->display('id'); |
|||
$form->text('user_id','懒ID')->required(); |
|||
$form->text('name')->required(); |
|||
$form->mobile('tel')->required(); |
|||
$form->select('market_id','所属市场')->options(ImsCjdcMarket::getMarket())->required(); |
|||
$form->radio('status','状态')->options([1=>'启用',-1=>'禁用'])->value(1)->required(); |
|||
$form->image('head_url')->uniqueName()->required(); |
|||
|
|||
$form->display('created_at'); |
|||
$form->display('updated_at'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
|
|||
use AlibabaCloud\Client\AlibabaCloud; |
|||
use AlibabaCloud\Client\Exception\ClientException; |
|||
use AlibabaCloud\Client\Exception\ServerException; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use Graze\GuzzleHttp\JsonRpc\Client; |
|||
use Illuminate\Support\Facades\Log; |
|||
|
|||
class Test extends AdminController |
|||
{ |
|||
public function sentSms() |
|||
{ |
|||
$params = [ |
|||
'RegionId' => "cn-shenzhen", |
|||
'PhoneNumbers' => "13481194554", |
|||
'SignName' => "懒族生活", |
|||
'TemplateCode' => "SMS_201720790", |
|||
'TemplateParam' => json_encode(['name'=>'DESION','money'=>999]), |
|||
]; |
|||
AlibabaCloud::accessKeyClient(env('OSS_ACCESS_ID'),env('OSS_ACCESS_SECRET')) |
|||
->regionId('cn-shenzhen') |
|||
->asDefaultClient(); |
|||
|
|||
try { |
|||
$result = AlibabaCloud::rpc() |
|||
->product('Dysmsapi') |
|||
->version('2017-05-25') |
|||
->action('SendSms') |
|||
->method('POST') |
|||
->host('dysmsapi.aliyuncs.com') |
|||
->options([ |
|||
'query' => $params |
|||
]) |
|||
->request(); |
|||
dd($result); |
|||
}catch (ClientException $e){ |
|||
echo $e->getErrorMessage() . PHP_EOL; |
|||
}catch (ServerException $e){ |
|||
echo $e->getErrorMessage() . PHP_EOL; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
public function testRpc() |
|||
{ |
|||
$client = Client::factory(env('RPC_SITE_HOST')); |
|||
$request = $client->request(uniqid(),'/alisms/sent', [ |
|||
'phone' => 13481194554, |
|||
'template'=>'SMS_201720790', |
|||
'templateParams'=> json_encode(['name'=>"[DESION]",'money'=>'200元']), |
|||
]); |
|||
$response = $client->send($request); |
|||
$result = json_decode($response->getBody()->getContents()); |
|||
if ($result->result->Code != 'OK') { |
|||
$msg = $result->result->Message; |
|||
Log::error('发送短信失败', ['Message'=>$msg]); |
|||
} |
|||
return $response->getBody()->getContents(); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Controllers; |
|||
|
|||
|
|||
class Type |
|||
{ |
|||
/** |
|||
* 流水类型,大的分类,<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_MM_PLAT_NEW_USER = 9; // 市场经理发展新用户
|
|||
const MONEY_TYPE_MM_PLAT_NEW_STORE = 10; // 市场经理发展新商户
|
|||
const MONEY_TYPE_MP_PLAT_NEW_USER = 11; // 服务商发展新用户
|
|||
const MONEY_TYPE_MP_PLAT_NEW_STORE = 12; // 服务商发展新商户
|
|||
const MONEY_TYPE_MP_OL_ORDER = 13; // 服务商线上订单分账(线上订单完成)
|
|||
|
|||
const MONEY_TYPE_USER_OFL_ORDER = 100; // 用户线下支付订单
|
|||
const MONEY_TYPE_USER_OL_ORDER = 101; // 用户线上支付订单
|
|||
|
|||
|
|||
/** |
|||
* lanzu_user_balance 提现类型 |
|||
*/ |
|||
const BALANCE_USER_TYPE_U = 1; //用户提现类型
|
|||
const BALANCE_USER_TYPE_MP = 2; //服务商提现类型
|
|||
const BALANCE_USER_TYPE_MM = 3; //市场经理提现类型
|
|||
const BALANCE_USER_TYPE_CS = 4; //社区提现类型
|
|||
const BALANCE_USER_TYPE_STORE= 5; //商户提现类型
|
|||
|
|||
} |
|||
@ -0,0 +1,120 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\Banners; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\ImsCjdcMarket as MarketModel; |
|||
use App\Models\v3\Banners as BannersModel; |
|||
|
|||
class BannersController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Banners(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('market_id')->display(function($markerId){ |
|||
$market = MarketModel::getMarketInfo($markerId,'name'); |
|||
return empty($market) ? '' : $market['name']; |
|||
}); |
|||
$grid->column('title'); |
|||
$grid->column('cover_url')->image('',100); |
|||
$grid->column('cover_type_text'); |
|||
$grid->column('path'); |
|||
$grid->column('path_type_text'); |
|||
$grid->column('type_text'); |
|||
$grid->column('sort')->sortable(); |
|||
$grid->column('status')->switch(); |
|||
// ->using(BannersModel::$_status)->label(['default' => 'primary',1 => 'primary', 0 => 'danger']);
|
|||
$grid->model()->orderby('id','desc'); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new Banners(), function (Show $show) { |
|||
|
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('id'); |
|||
$show->width(6)->field('market_id')->as(function ($marketId){ |
|||
$market = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($market) ? '' : $market->name; |
|||
}); |
|||
$show->width(6)->field('title'); |
|||
$show->width(6)->field('sub_title'); |
|||
$show->width(6)->field('cover_type_text'); |
|||
$show->width(6)->field('cover')->image(); |
|||
$show->width(6)->field('type_text'); |
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('path_type_text'); |
|||
$show->width(6)->field('path'); |
|||
$show->width(6)->field('status_text'); |
|||
$show->width(6)->field('sort'); |
|||
$show->width(6)->field('created_at'); |
|||
$show->width(6)->field('updated_at'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new Banners(), function (Form $form) { |
|||
|
|||
$form->column(6, function (Form $form) { |
|||
$form->hidden('id'); |
|||
// 市场
|
|||
$marketList = MarketModel::getMarket(); |
|||
$form->select('market_id')->options($marketList)->default(0); |
|||
// 多个市场
|
|||
$form->multipleSelect('market_ids')->options($marketList); |
|||
$form->select('type')->options(BannersModel::$_type)->required(); |
|||
$form->text('title')->required(); |
|||
$form->text('sub_title'); |
|||
$form->number('sort')->default(0); |
|||
$form->switch('status') |
|||
->customFormat(function ($v) { |
|||
return $v == '正常' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
}); |
|||
}); |
|||
$form->column(6, function (Form $form) { |
|||
$form->image('cover')->required(); |
|||
$form->select('cover_type')->options(BannersModel::$_coverType)->required(); |
|||
$form->text('path')->default(''); |
|||
$form->select('path_type')->options(BannersModel::$_pathType)->default(''); |
|||
}); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,92 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Actions\Tree\CategoryTie; |
|||
use App\Models\v3\Category; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Layout\Row; |
|||
use Dcat\Admin\Layout\Content; |
|||
use Dcat\Admin\Tree; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Widgets\Card; |
|||
use App\Admin\Forms\CategoryTieForm; |
|||
use App\Libs\SsdbClient; |
|||
|
|||
class CategoryController extends AdminController |
|||
{ |
|||
public function index(Content $content) |
|||
{ |
|||
return $content->header('分类') |
|||
->body(function (Row $row) { |
|||
$tree = new Tree(new Category); |
|||
|
|||
$tree->branch(function ($branch) { |
|||
// 查询分类ssdb
|
|||
$ssdb = new SsdbClient(); |
|||
$category = $ssdb->client()->hgetall('applet_index_category'); |
|||
$select = array_keys($category); |
|||
|
|||
$src = $branch['cover_img_url']; |
|||
$logo = "<img src='$src' style='margin-left: 20px; max-width:35px;max-height:35px' class='img'/>"; |
|||
|
|||
$actions = ''; |
|||
$actions = (in_array($branch['id'],$select)) ?'<span style="margin-left: 20px;color: #dda451;">在首页显示'.'【'.$branch['sort'].'】</span>' :$actions; |
|||
|
|||
return "{$branch['id']} - {$branch['title']} $logo $actions "; |
|||
}); |
|||
$tree->tools(function (Tree\Tools $tools) { |
|||
$tools->add(new CategoryTie()); |
|||
}); |
|||
|
|||
$row->column(12, $tree); |
|||
}); |
|||
} |
|||
|
|||
public function form() |
|||
{ |
|||
return Form::make(new Category(),function (Form $form){ |
|||
|
|||
// 只查一级
|
|||
$parentList = Category::getArray([['parent_id','=',0]],[0=>'顶级']); |
|||
|
|||
$form->select('parent_id')->default(0)->options($parentList); |
|||
$form->text('title')->required(); |
|||
$form->image('cover_img')->required(); |
|||
|
|||
$form->number('sort'); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
|
|||
public function categoryTieForms(Content $content) |
|||
{ |
|||
return $content |
|||
->title('绑定分类到首页') |
|||
->body(new Card(new CategoryTieForm())); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new Category(), function (Show $show) { |
|||
|
|||
$show->field('parent_id'); |
|||
$show->field('title'); |
|||
$show->field('cover_img')->image(); |
|||
$show->field('sort'); |
|||
$show->field('status'); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,250 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\Coupon; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\CouponReceiveType as ReceiveTypeModel; |
|||
use App\Models\v3\CouponSetting as SettingModel; |
|||
use App\Models\v3\Coupon as CouponModel; |
|||
use App\Models\v3\Market as MarketModel; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
use Dcat\Admin\Form\NestedForm; |
|||
|
|||
use function GuzzleHttp\json_decode; |
|||
|
|||
class CouponController extends AdminController |
|||
{ |
|||
protected $receive_type = 0; |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
// $model = new CouponModel();
|
|||
// $list = $model->setAppends([])->select('id','title')->get();
|
|||
// dd($list->toArray());
|
|||
return Grid::make(new Coupon(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->title; |
|||
$grid->start_time_text; |
|||
$grid->end_time_text; |
|||
|
|||
$grid->full_amount; |
|||
$grid->discounts; |
|||
$grid->discount_type_text; |
|||
|
|||
$grid->inventory; |
|||
$grid->inventory_use; |
|||
$grid->use_number; |
|||
$grid->active_type_text; |
|||
$grid->status |
|||
->using( |
|||
CouponModel::$_STATUS |
|||
) |
|||
->label( |
|||
config('label.status_label') |
|||
); |
|||
|
|||
$grid->model()->orderBy('id','desc'); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->like('title','标题'); |
|||
$filter->equal('discount_type')->select(config('coupon.discount_type')); |
|||
$filter->equal('active_type')->select(config('coupon.active_type')); |
|||
$status = config('coupon.status'); |
|||
unset($status[-1]);/* 去掉删除状态 */ |
|||
$filter->in('status')->multipleSelect($status); |
|||
}); |
|||
|
|||
$grid->disableBatchDelete(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new Coupon(), function (Show $show) use($id){ |
|||
// $show->id;
|
|||
$show->title; |
|||
$show->introduce; |
|||
$show->full_amount; |
|||
$show->discounts; |
|||
$show->discount_type_text; |
|||
$show->inventory; |
|||
$show->inventory_use; |
|||
|
|||
$show->start_time_text; |
|||
$show->end_time_text; |
|||
$show->usable_start_time_text; |
|||
$show->usable_end_time_text; |
|||
|
|||
$show->active_type_text; |
|||
$show->receive_type_text; |
|||
$show->type_text; |
|||
$show->category_text; |
|||
$show->market_id->as(function($marketId){ |
|||
$text = '全部市场'; |
|||
if($marketId > 0){ |
|||
$market = marketModel::select('name')->find($marketId)->toArray(); |
|||
$text = $market ? $market['name'] : $text ; |
|||
} |
|||
return $text; |
|||
}); |
|||
$show->storetype_id->as(function($storeTypeId){ |
|||
$text = '全部店铺类型'; |
|||
if($storeTypeId > 0){ |
|||
$storeType = storeTypeModel::select('type_name')->find($storeTypeId)->toArray(); |
|||
$text = $storeType ? $storeType['type_name'] : $text ; |
|||
} |
|||
return $text; |
|||
}); |
|||
$show->is_new_user_text; |
|||
|
|||
$show->usable_number; |
|||
$show->weigh; |
|||
$show->remark; |
|||
$show->status_text; |
|||
$show->created_at_text; |
|||
$show->updated_at_text; |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
$builder = CouponModel::with('receiveType'); |
|||
return Form::make($builder, function (Form $form) { |
|||
$receiveTypeId = 0; |
|||
$startTime = null; |
|||
$endTime = null; |
|||
$usableStartTime = null; |
|||
$usableEndTime = null; |
|||
|
|||
if($form->isEditing()){ |
|||
$id = $form->getKey(); |
|||
// 查询已选择的领取方式
|
|||
$receiveType = ReceiveTypeModel::getReceiveTypeOne([['coupon_id','=',$id]],'receive_type'); |
|||
$receiveTypeId = $receiveType ? $receiveType->receive_type : $this->receive_type ; |
|||
$startTime = date('Y-m-d H:i:s',$form->model()->start_time); |
|||
$endTime = date('Y-m-d H:i:s',$form->model()->end_time); |
|||
$usableStartTime = date('Y-m-d H:i:s',$form->model()->usable_start_time); |
|||
$usableEndTime = date('YmdHis',$form->model()->usable_end_time); |
|||
// dd($usableEndTime);
|
|||
} |
|||
|
|||
$form->column(6,function(Form $form){ |
|||
$form->text('title')->required()->maxLength(255,'最多只能输入500个字'); |
|||
$form->textarea('introduce')->required(); |
|||
$form->currency('full_amount')->required()->floatTwo()->symbol('¥'); |
|||
$form->currency('discounts')->required()->floatTwo()->symbol('¥'); |
|||
$form->radio('discount_type')->options(CouponModel::$_DISCOUNTTYPE)->default(1); |
|||
$form->number('inventory')->required()->type('number')->attribute('min', 1)->default(1); |
|||
$form->number('weigh')->type('number')->attribute('min', 0)->default(0); |
|||
$form->radio('is_new_user')->options(CouponModel::$_ISNEWUSER)->default(2)->disable(); |
|||
|
|||
}); |
|||
|
|||
$form->column(6,function(Form $form) use($receiveTypeId){ |
|||
$form->select('active_type')->required()->options(CouponModel::$_ACTIVETYPE)->default(1); |
|||
/* 领取方式 */ |
|||
$receives = SettingModel::getSettingArray([['category','=',1]]); |
|||
$form->select('receive_type.receive_type','领取方式')->required()->options($receives)->value($receiveTypeId)->default($receiveTypeId); |
|||
// $form->hasMany('receive_type',function(NestedForm $form){
|
|||
// $form->select('receive_type')->options($receives);
|
|||
// });
|
|||
// $receive = SettingModel::select('id','name')->where('category',1)->get()->keyBy('id')->toArray();
|
|||
// $receive = $this->keyToValue($receive,'id','name');
|
|||
// $form->select('receive_type')->options($receive)->value($receiveTypeId > 0? $receiveTypeId : 2);
|
|||
|
|||
$form->datetimeRange('start_time','end_time','活动时间')->required(); |
|||
// ->rules('after:now',[
|
|||
// 'after' => '只能选择今天和之后的时间'
|
|||
// ]);
|
|||
$form->datetimeRange('usable_start_time','usable_end_time','可用时间')->required()->rules('after:start_time',[ |
|||
'after' => '可用时间必须比活动开始时间晚' |
|||
]); |
|||
|
|||
// $form->select('type')->options(CouponModel::$_TYPE)->default(1)->disable();
|
|||
// $form->select('category')->options(CouponModel::$_CATEGORY)->default(1)->disable();
|
|||
/* 默认全平台的市场 */ |
|||
$marketList = MarketModel::getMarketArray(); |
|||
$form->multipleSelect('market_ids')->options($marketList)->help('不选默认所有市场可用'); |
|||
/* 目前默认全平台的分类 */ |
|||
$categoryList = CategoryModel::getArray(); |
|||
$form->multipleSelect('category_ids')->options($categoryList)->help('不选默认所有类型可用'); |
|||
|
|||
}); |
|||
|
|||
$form->column(12,function(Form $form){ |
|||
$form->tags('activity_available','可用活动')->options(CouponModel::$_ACTIVITY_AVAILABLE); |
|||
$form->tags('tags','标签')->options(['新人专享','满39减10','满19减5']); |
|||
$form->text('remark')->maxLength(500,'最多只能输入500个字'); |
|||
}); |
|||
|
|||
/* 页面按钮 */ |
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
|
|||
/* 不显示字段 */ |
|||
$form->hidden('id'); |
|||
|
|||
// $form->text('usable_number')->width(2)->default(1)->disable();
|
|||
|
|||
$form->saving(function (Form $form){ |
|||
// var_dump($form->usable_start_time);
|
|||
// dd($form->receive_type);
|
|||
if( $form->discount_type == 2 && ($form->discounts <= 0 || $form->discounts >= 10)){ |
|||
return $form->error('优惠金额请输入1~10之间的数字'); |
|||
} |
|||
|
|||
// $this->receive_type = $form->receive_type;
|
|||
$form->deleteInput('receive_type'); |
|||
}); |
|||
$form->saved(function (Form $form, $result){ |
|||
|
|||
$id = $form->getKey(); |
|||
$receiveTypeId = $form->input('receive_type'); |
|||
// 判断是否是新增操作
|
|||
if ($form->isCreating()) { |
|||
$id = $result; |
|||
|
|||
if (! $result) { |
|||
return $form->error('数据保存失败'); |
|||
} |
|||
} |
|||
if($form->isEditing()){ |
|||
// 删除领取方式
|
|||
ReceiveTypeModel::where('coupon_id',$id)->delete(); |
|||
} |
|||
|
|||
// 添加领取方式
|
|||
$receiveModel = new ReceiveTypeModel(); |
|||
$receiveModel->coupon_id = $id; |
|||
$receiveModel->receive_type = $receiveTypeId; |
|||
// 获取一次可领取数量
|
|||
$receiveNumber = SettingModel::getSettingInfo($receiveTypeId,'value'); |
|||
$receiveModel->one_receive_number = empty($receiveNumber) ? 1 : $receiveNumber->value; |
|||
$receiveModel->save(); |
|||
}); |
|||
|
|||
}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\CouponSetting; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\CouponSetting as SettingModel; |
|||
|
|||
class CouponSettingController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new CouponSetting(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
|
|||
$grid->category_text; |
|||
$grid->name; |
|||
$grid->value; |
|||
$grid->sort; |
|||
$grid->status->switch(); |
|||
|
|||
$grid->model()->orderBy('id','desc'); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->like('name'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new CouponSetting(), function (Show $show) { |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->id; |
|||
$show->width(6)->category_text; |
|||
$show->width(6)->name; |
|||
$show->width(6)->value; |
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->sort; |
|||
$show->width(6)->status_text; |
|||
$show->width(6)->created_at; |
|||
$show->width(6)->updated_at; |
|||
}); |
|||
|
|||
// $show->desc;
|
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new CouponSetting(), function (Form $form) { |
|||
$form->hidden('id'); |
|||
$form->select('category')->width(6)->options(SettingModel::$_CATEGORY); |
|||
$form->text('name')->width(6)->required()->maxLength(50); |
|||
|
|||
$form->number('value')->required()->rules('min:1')->default(1); |
|||
// $form->text('desc')->maxLength(500);
|
|||
$form->number('sort')->rules('min:0'); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,206 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\GoodsActivity; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\Market as MarketModel; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
use App\Models\v3\GoodsActivity as GoodsActivityModel; |
|||
use Dcat\Admin\Form\NestedForm; |
|||
use App\Models\v3\GoodsCategory as GoodsCategoryModel; |
|||
|
|||
class GoodsActivityController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new GoodsActivity(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('cover_img')->image('',50); |
|||
$grid->column('name'); |
|||
$grid->column('price'); |
|||
$grid->column('type_text'); |
|||
|
|||
$grid->column('market_id')->display(function($marketId){ |
|||
$item = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$grid->column('store_id')->display(function($storeId){ |
|||
$item = StoreModel::getStoreInfo($storeId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$grid->column('category_id')->display(function($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$grid->goods_category_id->display(function ($goodsCategoryId){ |
|||
$item = GoodsCategoryModel::getInfo($goodsCategoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$grid->column('expire_time_text'); |
|||
$grid->column('sort'); |
|||
$grid->column('on_sale')->switch(); |
|||
$grid->model()->orderby('id','desc'); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new GoodsActivity(), function (Show $show) { |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('id'); |
|||
$show->width(6)->field('name'); |
|||
$show->width(6)->field('cover_img')->image(); |
|||
$show->width(6)->field('goods_unit'); |
|||
$show->width(6)->field('price'); |
|||
$show->width(6)->field('original_price'); |
|||
$show->width(6)->field('vip_price'); |
|||
$show->width(6)->field('start_num'); |
|||
$show->width(6)->field('restrict_num'); |
|||
$show->width(6)->field('is_infinite'); |
|||
$show->width(6)->field('inventory'); |
|||
$show->width(6)->field('type_text'); |
|||
$show->width(6)->field('goods_id'); |
|||
$show->width(6)->field('market_id'); |
|||
$show->width(6)->field('store_id'); |
|||
$show->width(6)->field('category_id'); |
|||
$show->width(6)->field('on_sale'); |
|||
$show->width(6)->field('sort'); |
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('content'); |
|||
$show->width(6)->field('expire_time_text'); |
|||
$show->width(6)->field('time_limit_days'); |
|||
$show->width(6)->field('time_limit_num'); |
|||
$show->width(6)->field('can_use_coupon_text'); |
|||
$show->width(6)->field('tags')->as(function ($value){ |
|||
return $value; |
|||
}); |
|||
|
|||
$show->width(6)->field('spec')->as(function ($value){ |
|||
$text = ''; |
|||
foreach ($value as $v){ |
|||
$text .= '【'.$v['spec_key'] .':'.$v['spec_value'].'】 '; |
|||
} |
|||
return $text; |
|||
}); |
|||
// $show->width(6)->field('details_imgs');
|
|||
$show->width(6)->field('remark'); |
|||
|
|||
$show->width(6)->field('created_at'); |
|||
$show->width(6)->field('updated_at'); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
$builder = GoodsActivityModel::with(['ImageBanners','VideoBanners']); |
|||
return Form::make($builder, function (Form $form) { |
|||
$form->hidden('id'); |
|||
|
|||
// 二级分类
|
|||
$categoryList = CategoryModel::getArray([['parent_id','>',0]]); |
|||
// 店铺
|
|||
$storeList = StoreModel::getStoreArray(); |
|||
//市场
|
|||
// $marketList = MarketModel::getMarketArray();
|
|||
|
|||
$form->column(6, function (Form $form) use($storeList,$categoryList ){ |
|||
$form->text('goods_id')->default(0)->help('输入正常商品id,用于关联商品。'); |
|||
// $form->select('market_id')->required()->options($marketList);
|
|||
$form->select('category_id')->required()->options($categoryList)->load('goods_category_id', '/api/goods_category_list'); |
|||
$form->select('goods_category_id')->required(); |
|||
$form->select('store_id')->required()->options($storeList); |
|||
$form->text('name')->required()->maxLength(20); |
|||
$form->image('cover_img')->required(); |
|||
$form->select('type')->options(GoodsActivityModel::$_type)->default('flash_sale'); |
|||
$form->datetime('expire_time')->value($form->model()->expire_time_text); |
|||
$form->number('time_limit_days'); |
|||
|
|||
}); |
|||
$form->column(6, function (Form $form) { |
|||
$form->currency('price')->required()->floatTwo()->symbol('¥'); |
|||
$form->currency('original_price')->required()->floatTwo()->symbol('¥'); |
|||
$form->currency('vip_price')->required()->floatTwo()->symbol('¥'); |
|||
$form->text('goods_unit')->help('如:斤,个,盒,500克,1000克,1500克等'); |
|||
$form->radio('is_infinite')->options(['关闭','开启'])->default(1); |
|||
$form->number('inventory')->required()->attribute('min', 1)->default(1); |
|||
$form->number('restrict_num')->attribute('min', 0)->default(0)->help('0表示不限购'); |
|||
$form->number('start_num')->attribute('min', 1)->default(1); |
|||
$form->number('time_limit_num'); |
|||
$form->switch('can_use_coupon'); |
|||
}); |
|||
$form->column(12, function (Form $form) { |
|||
$form->hasMany('image_banners', function (Form\NestedForm $form) { |
|||
$form->image('path')->width(2); |
|||
$form->number('sort')->width(2)->default(0); |
|||
$form->hidden('type')->value(1)->default(1); |
|||
})->required(); |
|||
$form->divider(); |
|||
$form->hasMany('video_banners', function (Form\NestedForm $form) { |
|||
$form->file('path')->width(2); |
|||
$form->number('sort')->width(2)->default(0); |
|||
$form->hidden('type')->value(2)->default(2); |
|||
}); |
|||
$form->divider(); |
|||
|
|||
$form->multipleImage('details_imgs')->help('按图片顺序上传'); |
|||
$form->text('content')->maxLength(50); |
|||
$form->text('remark')->maxLength(50); |
|||
|
|||
$form->tags('tags','标签')->options(['新品','热销','新鲜']); |
|||
$form->table('spec', function (NestedForm $table) { |
|||
$table->text('spec_key')->help('如:净含量:500克,保质期:120天,包装:12个/盒等'); |
|||
$table->text('spec_value'); |
|||
}); |
|||
$form->switch('on_sale') |
|||
->customFormat(function ($v) { |
|||
return $v == '上架' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
}); |
|||
$form->saved(function (Form $form){ |
|||
$storeId = $form->input('store_id'); |
|||
|
|||
// 商品所属市场,根据店铺查询市场
|
|||
$info = StoreModel::getStoreInfo($storeId,'market_id'); |
|||
$form->market_id = $info->market_id; |
|||
}); |
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,97 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\GoodsCategory; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
use Symfony\Component\HttpFoundation\Request; |
|||
use Illuminate\Support\Facades\DB; |
|||
use App\Models\v3\GoodsCategory as GoodsCategoryModel; |
|||
class GoodsCategoryController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new GoodsCategory(), function (Grid $grid) { |
|||
$grid->column('id')->sortable(); |
|||
$grid->column('category_id')->display(function($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$grid->column('title'); |
|||
$grid->column('cover_img')->image('',50); |
|||
$grid->column('sort'); |
|||
|
|||
$grid->model()->orderBy('id','desc'); |
|||
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
|
|||
}); |
|||
$grid->disableBatchDelete(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new GoodsCategory(), function (Show $show) { |
|||
$show->field('id'); |
|||
$show->field('category_id')->as(function($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$show->field('title'); |
|||
$show->field('cover_img')->image('',50); |
|||
$show->field('sort'); |
|||
$show->field('created_at'); |
|||
$show->field('updated_at'); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
return Form::make(new GoodsCategory(), function (Form $form) { |
|||
$form->hidden('id'); |
|||
$category = CategoryModel::getArray([['parent_id','>',0]]); |
|||
$form->select('category_id')->width(4)->required()->options($category); |
|||
$form->text('title')->width(4)->required(); |
|||
$form->image('cover_img')->width(2); |
|||
$form->number('sort'); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* 获取商品类目列表 |
|||
*/ |
|||
public function getList(Request $request) |
|||
{ |
|||
$categoryId = $request->get('q'); |
|||
$list = GoodsCategoryModel::where('category_id',$categoryId)->get(['id',DB::raw('title as text')]); |
|||
return $list; |
|||
} |
|||
} |
|||
@ -0,0 +1,226 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Actions\Grid\GoodsCopy; |
|||
use App\Admin\Repositories\v3\Goods; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use Dcat\Admin\Form\NestedForm; |
|||
use App\Models\v3\Goods as GoodsModel; |
|||
use App\Models\v3\Market as MarketModel; |
|||
use Dcat\Admin\Grid\Displayers\Actions; |
|||
use App\Models\v3\GoodsCategory as GoodsCategoryModel; |
|||
|
|||
class GoodsController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Goods(), function (Grid $grid) { |
|||
$grid->id->sortable(); |
|||
$grid->cover_img_url->image('',50); |
|||
$grid->name; |
|||
$grid->price; |
|||
$grid->column('market_id')->display(function($marketId){ |
|||
$item = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$grid->store_id->display(function ($storeId){ |
|||
$store = StoreModel::getStoreInfo($storeId,'name'); |
|||
return empty($store) ? '' : $store->name; |
|||
}); |
|||
$grid->category_id->display(function ($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$grid->goods_category_id->display(function ($goodsCategoryId){ |
|||
$item = GoodsCategoryModel::getInfo($goodsCategoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
|
|||
|
|||
$grid->sort->sortable(); |
|||
$grid->on_sale->switch(); |
|||
|
|||
$grid->actions([new GoodsCopy()]); |
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->like('name'); |
|||
}); |
|||
|
|||
$grid->model()->orderBy('id', 'desc'); |
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
// $g = GoodsModel::find(1572);
|
|||
// dd($g->toArray());
|
|||
return Show::make($id, new Goods(), function (Show $show) { |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->field('id'); |
|||
$show->width(6)->field('name'); |
|||
$show->width(6)->category_id->as(function ($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$show->width(6)->store_id->as(function ($storeId){ |
|||
$item = GoodsCategoryModel::getInfo($storeId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$show->width(6)->store_id->as(function ($goodsCategoryId){ |
|||
$item = StoreModel::getStoreInfo($goodsCategoryId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$show->width(6)->cover_img->image(); |
|||
$show->width(6)->price; |
|||
$show->width(6)->original_price; |
|||
$show->width(6)->vip_price; |
|||
$show->width(6)->inventory; |
|||
$show->width(6)->goods_unit; |
|||
|
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->on_sale_text; |
|||
$show->width(6)->content; |
|||
$show->width(6)->sort; |
|||
$show->width(6)->restrict_num; |
|||
$show->width(6)->start_num; |
|||
$show->width(6)->is_infinite_text; |
|||
|
|||
$show->width(6)->tags->as(function ($value){ |
|||
return $value; |
|||
}); |
|||
$show->width(6)->spec->as(function ($value){ |
|||
$text = ''; |
|||
foreach ($value as $v){ |
|||
$text .= '【'.$v['spec_key'] .':'.$v['spec_value'].'】 '; |
|||
} |
|||
return $text; |
|||
}); |
|||
$goodsModel = new GoodsModel(); |
|||
$show->html(function () use($goodsModel){ |
|||
if(empty($this->details_imgs)){ |
|||
return ''; |
|||
}else{ |
|||
// 还需要优化
|
|||
$value = $this->details_imgs; |
|||
$text = ''; |
|||
foreach ($value as $v){ |
|||
$img = $goodsModel->imageUrl($v); |
|||
$text .= "<img src='$img' />"; |
|||
} |
|||
return $text; |
|||
} |
|||
}); |
|||
|
|||
// $show->created_at;
|
|||
// $show->updated_at;
|
|||
}); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
$builder = GoodsModel::with(['ImageBanners','VideoBanners']); |
|||
|
|||
return Form::make($builder, function (Form $form) { |
|||
$form->hidden('id'); |
|||
|
|||
// 二级分类
|
|||
$categoryList = CategoryModel::getArray([['parent_id','>',0]]); |
|||
// 商品类目
|
|||
$goodsCategoryList = GoodsCategoryModel::getArray(); |
|||
// 店铺
|
|||
$storeList = StoreModel::getStoreArray(); |
|||
//市场
|
|||
// $marketList = MarketModel::getMarketArray();
|
|||
|
|||
$form->column(6, function (Form $form) use($storeList,$categoryList,$goodsCategoryList ){ |
|||
// $form->select('market_id')->required()->options($marketList);
|
|||
$form->select('category_id')->required()->options($categoryList)->load('goods_category_id', '/api/goods_category_list'); |
|||
$form->select('goods_category_id')->required(); |
|||
$form->select('store_id')->required()->options($storeList); |
|||
$form->text('name')->required()->maxLength(20); |
|||
$form->image('cover_img')->required(); |
|||
$form->number('sort'); |
|||
}); |
|||
$form->column(6, function (Form $form) { |
|||
$form->currency('price')->required()->floatTwo()->symbol('¥'); |
|||
$form->currency('original_price')->required()->floatTwo()->symbol('¥'); |
|||
$form->currency('vip_price')->required()->floatTwo()->symbol('¥'); |
|||
$form->text('goods_unit')->help('如:斤,个,盒,500克,1000克,1500克等'); |
|||
$form->radio('is_infinite')->options(['关闭','开启'])->default(1); |
|||
$form->number('inventory')->required()->attribute('min', 1)->default(1); |
|||
$form->number('restrict_num')->attribute('min', 0)->default(0)->help('0表示不限购'); |
|||
$form->number('start_num')->attribute('min', 1)->default(1); |
|||
}); |
|||
$form->column(12, function (Form $form) { |
|||
$form->hasMany('image_banners', function (Form\NestedForm $form) { |
|||
$form->image('path')->width(2); |
|||
$form->number('sort')->width(2)->default(0); |
|||
$form->hidden('type')->value(1)->default(1); |
|||
})->required(); |
|||
$form->divider(); |
|||
$form->hasMany('video_banners', function (Form\NestedForm $form) { |
|||
$form->file('path')->width(2); |
|||
$form->number('sort')->width(2)->default(0); |
|||
$form->hidden('type')->value(2)->default(2); |
|||
}); |
|||
$form->divider(); |
|||
|
|||
$form->multipleImage('details_imgs')->help('按图片顺序上传'); |
|||
$form->text('content')->maxLength(50); |
|||
$form->text('remark')->maxLength(50); |
|||
|
|||
$form->tags('tags','标签')->options(['新品','热销','新鲜']); |
|||
$form->table('spec', function (NestedForm $table) { |
|||
$table->text('spec_key')->help('如:净含量:500克,保质期:120天,包装:12个/盒等'); |
|||
$table->text('spec_value'); |
|||
}); |
|||
$form->switch('on_sale') |
|||
->customFormat(function ($v) { |
|||
return $v == '上架' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
}); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
$form->saved(function (Form $form){ |
|||
$storeId = $form->input('store_id'); |
|||
|
|||
// 商品所属市场,根据店铺查询市场
|
|||
$info = StoreModel::getStoreInfo($storeId,'market_id'); |
|||
$form->market_id = $info->market_id; |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,282 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Controllers\v3; |
|||
|
|||
use App\Admin\Repositories\v3\Store; |
|||
use Dcat\Admin\Form; |
|||
use Dcat\Admin\Grid; |
|||
use Dcat\Admin\Show; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
use App\Models\LanzuMmInfo as MminfoModel; |
|||
use App\Models\v3\Market as MarketModel; |
|||
use App\Admin\Common\StoreQRCode; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use App\Models\v3\User as UserModel; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
use App\Models\LanzuUserBalance as UserBalanceModel; |
|||
use App\Models\v3\StoreUsers as StoreUsersModel; |
|||
|
|||
class StoreController extends AdminController |
|||
{ |
|||
/** |
|||
* Make a grid builder. |
|||
* |
|||
* @return Grid |
|||
*/ |
|||
protected function grid() |
|||
{ |
|||
return Grid::make(new Store(), function (Grid $grid) { |
|||
$grid->model()->orderBy('id','desc'); |
|||
$grid->id->sortable(); |
|||
$grid->logo_url->image('',50); |
|||
$grid->name; |
|||
|
|||
$grid->market_id->display(function ($marketId){ |
|||
$market = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($market) ? '' : $market->name; |
|||
}); |
|||
$grid->mm_user_id->display(function ($mmUserId){ |
|||
$mmUser = MminfoModel::getMmInfo($mmUserId,'name'); |
|||
return empty($mmUser) ? '' : $mmUser->name; |
|||
}); |
|||
$grid->store_applet_img->image('',50); |
|||
$grid->cash_code_img->image('',50); |
|||
|
|||
$grid->sort->sortable(); |
|||
$grid->is_rest->switch(); |
|||
$grid->is_open->switch(); |
|||
|
|||
// 搜索
|
|||
$grid->filter(function (Grid\Filter $filter) { |
|||
$filter->equal('id'); |
|||
$filter->like('name'); |
|||
}); |
|||
|
|||
// 每页10条
|
|||
$grid->paginate(10); |
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a show builder. |
|||
* |
|||
* @param mixed $id |
|||
* |
|||
* @return Show |
|||
*/ |
|||
protected function detail($id) |
|||
{ |
|||
return Show::make($id, new Store(), function (Show $show) { |
|||
|
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->id; |
|||
$show->width(6)->mm_user_id->as(function ($mmUserId){ |
|||
$item = MminfoModel::getMmInfo($mmUserId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$show->width(6)->market_id->as(function ($marketId){ |
|||
$item = MarketModel::getMarketInfo($marketId,'name'); |
|||
return empty($item) ? '' : $item->name; |
|||
}); |
|||
$show->width(6)->category_id->as(function ($categoryId){ |
|||
$item = CategoryModel::getInfo($categoryId,'title'); |
|||
return empty($item) ? '' : $item->title; |
|||
}); |
|||
$show->width(6)->name; |
|||
$show->width(6)->logo->image(); |
|||
$show->width(6)->user_id->as(function ($userId){ |
|||
$item = UserModel::getUserInfo($userId,'nick_name'); |
|||
return empty($item) ? '' : $item->nick_name; |
|||
}); |
|||
$show->width(6)->admin_id->as(function ($userId){ |
|||
$item = UserModel::getUserInfo($userId,'nick_name'); |
|||
return empty($item) ? '' : $item->nick_name; |
|||
}); |
|||
$show->width(6)->business_license->image(); |
|||
$show->width(6)->zm_img->image(); |
|||
$show->width(6)->fm_img->image(); |
|||
$show->width(6)->tel; |
|||
$show->width(6)->link_name; |
|||
$show->width(6)->link_tel; |
|||
$show->width(6)->time1; |
|||
$show->width(6)->time2; |
|||
$show->width(6)->time3; |
|||
$show->width(6)->time4; |
|||
}); |
|||
$show->row(function (Show\Row $show) { |
|||
$show->width(6)->announcement; |
|||
$show->width(6)->address; |
|||
$show->width(6)->coordinates; |
|||
|
|||
$show->width(6)->is_rest_text; |
|||
$show->width(6)->is_open_text; |
|||
$show->width(6)->sort; |
|||
// $show->width(6)->environment;
|
|||
$show->width(6)->expire_time; |
|||
$show->width(6)->loudspeaker_imei; |
|||
}); |
|||
|
|||
// $show->created_at;
|
|||
// $show->updated_at;
|
|||
}); |
|||
} |
|||
|
|||
/** |
|||
* Make a form builder. |
|||
* |
|||
* @return Form |
|||
*/ |
|||
protected function form() |
|||
{ |
|||
// dd(StoreModel::pluck('admin_id'));
|
|||
return Form::make(new Store(), function (Form $form) { |
|||
// 查询市场经理
|
|||
$mmList = MminfoModel::getMmInfoArray(); |
|||
// 查询市场
|
|||
$marketList = MarketModel::getMarketArray(); |
|||
// 查询一级分类
|
|||
$categoryList = CategoryModel::getArray([['parent_id','=',0]]); |
|||
// 用户
|
|||
$userList = UserModel::getUserArray(); |
|||
// 绑定了店铺的用户
|
|||
$userHas = StoreModel::pluck('admin_id')->toArray(); |
|||
|
|||
foreach($userList as $ku => $uv){ |
|||
if($ku != 0 && in_array($ku,$userHas)){ |
|||
unset($userList[$ku]); |
|||
} |
|||
} |
|||
|
|||
$form->column(6, function (Form $form) use($mmList,$marketList,$categoryList){ |
|||
$form->hidden('id'); |
|||
$form->select('mm_user_id')->options($mmList); |
|||
$form->select('market_id')->required()->options($marketList); |
|||
$form->select('category_id')->options($categoryList); |
|||
$form->text('name')->required()->maxLength(50); |
|||
$form->image('logo')->required(); |
|||
$form->mobile('tel'); |
|||
$form->text('link_name')->required(); |
|||
$form->mobile('link_tel')->required(); |
|||
$form->number('sort'); |
|||
$form->switch('is_rest') |
|||
->customFormat(function ($v) { |
|||
return $v == '休息' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
}); |
|||
$form->switch('is_open') |
|||
->customFormat(function ($v) { |
|||
return $v == '开启' ? 1 : 0; |
|||
}) |
|||
->saving(function ($v) { |
|||
return $v; |
|||
})->default(1); |
|||
$form->text('address'); |
|||
}); |
|||
$form->column(6, function (Form $form) use($userList){ |
|||
$form->image('business_license')->required(); |
|||
$form->image('zm_img')->required(); |
|||
$form->image('fm_img')->required(); |
|||
$form->select('admin_id')->options($userList)->required();/*需要优化 一个用户只能绑定一家店铺*/ |
|||
$form->select('user_id')->options($userList)->required();/*需要优化 一个用户只能绑定一家店铺*/ |
|||
$form->time('time1','时间段一开始')->format('HH:mm'); |
|||
$form->time('time2','时间段一结束')->format('HH:mm')->rules('after:time1',['after'=>'选择的时间必须比时间段一开始时间晚']); |
|||
$form->time('time3','时间段二开始')->format('HH:mm')->rules('after:time2',['after'=>'选择的时间必须比时间段一结束时间晚']); |
|||
$form->time('time4','时间段二结束')->format('HH:mm')->rules('after:time3',['after'=>'选择的时间必须比时间段二开始时间晚']); |
|||
// $form->timeRange('time1','time2','营业时间段一')->required();
|
|||
// $form->timeRange('time3','time4','营业时间段二')->rules('after:time2',['after'=>'选择的时间必须比时间段一结束时间大']);
|
|||
}); |
|||
$form->column(12, function (Form $form) { |
|||
$form->map('lat','lng','地址'); |
|||
$form->textarea('introduction')->required(); |
|||
$form->textarea('announcement'); |
|||
$form->multipleImage('environment'); |
|||
}); |
|||
|
|||
// $form->text('coordinates')->width(4)
|
|||
// ->placeholder('输入 经纬度,如: 108.281552,22.83731')
|
|||
// ->help("通过网址 <a href='https://lbs.amap.com/console/show/picker' target='_blank'>https://lbs.amap.com/console/show/picker</a> 获取经纬度");
|
|||
|
|||
$form->saved(function (Form $form){ |
|||
$id = $form->getKey(); |
|||
$store = StoreModel::find($id); |
|||
|
|||
// 添加商户钱包
|
|||
$userBalance = UserBalanceModel::where([ |
|||
['user_type','=',5], |
|||
['source_id','=',$id] |
|||
])->first(); |
|||
|
|||
if(empty($userBalance)){ |
|||
$userBalance = new UserBalanceModel(); |
|||
$userBalance->user_type = 5; |
|||
$userBalance->source_id = $id; |
|||
$userBalance->save(); |
|||
} |
|||
|
|||
if($form->isCreating() && !empty($id)){ |
|||
$qrCode = new StoreQRCode(); |
|||
// 生成小程序码 店铺
|
|||
$sRes = $qrCode->SetStoreWeChatCode($id); |
|||
|
|||
// 生产小程序码 收银
|
|||
$pRes = $qrCode->SetPayWeChatCode($id); |
|||
|
|||
// 保存图片
|
|||
$store->store_applet_img = $sRes['status'] ? $sRes['path'] : ''; |
|||
$store->cash_code_img = $pRes['status'] ? $pRes['path'] : ''; |
|||
$store->save(); |
|||
// 剪裁图片
|
|||
// $form->image('cash_code_img')->crop(270, 270, [5, 5]);
|
|||
|
|||
//店长账号
|
|||
$storeUsersInfo = StoreUsersModel::where('store_id',$id)->where('user_category',1)->first(); |
|||
if(empty($storeUsersInfo)){ |
|||
$storeUsersModel = new StoreUsersModel(); |
|||
$storeUsersModel->store_id = $id; |
|||
$storeUsersModel->username = $form->link_tel; |
|||
$storeUsersModel->join_ip = $_SERVER['SERVER_NAME']; |
|||
$storeUsersModel->user_category = 1; |
|||
$storeUsersModel->register_type = 4; |
|||
$storeUsersModel->status = 2; |
|||
$storeUsersModel->salt = $this->random(8); |
|||
$storeUsersModel->password = $this->stringHash(substr($form->link_tel,-1,5),$storeUsersModel->salt); |
|||
$storeUsersModel->remark = '入驻店铺注册'; |
|||
$storeUsersModel->save(); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
$form->disableResetButton(); |
|||
$form->disableViewCheck(); |
|||
$form->disableEditingCheck(); |
|||
$form->disableCreatingCheck(); |
|||
}); |
|||
} |
|||
|
|||
public function stringHash($password, $salt) { |
|||
$authkey = config('admin.setting.authkey'); |
|||
$password = "{$password}-{$salt}-{$authkey}"; |
|||
return sha1($password); |
|||
} |
|||
/** |
|||
* 字符串 |
|||
*/ |
|||
public function random($length, $numeric = false) { |
|||
$seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); |
|||
$seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed)); |
|||
if ($numeric) { |
|||
$hash = ''; |
|||
} else { |
|||
$hash = chr(rand(1, 26) + rand(0, 1) * 32 + 64); |
|||
--$length; |
|||
} |
|||
$max = strlen($seed) - 1; |
|||
for ($i = 0; $i < $length; ++$i) { |
|||
$hash .= $seed[mt_rand(0, $max)]; |
|||
} |
|||
|
|||
return $hash; |
|||
} |
|||
} |
|||
@ -1,42 +1,38 @@ |
|||
<?php |
|||
namespace App\Admin\Extensions; |
|||
|
|||
use App\Admin\Forms\CouponTieForm; |
|||
use App\Admin\Forms\SelectHorseman; |
|||
use App\Models\ImsCjdcOrderMain; |
|||
use App\Models\StoreAccount; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class CheckRow extends RowAction |
|||
{ |
|||
|
|||
public function title() |
|||
protected $title; |
|||
protected $order_id; |
|||
protected $currentPage; |
|||
public function __construct($orderId,$currentPage,$title=null) |
|||
{ |
|||
return 'Check row'; |
|||
} |
|||
/** |
|||
* 添加JS |
|||
* |
|||
* @return string |
|||
*/ |
|||
protected function script() |
|||
{ |
|||
return <<<JS |
|||
$('.grid-check-row').on('click', function () { |
|||
|
|||
// Your code.
|
|||
console.log($(this).data('id')); |
|||
$this->order_id = $orderId; |
|||
$this->currentPage = $currentPage; |
|||
parent::__construct($title); |
|||
|
|||
}); |
|||
JS; |
|||
} |
|||
public function html() |
|||
{ |
|||
// 获取当前行数据ID
|
|||
$id = $this->getKey(); |
|||
|
|||
// 获取当前行数据的用户名
|
|||
$username = $this->row->username; |
|||
public function render() |
|||
{ |
|||
|
|||
// 这里需要添加一个class, 和上面script方法对应
|
|||
$this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']); |
|||
// 实例化表单类并传递自定义参数
|
|||
$form = SelectHorseman::make(['order_id'=>$this->order_id,'current_page'=>$this->currentPage]); |
|||
return Modal::make() |
|||
->lg() |
|||
->title($this->title) |
|||
->body($form) |
|||
->button($this->title); |
|||
|
|||
return parent::html(); |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Extensions; |
|||
|
|||
|
|||
use Dcat\Admin\Grid\RowAction; |
|||
|
|||
class OrderDetail extends RowAction |
|||
{ |
|||
public function __construct($title=null) |
|||
{ |
|||
parent::__construct($title); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,100 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Extensions; |
|||
|
|||
|
|||
use App\Models\Feprint; |
|||
use App\Models\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Graze\GuzzleHttp\JsonRpc\Client; |
|||
use Illuminate\Http\Request; |
|||
|
|||
class OrderPrint extends RowAction |
|||
{ |
|||
protected $title; |
|||
|
|||
public function __construct($title = null) |
|||
{ |
|||
parent::__construct($title); |
|||
|
|||
} |
|||
|
|||
public function handle(Request $request) |
|||
{ |
|||
$oid = $this->getKey(); |
|||
$result = $this->doPrint($oid); |
|||
if ($result){ |
|||
return $this->response()->success('操作成功'); |
|||
}else{ |
|||
return $this->response()->success('打印失败'); |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 设置要POST到接口的数据 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function parameters() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public function doPrint($oid) |
|||
{ |
|||
|
|||
$row = ImsCjdcOrderMain::find($oid); |
|||
|
|||
//>>1.获取打印机状态
|
|||
$result = $this->getPrintStatus($row->market_id); |
|||
|
|||
//>>2.调用打印
|
|||
if ($result == 1) { |
|||
$res = $this->rpcPrint($oid); |
|||
$res = json_decode($res, true)['result']; |
|||
$res = json_decode($res); |
|||
|
|||
//>>3.记录打印次数
|
|||
if ($res->msg == 'ok' && $res->ret == 0) { |
|||
//记录打印次数
|
|||
$row->print_num +=1; |
|||
return $row->save(); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/** |
|||
* @param $oid //主订单ID
|
|||
* @return int |
|||
*/ |
|||
public function getPrintStatus($mid) |
|||
{ |
|||
$fe = Feprint::where('market_id', $mid)->first(); |
|||
if ($fe) { |
|||
return $fe->status; |
|||
} else { |
|||
return -1; |
|||
} |
|||
} |
|||
|
|||
|
|||
public function rpcPrint($oid) |
|||
{ |
|||
$client = Client::factory(env('RPC_SITE_HOST')); |
|||
$request = $client->request(uniqid(), '/feie/doPrint', ['oid' => $oid]); |
|||
$response = $client->send($request); |
|||
return $response->getBody()->getContents(); |
|||
} |
|||
|
|||
public function feiErPrint($order_num) |
|||
{ |
|||
include_once app_path('Libs\feier_print\api_php_demo.php'); |
|||
$result = json_decode(FeiePrint($order_num)); |
|||
dd($result); |
|||
} |
|||
} |
|||
@ -0,0 +1,69 @@ |
|||
<?php |
|||
namespace App\Admin\Extensions; |
|||
|
|||
use App\Admin\Common\Rpc; |
|||
use App\Models\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Grid\Displayers\Modal; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Layout\Content; |
|||
use Illuminate\Http\Request; |
|||
use Illuminate\Support\Facades\Log; |
|||
|
|||
class OrderStateHandle extends RowAction |
|||
{ |
|||
|
|||
protected $model; |
|||
protected $state; |
|||
protected $title; |
|||
protected $content; |
|||
public function __construct($title=null,$state=null) |
|||
{ |
|||
parent::__construct($title); |
|||
$this->state = $state; |
|||
} |
|||
|
|||
/** |
|||
* 处理请求 |
|||
* |
|||
* @param Request $request |
|||
* |
|||
* @return \Dcat\Admin\Actions\Response |
|||
*/ |
|||
public function handle(Request $request) |
|||
{ |
|||
// 获取当前行ID
|
|||
$id = $this->getKey(); |
|||
$orderMain = new ImsCjdcOrderMain(); |
|||
$state = $request->get('state'); |
|||
$res = $orderMain->modifyState($id,$state); |
|||
if ($res&&$state==4){ |
|||
$order = $orderMain::where('id',$id)->first(); |
|||
//记录分账流水
|
|||
$result = json_decode(Rpc::separateAccounts($id,$order->user_id)); |
|||
if ($result->result){ |
|||
return $this->response()->success('操作成功')->refresh(); |
|||
}else{ |
|||
Log::error('订单完成时分账接口调用失败',$result); |
|||
return $this->response()->error('操作失败')->refresh(); |
|||
} |
|||
} |
|||
if ($res==true){ |
|||
return $this->response()->success('操作成功')->refresh(); |
|||
}else{ |
|||
return $this->response()->error('操作失败'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 设置要POST到接口的数据 |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function parameters() |
|||
{ |
|||
return [ |
|||
'state' => $this->state, |
|||
]; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
use App\Libs\SsdbClient; |
|||
use App\Models\v3\Category as CategoryModel; |
|||
|
|||
class CategoryTieForm extends Form |
|||
{ |
|||
|
|||
protected $ssdb; |
|||
|
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(array $input) |
|||
{ |
|||
$ids = $input['category_ids']; |
|||
$category = CategoryModel::select('id','title','cover_img','sort')->whereIn('id',$ids)->get(); |
|||
$data = []; |
|||
if(!empty($category)){ |
|||
foreach ($category as $key => $value){ |
|||
$data[$value->id] = json_encode([ |
|||
'icon' => $value->cover_img, |
|||
'name' => $value->title, |
|||
'sort' => $value->sort |
|||
]); |
|||
} |
|||
if(count($data) > 0){ |
|||
$this->ssdb->client()->hclear('applet_index_category'); |
|||
} |
|||
} |
|||
|
|||
$category = $this->ssdb->client()->multi_hset('applet_index_category',$data); |
|||
if($category === false){ |
|||
return $this->error('修改失败'); |
|||
} |
|||
|
|||
return $this->success('修改成功', '/category'); |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
$this->ssdb = new SsdbClient(); |
|||
$category = $this->ssdb->client()->hgetall('applet_index_category'); |
|||
$select = array_keys($category); |
|||
|
|||
// 只查一级
|
|||
$parentList = CategoryModel::where('parent_id',0)->pluck('title','id')->toArray(); |
|||
|
|||
$this->multipleSelect('category_ids','选择分类')->required()->options($parentList)->value($select)->default($select); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
return []; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use App\Models\v3\Goods as GoodsModel; |
|||
use App\Models\v3\GoodsBanners as GoodsBannerModel; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class GoodsCopyForm extends Form |
|||
{ |
|||
|
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(array $input) |
|||
{ |
|||
// 获取外部传递参数
|
|||
$goodsId = $input['goods_id']; |
|||
$storeIds= $input['store_ids']; |
|||
|
|||
$goods = GoodsModel::find($goodsId); |
|||
$goodsBanners = GoodsBannerModel::where('goods_id',$goodsId)->get(); |
|||
$markets = StoreModel::whereIn('id',$storeIds)->pluck('market_id','id'); |
|||
foreach($storeIds as $key =>$value){ |
|||
$storeId = $value; |
|||
$model = new GoodsModel(); |
|||
|
|||
$model->store_id = $storeId; |
|||
$model->market_id = $markets[$storeId]; |
|||
$model->category_id = $goods->category_id; |
|||
|
|||
$model->name = $goods->name; |
|||
$model->cover_img = $goods->cover_img; |
|||
$model->goods_unit = $goods->goods_unit; |
|||
|
|||
$model->tags = $goods->tags; |
|||
$model->spec = $goods->spec; |
|||
$model->details_imgs = $goods->details_imgs; |
|||
$model->content = $goods->content; |
|||
$model->details = $goods->details; |
|||
|
|||
$model->price = $goods->price; |
|||
$model->original_price = $goods->original_price; |
|||
$model->vip_price = $goods->vip_price; |
|||
|
|||
$model->start_num = $goods->start_num; |
|||
$model->restrict_num = $goods->restrict_num; |
|||
$model->is_infinite = $goods->is_infinite; |
|||
$model->inventory = $goods->inventory; |
|||
|
|||
$model->on_sale = $goods->on_sale; |
|||
$model->sort = $goods->sort; |
|||
$model->remark = $goods->remark; |
|||
|
|||
if($model->save() && !empty($goodsBanners)){ |
|||
$goodsId = $model->getKey(); |
|||
$banners = []; |
|||
foreach($goodsBanners as $kb => $vb){ |
|||
$banners[] = [ |
|||
'goods_id' => $goodsId, |
|||
'type' => $vb->type, |
|||
'path' => $vb->path, |
|||
'sort' => $vb->sort, |
|||
'created_at' => time(), |
|||
'updated_at' => time(), |
|||
]; |
|||
GoodsBannerModel::insert($banners); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
return $this->success('修改成功', '/goods'); |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
$id = $this->getKey(); |
|||
$goods = GoodsModel::select('name')->find($id); |
|||
$this->hidden('goods_id')->value($id); |
|||
$this->display('name')->value($goods->name); |
|||
$stores = StoreModel::getStoreArray(); |
|||
$this->multipleSelect('store_ids','选择店铺')->required()->options($stores)->help('选择店铺,将当前商品复制到所选店铺。注意选择重复店铺问题!!!'); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
return []; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,57 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use App\Models\ImsCjdcOrderMain; |
|||
use App\Models\LanzuServiceHorseman; |
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
|
|||
class SelectHorseman extends Form |
|||
{ |
|||
|
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
protected $orderId; |
|||
public function handle(array $input) |
|||
{ |
|||
$hid = request()->get('horseman_id'); |
|||
$oid = request()->get('order_id'); |
|||
$current_page = request()->get('current_page'); |
|||
$result = ImsCjdcOrderMain::where('id',$oid)->update(['shipping_type'=>1,'horseman_id'=>$hid,'updated_at'=>time()]); |
|||
if ($result){ |
|||
return $this->success('操作成功',"order?page={$current_page}"); |
|||
}else{ |
|||
return $this->error('操作失败'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
|
|||
$this->select('horseman_id','配送员') |
|||
->options(LanzuServiceHorseman::getHorseman()) |
|||
->required(); |
|||
$this->hidden('order_id')->value($this->data['order_id']); |
|||
$this->hidden('current_page')->value($this->data['current_page']); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
|
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Metrics\Examples\Community; |
|||
|
|||
use App\Models\LanzuUserBalance; |
|||
use Dcat\Admin\Widgets\Metrics\Card; |
|||
|
|||
class TotalAmount extends Card |
|||
{ |
|||
protected $uid; |
|||
protected $uType; |
|||
|
|||
public function __construct($uid, $uType) |
|||
{ |
|||
$this->uid = $uid; |
|||
$this->uType =$uType; |
|||
parent::__construct('可提现金额(元)'); |
|||
} |
|||
|
|||
protected function init() |
|||
{ |
|||
parent::init(); |
|||
$this->content(LanzuUserBalance::getBalance($this->uid, $this->uType)); |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 渲染卡片内容 |
|||
* @return string |
|||
*/ |
|||
public function renderContent() |
|||
{ |
|||
$content = parent::renderContent(); |
|||
return <<<HTML |
|||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|||
<h2 class="ml-1 font-large-1">{$content}</h2> |
|||
</div> |
|||
HTML; |
|||
} |
|||
|
|||
} |
|||
@ -1,9 +1,8 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Metrics\Examples; |
|||
|
|||
|
|||
namespace App\Admin\Metrics\Examples\Community; |
|||
|
|||
use App\Models\LanzuCsInfo; |
|||
use Dcat\Admin\Widgets\Metrics\Card; |
|||
@ -1,7 +1,7 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\admin\Metrics\Community; |
|||
namespace App\Admin\Metrics\Examples\Community; |
|||
|
|||
|
|||
use App\Models\LanzuUserRelationBind; |
|||
@ -1,25 +1,23 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\admin\Metrics\Community; |
|||
namespace App\Admin\Metrics\Examples\ServiceCard; |
|||
|
|||
|
|||
|
|||
use App\Models\LanzuCsInfo; |
|||
use App\Models\LanzuMpInfo; |
|||
use Dcat\Admin\Widgets\Metrics\Card; |
|||
|
|||
class TotalCommunity extends Card |
|||
class TotalMp extends Card |
|||
{ |
|||
protected function init() |
|||
{ |
|||
parent::init(); |
|||
$this->title = '社区总数'; |
|||
$this->content(LanzuCsInfo::count()); |
|||
$this->title = '服务商量数'; |
|||
$this->content(LanzuMpInfo::count()); |
|||
} |
|||
|
|||
/** |
|||
* 渲染卡片内容. |
|||
* |
|||
* 渲染卡片内容 |
|||
* @return string |
|||
*/ |
|||
public function renderContent() |
|||
@ -0,0 +1,44 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Metrics\Examples\ServiceCard; |
|||
|
|||
|
|||
use App\Models\ImsCjdcStore; |
|||
use App\Models\LanzuMmInfo; |
|||
use App\Models\LanzuStore; |
|||
use Dcat\Admin\Admin; |
|||
use Dcat\Admin\Widgets\Metrics\Card; |
|||
|
|||
class TotalStore extends Card |
|||
{ |
|||
|
|||
protected function init() |
|||
{ |
|||
parent::init(); |
|||
$this->title = '商户数'; |
|||
$aud = Admin::user(); |
|||
$count = 0; |
|||
if ($aud->isRole('lanzu_mm')){ |
|||
$mm = LanzuMmInfo::where('admin_user_id',$aud->id)->first(); |
|||
if ($mm){ |
|||
$count = ImsCjdcStore::where('mm_user_id',$mm->user_id)->count(); |
|||
} |
|||
}elseif($aud->isRole('lanzu_mp')){ |
|||
$count = 0; |
|||
}else{ |
|||
$count = ImsCjdcStore::count(); |
|||
} |
|||
$this->content($count); |
|||
} |
|||
|
|||
public function renderContent() |
|||
{ |
|||
$content = parent::renderContent(); |
|||
return <<<HTML |
|||
<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px"> |
|||
<h2 class="ml-1 font-large-1">{$content}</h2> |
|||
</div> |
|||
HTML; |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories; |
|||
|
|||
use App\Models\LanzuServiceHorseman as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class LanzuServiceHorseman extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\Banners as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Banners extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\Coupon as Model; |
|||
use Dcat\Admin\Grid\Model as GridModel; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
use App\Models\v3\CouponUse as CouponUseModel; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class Coupon extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
|
|||
/** |
|||
* 查询Grid表格数据. |
|||
* |
|||
* @param Grid\Model $model |
|||
* |
|||
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator|Collection|array |
|||
*/ |
|||
public function get(GridModel $model) |
|||
{ |
|||
$this->setSort($model); |
|||
$this->setPaginate($model); |
|||
|
|||
$query = $this->newQuery(); |
|||
|
|||
if ($this->relations) { |
|||
$query->with($this->relations); |
|||
} |
|||
|
|||
$model->getQueries()->unique()->each(function ($value) use (&$query) { |
|||
if ($value['method'] == 'paginate') { |
|||
$value['arguments'][1] = $this->getGridColumns(); |
|||
} elseif ($value['method'] == 'get') { |
|||
$value['arguments'] = [$this->getGridColumns()]; |
|||
} |
|||
|
|||
$query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []); |
|||
}); |
|||
|
|||
// dd(CouponUseModel::where('system_coupon_id',16)->sum('number'));
|
|||
// $u = DB::table('ims_system_coupon_user_use')->where('system_coupon_id',16)->count('number');
|
|||
// dd($u);
|
|||
// $list = $query->toArray();
|
|||
// foreach($list as &$value){
|
|||
// // 查询使用数量
|
|||
// $value['use_total'] = CouponUseModel::where('system_coupon_id',16)->count('number');
|
|||
// dd( $value['use_total'] );
|
|||
// }
|
|||
|
|||
return $query; |
|||
} |
|||
} |
|||
@ -1,8 +1,8 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories; |
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\CouponSetting as Model; |
|||
use App\Models\v3\CouponSetting as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class CouponSetting extends EloquentRepository |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\Goods as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Goods extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\GoodsActivity as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class GoodsActivity extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\GoodsCategory as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class GoodsCategory extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Repositories\v3; |
|||
|
|||
use App\Models\v3\Store as Model; |
|||
use Dcat\Admin\Repositories\EloquentRepository; |
|||
|
|||
class Store extends EloquentRepository |
|||
{ |
|||
/** |
|||
* Model. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $eloquentClass = Model::class; |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use App\Models\LanzuGoods; |
|||
|
|||
class EsTest extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'command:EsTest'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 测试Es搜索'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
$gds = LanzuGoods::search('火龙果')->get(); |
|||
dd($gds); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use App\Models\EsDict; |
|||
|
|||
class GenEsDicts extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'command:GenEsDicts'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 生成Es分词数据'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
$es = EsDict::whereNull('deleted_at')->pluck('title')->toArray(); |
|||
//dd($es);
|
|||
$es = implode("\n",$es); |
|||
$file_path = public_path() . '/es_use_dicts.txt'; |
|||
file_put_contents($file_path,$es); |
|||
|
|||
$es = EsDict::whereNotNull('deleted_at')->pluck('title')->toArray(); |
|||
$es = implode("\n",$es); |
|||
$file_path = public_path() . '/es_unuse_dicts.txt'; |
|||
file_put_contents($file_path,$es); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class MigrateMarketData extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:market'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'migrate market data'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
// get old data from old table
|
|||
$oldData = DB::table('ims_cjdc_market')->get(); |
|||
|
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
|
|||
$newData = []; |
|||
foreach ($oldData as $key => $value) { |
|||
$coordinates = explode(',', $value->coordinates); |
|||
$newData[] = [ |
|||
'mp_id' => $value->mp_id ?? 0, |
|||
'name' => $value->name ?? '', |
|||
'logo' => $value->logo ?? '', |
|||
'introduce' => $value->introduce ?? '', |
|||
'imgs' => $value->imgs ?? '', |
|||
'province_id' => 2162, |
|||
'city_id' => 2163, |
|||
'region_id' => 0, |
|||
'address' => $value->address ?? '', |
|||
'tel' => $value->tel ?? '', |
|||
'lat' => $coordinates[0] ?? '', |
|||
'lng' => $coordinates[1] ?? '', |
|||
'status' => $value->status ?? 1, |
|||
'sort' => $value->sort ?? 1, |
|||
'created_at' => $value->addtime ? strtotime($value->addtime) : 0, |
|||
'updated_at' => $value->addtime ? strtotime($value->addtime) : 0, |
|||
]; |
|||
|
|||
$bar->advance(); |
|||
} |
|||
|
|||
// insert new data to new table
|
|||
DB::table('lanzu_market')->insert($newData); |
|||
|
|||
$bar->finish(); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,146 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class MigrateOrder extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:order'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'migrate order data'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
// main order
|
|||
$orderMain = DB::table('ims_cjdc_order_main')->get(); |
|||
|
|||
$bar = $this->output->createProgressBar(count($orderMain)); |
|||
$bar->start(); |
|||
|
|||
foreach ($orderMain as $k => $main) { |
|||
DB::beginTransaction(); |
|||
try { |
|||
// 主订单
|
|||
$dataMain = [ |
|||
'market_id' => $main->market_id ?? 0, |
|||
'order_num' => $main->order_num ?? '', |
|||
'global_order_id' => $main->global_order_id ?? 0, |
|||
'user_id' => $main->user_id ?? 0, |
|||
'pay_type' => $main->pay_type ?? 0, |
|||
'type' => $main->type ?? 0, |
|||
'order_type' => $main->order_type ?? 0, |
|||
'shipping_type' => $main->dada_status == 0 ? 1 : 2, |
|||
'money' => $main->money ?? 0, |
|||
'total_money' => $main->total_money ?? 0, |
|||
'services_money' => 0, |
|||
'coupon_money' => $main->yhq_money2 ?? 0, |
|||
'delivery_money' => $main->dada_fee ?? 0, |
|||
'state' => $main->state ?? 0, |
|||
'pay_time' => $main->pay_time ? strtotime($main->pay_time) : 0, |
|||
'receive_time' => $main->jd_time ? strtotime($main->jd_time) : 0, |
|||
'delivery_time' => 0, |
|||
'complete_time' => $main->complete_time ? strtotime($main->complete_time) : 0, |
|||
'cancel_time' => $main->complete_time ? strtotime($main->complete_time) : 0, |
|||
'refund_time' => $main->refund_time ?? 0, |
|||
'tel' => $main->tel ?? '', |
|||
'address' => $main->address ?? '', |
|||
'lat' => $main->lat ?? '', |
|||
'lng' => $main->lng ?? '', |
|||
'name' => $main->name ?? '', |
|||
'print_num' => $main->print_num ?? 0, |
|||
'plat' => $main->plat ?? 0, |
|||
'refuse_refund_note' => $main->refuse_refund_note ?? '', |
|||
'delivery_time_note' => $main->delivery_time ?? '', |
|||
'total_refund_note' => $main->total_refund_note ?? '', |
|||
'note' => $main->note ?? '', |
|||
'created_at' => $main->time_add ?? 0, |
|||
'updated_at' => 0, |
|||
]; |
|||
$newMainId = DB::table('lanzu_order_main')->insertGetId($dataMain); |
|||
|
|||
// 子订单
|
|||
$orderChildren = DB::table('ims_cjdc_order')->where(['order_main_id' => $main->id])->get(); |
|||
foreach ($orderChildren as $kChild => $child) { |
|||
// 子订单
|
|||
$dataChild = [ |
|||
'order_main_id' => $newMainId ?? 0, |
|||
'user_id' => $child->user_id ?? 0, |
|||
'store_id' => $child->store_id ?? 0, |
|||
'status' => 1, |
|||
'refund_time' => 0, |
|||
'order_num' => $child->order_num ?? '', |
|||
'money' => $child->money ?? 0, |
|||
'oid' => $child->oid ?? 0, |
|||
'refuse_refund_note' => '', |
|||
'refund_note' => '', |
|||
'note' => $child->note ?? '', |
|||
'created_at' => $child->time_add ? strtotime($child->time_add) : 0, |
|||
'updated_at' => $child->time_add ? strtotime($child->time_add) : 0, |
|||
]; |
|||
$newChildId = DB::table('lanzu_order')->insertGetId($dataChild); |
|||
|
|||
// 订单商品
|
|||
$orderGoods = DB::table('ims_cjdc_order_goods')->where(['order_id' => $child->id])->get(); |
|||
$dataGoods = []; |
|||
foreach ($orderGoods as $kGoods => $goods) { |
|||
// 订单商品
|
|||
$dataGoods[] = [ |
|||
'order_id' => $newChildId ?? 0, |
|||
'goods_id' => $goods->good_id ?? 0, |
|||
'number' => $goods->number ?? 0, |
|||
'status' => 1, |
|||
'price' => $goods->money ?? 0, |
|||
'original_price' => $goods->money2 ?? 0, |
|||
'vip_price' => $goods->vip_money ?? 0, |
|||
'name' => $goods->name ?? '', |
|||
'goods_unit' => $goods->good_unit ?? '', |
|||
'cover_img' => $goods->img ?? '', |
|||
'spec' => json_encode([]), |
|||
'refund_time' => 0, |
|||
'created_at' => time(), |
|||
'updated_at' => time(), |
|||
'refuse_refund_note' => '', |
|||
]; |
|||
} |
|||
DB::table('lanzu_order_goods')->insert($dataGoods); |
|||
} |
|||
$bar->advance(); |
|||
DB::commit(); |
|||
} catch (\Exception $e) { |
|||
$this->info(json_encode(['order_id' => $main->id, 'exception' => $e->getMessage()])); |
|||
DB::rollBack(); |
|||
} |
|||
} |
|||
|
|||
$bar->finish(); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class MigrateOrderGoods extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:orderGoods'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'migrate order goods data'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
// get old data from old table
|
|||
$oldData = DB::table('ims_cjdc_order_goods')->get(); |
|||
|
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
|
|||
$newData = []; |
|||
foreach ($oldData as $key => $value) { |
|||
|
|||
$goods =DB::table('ims_cjdc_goods')->find($value->good_id); |
|||
|
|||
$newData[] = [ |
|||
'order_id' => $value->order_id ?? 0, |
|||
'goods_id' => $value->good_id ?? 0, |
|||
'number' => $value->number ?? 0, |
|||
'status' => 1, |
|||
'price' => $value->money ?? 0, |
|||
'original_price' => $goods->money2 ?? 0, |
|||
'vip_price' => $goods->vip_money ?? 0, |
|||
'name' => $value->name ?? '', |
|||
'goods_unit' => $value->good_unit ?? '', |
|||
'cover_img' => $value->img ?? '', |
|||
'spec' => json_encode([]), |
|||
'refund_time' => 0, |
|||
'created_at' => time(), |
|||
'updated_at' => time(), |
|||
'refuse_refund_note' => '', |
|||
]; |
|||
|
|||
$bar->advance(); |
|||
} |
|||
|
|||
// insert new data to new table
|
|||
DB::table('lanzu_order_goods')->insert($newData); |
|||
|
|||
$bar->finish(); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class MigrateOrderMain extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:orderMain'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'migrate order main data'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
// get old data from old table
|
|||
$oldData = DB::table('ims_cjdc_order_main')->get(); |
|||
|
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
|
|||
$newData = []; |
|||
foreach ($oldData as $key => $value) { |
|||
|
|||
$newData[] = [ |
|||
'market_id' => $value->market_id ?? 0, |
|||
'order_num' => $value->order_num ?? '', |
|||
'global_order_id' => $value->global_order_id ?? 0, |
|||
'user_id' => $value->user_id ?? 0, |
|||
'pay_type' => $value->pay_type ?? 0, |
|||
'type' => $value->type ?? 0, |
|||
'order_type' => $value->order_type ?? 0, |
|||
'shipping_type' => $value->dada_status==0 ? 1 : 2, |
|||
'money' => $value->money ?? 0, |
|||
'total_money' => $value->total_money ?? 0, |
|||
'services_money' => 0, |
|||
'coupon_money' => $value->yhq_money2 ?? 0, |
|||
'delivery_money' => $value->dada_fee ?? 0, |
|||
'state' => $value->state ?? 0, |
|||
'pay_time' => $value->pay_time ? strtotime($value->pay_time) : 0, |
|||
'receive_time' => $value->jd_time ? strtotime($value->jd_time) : 0, |
|||
'delivery_time' => 0, |
|||
'complete_time' => $value->complete_time ? strtotime($value->complete_time) : 0, |
|||
'cancel_time' => $value->complete_time ? strtotime($value->complete_time) : 0, |
|||
'refund_time' => $value->refund_time ?? 0, |
|||
'tel' => $value->tel ?? '', |
|||
'address' => $value->address ?? '', |
|||
'lat' => $value->lat ?? '', |
|||
'lng' => $value->lng ?? '', |
|||
'name' => $value->name ?? '', |
|||
'print_num' => $value->print_num ?? 0, |
|||
'plat' => $value->plat ?? 0, |
|||
'refuse_refund_note' => $value->refuse_refund_note ?? '', |
|||
'delivery_time_note' => $value->delivery_time ?? '', |
|||
'total_refund_note' => $value->total_refund_note ?? '', |
|||
'note' => $value->note ?? '', |
|||
'created_at' => $value->time_add ?? 0, |
|||
'updated_at' => 0, |
|||
]; |
|||
|
|||
$bar->advance(); |
|||
} |
|||
|
|||
// insert new data to new table
|
|||
DB::table('lanzu_order_main')->insert($newData); |
|||
|
|||
$bar->finish(); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class MigrateUserAddr extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:userAddr'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'migrate user addr data'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
// get old data from old table
|
|||
$oldData = DB::table('ims_cjdc_useradd')->get(); |
|||
|
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
|
|||
$newData = []; |
|||
foreach ($oldData as $key => $value) { |
|||
$newData[] = [ |
|||
'user_id' => $value->user_id ?? '', |
|||
'user_name' => $value->user_name ?? '', |
|||
'address' => $value->address ?? '', |
|||
'gender' => $value->sex ?? 0, |
|||
'lat' => $value->lat ?? '', |
|||
'lng' => $value->lng ?? '', |
|||
'tel' => $value->tel ?? '', |
|||
'tags' => json_encode([]), |
|||
'created_at' => time(), |
|||
'updated_at' => time(), |
|||
]; |
|||
|
|||
$bar->advance(); |
|||
} |
|||
|
|||
// insert new data to new table
|
|||
DB::table('lanzu_user_address')->insert($newData); |
|||
|
|||
$bar->finish(); |
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,66 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use DB; |
|||
|
|||
class OnlineOrderStatis extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'command:OnlineOrderStatis'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 在线订单情况统计'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
$ret = DB::select("select main.id as '系统订单号',
|
|||
main.order_num '订单号', |
|||
main.global_order_id '全局订单ID', |
|||
main.money '实付金额', |
|||
main.total_money '订单原金额', |
|||
main.yhq_money2 '优惠金额', |
|||
market.name '市场名', |
|||
main.user_id '下单用户ID', |
|||
user.name '系统用户名', |
|||
main.name '下单用户名', |
|||
main.address '下单用户地址', |
|||
FROM_UNIXTIME(main.time_add,'%Y-%m-%d %H:%i:%s') '下单时间' |
|||
FROM ims_cjdc_order_main `main` |
|||
INNER JOIN ims_cjdc_user `user` ON user.id=main.user_id |
|||
INNER JOIN `ims_cjdc_market` `market` ON main.`market_id`=market.id |
|||
where `time_add` >= 1599148800 and `time_add` <=1599235199 and `type` = 1 and state IN (4,5,10)");
|
|||
|
|||
$totalCount = count($ret); |
|||
foreach ($ret as $key => $item) { |
|||
|
|||
} |
|||
|
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use App\Models\LanzuGoods; |
|||
|
|||
use App\Models\LanzuStore; |
|||
|
|||
|
|||
class SetGoodsMarketId extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:SetGoodsMarketId'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 根据商品表中storeid设置市场id'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
|
|||
$goods = LanzuGoods::all(); |
|||
|
|||
$no_store_ids = []; |
|||
|
|||
foreach($goods as $key => $item){ |
|||
$store = LanzuStore::find($item->store_id); |
|||
if($store){ |
|||
$item->market_id = $store->market_id; |
|||
$item->save(); |
|||
print_r($item->id.'\r\n'); |
|||
}else{ |
|||
$no_store_ids[] = $item->store_id; |
|||
break; |
|||
} |
|||
} |
|||
|
|||
var_dump($no_store_ids); |
|||
|
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,84 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use App\Models\v3\Store as StoreModel; |
|||
use Illuminate\Support\Facades\DB; |
|||
|
|||
class SetStoreBalance extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:setStoreBalance'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 在user_balance表添加商户钱包'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* 添加商户钱包 |
|||
* 先判断是否存在,不存在则添加一条店铺的钱包记录 |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
$oldData = DB::table('ims_cjdc_store')->get(); |
|||
var_dump('start_time:'.date('H:i:s',time())); |
|||
$bar = $this->output->createProgressBar(count($oldData)); |
|||
$bar->start(); |
|||
|
|||
$data = []; |
|||
$newData = []; |
|||
foreach ($oldData as $key => $value){ |
|||
// 查询店铺是否存在balance
|
|||
$exist = DB::table('lanzu_user_balance') |
|||
->where('source_id',$value->id) |
|||
->where('user_type',5) |
|||
->first(); |
|||
|
|||
if(empty($exist)){ |
|||
$newData[] = [ |
|||
'source_id' => $value->id, |
|||
'user_type' => 5, |
|||
'balance' => 0, |
|||
'created_at' => time(), |
|||
'updated_at' => time() |
|||
]; |
|||
}else{ |
|||
$data[] = [ |
|||
'store_id' => $value->id, |
|||
'balance_id' => $exist->id |
|||
]; |
|||
} |
|||
$bar->advance(); |
|||
} |
|||
// 添加到新表
|
|||
$res = DB::table('lanzu_user_balance')->insert($newData); |
|||
|
|||
$bar->finish(); |
|||
var_dump(' end_time: '.date('H:i:s',time())); |
|||
var_dump('new_total: '.count($newData)); |
|||
var_dump('exist: '.count($data)); |
|||
var_dump('res: '.$res); |
|||
// var_dump($data);
|
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
<?php |
|||
|
|||
namespace App\Console\Commands; |
|||
|
|||
use Illuminate\Console\Command; |
|||
use Illuminate\Database\Schema\Blueprint; |
|||
use Illuminate\Support\Facades\DB; |
|||
use Illuminate\Support\Facades\Schema; |
|||
|
|||
class setStoreUsers extends Command |
|||
{ |
|||
/** |
|||
* The name and signature of the console command. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $signature = 'migrateData:setStoreUsers'; |
|||
|
|||
/** |
|||
* The console command description. |
|||
* |
|||
* @var string |
|||
*/ |
|||
protected $description = 'Command 店铺的账号表整理'; |
|||
|
|||
/** |
|||
* Create a new command instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
parent::__construct(); |
|||
} |
|||
|
|||
/** |
|||
* Execute the console command. |
|||
* 店铺的登录账号,店长、店员 |
|||
* 将旧账号表的关联的店铺id和角色洗到新的店铺账号表 |
|||
* @return int |
|||
*/ |
|||
public function handle() |
|||
{ |
|||
// 如果表不存在则创建
|
|||
if(!Schema::hasTable('lanzu_store_users')){ |
|||
Schema::create('lanzu_store_users',function (Blueprint $table){ |
|||
$table->id(); |
|||
}); |
|||
} |
|||
$account = DB::table('ims_cjdc_account')->get(); |
|||
$bar = $this->output->createProgressBar(count($account)); |
|||
$bar->start(); |
|||
|
|||
foreach ($account as $ka => $va){ |
|||
$data = []; |
|||
$storeUsers = DB::table('lanzu_store_users')->find($va->uid); |
|||
if(!empty($storeUsers)){ |
|||
$data =[ |
|||
'user_category'=>$va->role, |
|||
'store_id'=>$va->storeid |
|||
]; |
|||
DB::table('lanzu_store_users')->where('id',$va->uid)->update($data); |
|||
} |
|||
$bar->advance(); |
|||
} |
|||
|
|||
$bar->finish(); |
|||
|
|||
return 0; |
|||
} |
|||
} |
|||
@ -0,0 +1,338 @@ |
|||
<?php |
|||
|
|||
use think\Db; |
|||
|
|||
header("Content-type: text/html; charset=utf-8"); |
|||
include 'httpclient.php'; |
|||
|
|||
define('USER', '13161443713@163.com'); //*必填*:飞鹅云后台注册账号
|
|||
define('UKEY', 'XsaHzgePdyWTfcMX'); //*必填*: 飞鹅云后台注册账号后生成的UKEY 【备注:这不是填打印机的KEY】
|
|||
define('SN', '550510805'); //*必填*:打印机编号,必须要在管理后台里添加打印机或调用API接口添加之后,才能调用API
|
|||
|
|||
//以下参数不需要修改
|
|||
define('IP', 'api.feieyun.cn'); //接口IP或域名
|
|||
define('PORT', 80); //接口IP端口
|
|||
define('PATH', '/Api/Open/'); //接口路径
|
|||
|
|||
//拼凑订单内容时可参考如下格式
|
|||
//根据打印纸张的宽度,自行调整内容的格式,可参考下面的样例格式
|
|||
$content = '<CB>测试打印</CB><BR>'; |
|||
$content .= '名称 单价 数量 金额<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '饭 10.0 10 100.0<BR>'; |
|||
$content .= '炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '备注:加辣<BR>'; |
|||
$content .= '合计:xx.0元<BR>'; |
|||
$content .= '送货地点:广西南宁五象新区<BR>'; |
|||
$content .= '联系电话:13888888888888<BR>'; |
|||
$content .= '订餐时间:2014-08-08 08:08:08<BR>'; |
|||
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码
|
|||
//标签说明:
|
|||
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸,
|
|||
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印
|
|||
|
|||
/** |
|||
* [打印订单接口 Open_printMsg] |
|||
* @param [string] $sn [打印机编号sn] |
|||
* @param [string] $content [打印内容] |
|||
* @param [string] $times [打印联数] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printMsg($sn, $content, $times = 1) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printMsg', |
|||
'sn' => $sn, |
|||
'content' => $content, |
|||
'times' => $times//打印次数
|
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
//服务器返回的JSON字符串,建议要当做日志记录起来
|
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [批量添加打印机接口 Open_printerAddlist] |
|||
* @param [string] $printerContent [打印机的sn#key]
|
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printerAddlist($printerContent) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printerAddlist', |
|||
'printerContent' => $printerContent |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [批量删除打印机 Open_printerDelList] |
|||
* @param [string] $snlist [打印机编号,多台打印机请用减号“-”连接起来] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function printerDelList($snlist) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_printerDelList', |
|||
'snlist' => $snlist |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [查询订单是否打印成功接口 Open_queryOrderState] |
|||
* @param [string] $orderid [调用打印机接口成功后,服务器返回的JSON中的编号 例如:123456789_20190919163739_95385649] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function queryOrderState($orderid) |
|||
{ |
|||
$time = time(); //请求时间
|
|||
$msgInfo = array( |
|||
'user' => USER, |
|||
'stime' => $time, |
|||
'sig' => signature($time), |
|||
'apiname' => 'Open_queryOrderState', |
|||
'orderid' => $orderid |
|||
); |
|||
$client = new HttpClient(IP, PORT); |
|||
if (!$client->post(PATH, $msgInfo)) { |
|||
echo 'error'; |
|||
} else { |
|||
$result = $client->getContent(); |
|||
return $result; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* [signature 生成签名] |
|||
* @param [string] $time [当前UNIX时间戳,10位,精确到秒] |
|||
* @return [string] [接口返回值] |
|||
*/ |
|||
function signature($time) |
|||
{ |
|||
return sha1(USER . UKEY . $time);//公共参数,请求公钥
|
|||
} |
|||
|
|||
function FeiePrint($order_num) |
|||
{ |
|||
//$data = DB::table('ims_cjdc_order_main')
|
|||
// ->alias('m')
|
|||
// ->join(['ims_cjdc_order'=>'o'],'o.order_main_id = m.id','inner')
|
|||
// ->join(['ims_cjdc_order_goods'=>'g'],'o.id = g.order_id','inner')
|
|||
// ->join(['ims_cjdc_feprint'=>'f'],'m.market_id = f.market_id','inner')
|
|||
// ->join(['ims_cjdc_store'=>'s'],'s.id = o.store_id','inner')
|
|||
// //->distinct(true)
|
|||
// ->where('m.order_num',$order_num)
|
|||
// ->field("o.note as o_note,g.name,g.number,g.money,g.good_unit,m.delivery_time as ps_time,m.address,m.note,m.name as user_name,m.dada_fee,m.money as m_money,m.yhq_money2,m.box_money,f.sn,m.tel,m.order_num,g.id,g.spec,s.name as shopname")
|
|||
// ->order('s.id')
|
|||
// ->select();
|
|||
|
|||
$data = Db::table('ims_cjdc_order_main as m') |
|||
->join('ims_cjdc_order as o','o.order_main_id', '=', 'm.id','inner') |
|||
->join('ims_cjdc_order_goods as g','o.id','=', 'g.order_id','inner') |
|||
->join('ims_cjdc_feprint as f','m.market_id','=', 'f.market_id','inner') |
|||
->join('ims_cjdc_store as s','s.id','=', 'o.store_id','inner') |
|||
->where('m.global_order_id', $order_num) |
|||
->selectRaw("o.note as o_note,g.name,g.number,g.money,g.good_unit,m.delivery_time as ps_time,m.address,m.note,m.name as user_name,m.dada_fee,m.money as m_money,m.yhq_money2,m.box_money,f.sn,m.tel,m.order_num,g.id,g.spec,s.name as shopname") |
|||
->orderBy('s.id') |
|||
->get() |
|||
->toArray(); |
|||
|
|||
// $order_goods = Db::table('ims_cjdc_order_goods')->where('order_id', $order_main['id'])->field("name,number,money")->select();
|
|||
// $sn = Db::table('ims_cjdc_feprint')->where('market_id', $order_main['market_id'])->value("sn");
|
|||
$content = PrintFormat($data, 14, 6, 3, 6); |
|||
$res = printMsg($data[0]['sn'], $content, 1); |
|||
return ($res); |
|||
} |
|||
|
|||
function PrintFormat($arr, $A, $B, $C, $D) |
|||
{ |
|||
$orderInfo = '<CB>懒族生活</CB><BR>'; |
|||
$orderInfo .= '名称 单价 数量 金额<BR>'; |
|||
$orderInfo .= '--------------------------------<BR>'; |
|||
$shopname = ""; |
|||
$shopnum = 0; |
|||
foreach ($arr as $k5 => $v5) { |
|||
if ($shopname != $v5['shopname']) { |
|||
if ($shopname != "") { |
|||
$orderInfo .= ' <BR>'; |
|||
} |
|||
$shopnum++; |
|||
$orderInfo .= "<C>(" . $shopnum . ")" .$v5['shopname'] . '</C><BR>'; |
|||
$shopname = $v5['shopname']; |
|||
} |
|||
$name = $v5['name']; |
|||
if(!empty($v5['spec'])) { |
|||
$name .= "(规格:". $v5['spec'].")"; |
|||
}elseif (!empty($v5['good_unit'])){ |
|||
$name .= "(规格:". $v5['good_unit'].")"; |
|||
} |
|||
$price = $v5['money']; |
|||
$num = $v5['number']; |
|||
$prices = sprintf("%.2f",$v5['money']*$v5['number']); |
|||
$kw3 = ''; |
|||
$kw1 = ''; |
|||
$kw2 = ''; |
|||
$kw4 = ''; |
|||
$str = $name; |
|||
$blankNum = $A;//名称控制为14个字节
|
|||
$lan = mb_strlen($str,'utf-8'); |
|||
$m = 0; |
|||
$j=1; |
|||
$blankNum++; |
|||
$result = array(); |
|||
if(strlen($price) < $B){ |
|||
$k1 = $B - strlen($price); |
|||
for($q=0;$q<$k1;$q++){ |
|||
$kw1 .= ' '; |
|||
} |
|||
$price = $kw1.$price; |
|||
} |
|||
if(strlen($num) < $C){ |
|||
$k2 = $C - strlen($num); |
|||
for($q=0;$q<$k2;$q++){ |
|||
$kw2 .= ' '; |
|||
} |
|||
$num = $kw2.$num; |
|||
} |
|||
if(strlen($prices) < $D){ |
|||
$k3 = $D - strlen($prices); |
|||
for($q=0;$q<$k3;$q++){ |
|||
$kw4 .= ' '; |
|||
} |
|||
$prices = $kw4.$prices; |
|||
} |
|||
for ($i=0;$i<$lan;$i++){ |
|||
$new = mb_substr($str,$m,$j,'utf-8'); |
|||
$j++; |
|||
if(mb_strwidth($new,'utf-8')<$blankNum) { |
|||
if($m+$j>$lan) { |
|||
$m = $m+$j; |
|||
$tail = $new; |
|||
$lenght = iconv("UTF-8", "GBK//IGNORE", $new); |
|||
$k = $A - strlen($lenght); |
|||
for($q=0;$q<$k;$q++){ |
|||
$kw3 .= ' '; |
|||
} |
|||
if($m==$j){ |
|||
$tail .= $kw3.' '.$price.' '.$num.' '.$prices; |
|||
}else{ |
|||
$tail .= $kw3.'<BR>'; |
|||
} |
|||
break; |
|||
}else{ |
|||
$next_new = mb_substr($str,$m,$j,'utf-8'); |
|||
if(mb_strwidth($next_new,'utf-8')<$blankNum) continue; |
|||
else{ |
|||
$m = $i+1; |
|||
$result[] = $new; |
|||
$j=1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
$head = ''; |
|||
foreach ($result as $key=>$value) { |
|||
if($key < 1){ |
|||
$v_lenght = iconv("UTF-8", "GBK//IGNORE", $value); |
|||
$v_lenght = strlen($v_lenght); |
|||
if($v_lenght == 13) $value = $value." "; |
|||
$head .= $value.' '.$price.' '.$num.' '.$prices; |
|||
}else{ |
|||
$head .= $value.'<BR>'; |
|||
} |
|||
} |
|||
$orderInfo .= $head.$tail; |
|||
if(!empty($v5['o_note'])){ |
|||
$orderInfo .= '备注:'.$v5['o_note'].'<BR>'; |
|||
} |
|||
@$nums += $prices; |
|||
} |
|||
// $time = date('Y-m-d H:i:s', time());
|
|||
$orderInfo .= '--------------------------------<BR>'; |
|||
if ($arr[0]['box_money'] > 0) { |
|||
$kw5 = ''; |
|||
$len = 24 - strlen($arr[0]['box_money']); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$orderInfo .= '包装费:' . $kw5 . $arr[0]['box_money'] . '<BR>'; |
|||
} |
|||
if($arr[0]['dada_fee'] > 0){ |
|||
$kw5 = ''; |
|||
$len = 24 - strlen($arr[0]['dada_fee']); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$orderInfo .= '配送费:'.$kw5.$arr[0]['dada_fee'].'<BR>'; |
|||
} |
|||
if($arr[0]['yhq_money2'] > 0){ |
|||
$yhq_money2 = sprintf("%.2f",$arr[0]['yhq_money2']); |
|||
$kw6 = ''; |
|||
$len = 25 - strlen($yhq_money2); |
|||
for ($q = 0; $q < $len; $q++) { |
|||
$kw6 .= ' '; |
|||
} |
|||
$orderInfo .= '红包:'.$kw6.'-'.$yhq_money2.'<BR>'; |
|||
} |
|||
$total = '合计:'.$arr[0]['m_money']; |
|||
$user_name = $arr[0]['user_name']; |
|||
if(strlen($user_name)>18){ |
|||
$user_name=substr($user_name,0,18).'...'; |
|||
} |
|||
$str = $user_name . $total; |
|||
$kw5 = ''; |
|||
$lenght = iconv("UTF-8", "GBK//IGNORE", $str); |
|||
$total_len = 32 - strlen($lenght); |
|||
for ($q = 0; $q < $total_len; $q++) { |
|||
$kw5 .= ' '; |
|||
} |
|||
$total_str = $user_name.$kw5.$total; |
|||
$orderInfo .= $total_str.'<BR>'; |
|||
$orderInfo .= '送货地点:' . $arr[0]['address'] . '<BR>'; |
|||
$tel = substr_replace( $arr[0]['tel'], '****', 3, 4); |
|||
$orderInfo .= '联系电话:' . $tel . '<BR>'; |
|||
$orderInfo .= '配送时间:' . $arr[0]['ps_time'] . '<BR>'; |
|||
if(!empty($arr[0]['note'])){ |
|||
$orderInfo .= '备注:'.$arr[0]['note'].'<BR><BR>'; |
|||
} |
|||
//$orderInfo .= '<QR>http://www.feieyun.com</QR>';//把解析后的二维码生成的字符串用标签套上即可自动生成二维码
|
|||
return $orderInfo; |
|||
} |
|||
|
|||
?>
|
|||
@ -0,0 +1,307 @@ |
|||
<?php |
|||
|
|||
class HttpClient { |
|||
// Request vars
|
|||
var $host; |
|||
var $port; |
|||
var $path; |
|||
var $method; |
|||
var $postdata = ''; |
|||
var $cookies = array(); |
|||
var $referer; |
|||
var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*'; |
|||
var $accept_encoding = 'gzip'; |
|||
var $accept_language = 'en-us'; |
|||
var $user_agent = 'Incutio HttpClient v0.9'; |
|||
var $timeout = 20; |
|||
var $use_gzip = true; |
|||
var $persist_cookies = true; |
|||
var $persist_referers = true; |
|||
var $debug = false; |
|||
var $handle_redirects = true; |
|||
var $max_redirects = 5; |
|||
var $headers_only = false; |
|||
var $username; |
|||
var $password; |
|||
var $status; |
|||
var $headers = array(); |
|||
var $content = ''; |
|||
var $errormsg; |
|||
var $redirect_count = 0; |
|||
var $cookie_host = ''; |
|||
function __construct($host, $port=80) { |
|||
$this->host = $host; |
|||
$this->port = $port; |
|||
} |
|||
function get($path, $data = false) { |
|||
$this->path = $path; |
|||
$this->method = 'GET'; |
|||
if ($data) { |
|||
$this->path .= '?'.$this->buildQueryString($data); |
|||
} |
|||
return $this->doRequest(); |
|||
} |
|||
function post($path, $data) { |
|||
$this->path = $path; |
|||
$this->method = 'POST'; |
|||
$this->postdata = $this->buildQueryString($data); |
|||
return $this->doRequest(); |
|||
} |
|||
function buildQueryString($data) { |
|||
$querystring = ''; |
|||
if (is_array($data)) { |
|||
foreach ($data as $key => $val) { |
|||
if (is_array($val)) { |
|||
foreach ($val as $val2) { |
|||
$querystring .= urlencode($key).'='.urlencode($val2).'&'; |
|||
} |
|||
} else { |
|||
$querystring .= urlencode($key).'='.urlencode($val).'&'; |
|||
} |
|||
} |
|||
$querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
|
|||
} else { |
|||
$querystring = $data; |
|||
} |
|||
return $querystring; |
|||
} |
|||
function doRequest() { |
|||
if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) { |
|||
switch($errno) { |
|||
case -3: |
|||
$this->errormsg = 'Socket creation failed (-3)'; |
|||
case -4: |
|||
$this->errormsg = 'DNS lookup failure (-4)'; |
|||
case -5: |
|||
$this->errormsg = 'Connection refused or timed out (-5)'; |
|||
default: |
|||
$this->errormsg = 'Connection failed ('.$errno.')'; |
|||
$this->errormsg .= ' '.$errstr; |
|||
$this->debug($this->errormsg); |
|||
} |
|||
return false; |
|||
} |
|||
socket_set_timeout($fp, $this->timeout); |
|||
$request = $this->buildRequest(); |
|||
$this->debug('Request', $request); |
|||
fwrite($fp, $request); |
|||
$this->headers = array(); |
|||
$this->content = ''; |
|||
$this->errormsg = ''; |
|||
$inHeaders = true; |
|||
$atStart = true; |
|||
while (!feof($fp)) { |
|||
$line = fgets($fp, 4096); |
|||
if ($atStart) { |
|||
$atStart = false; |
|||
if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { |
|||
$this->errormsg = "Status code line invalid: ".htmlentities($line); |
|||
$this->debug($this->errormsg); |
|||
return false; |
|||
} |
|||
$http_version = $m[1]; |
|||
$this->status = $m[2]; |
|||
$status_string = $m[3]; |
|||
$this->debug(trim($line)); |
|||
continue; |
|||
} |
|||
if ($inHeaders) { |
|||
if (trim($line) == '') { |
|||
$inHeaders = false; |
|||
$this->debug('Received Headers', $this->headers); |
|||
if ($this->headers_only) { |
|||
break; |
|||
} |
|||
continue; |
|||
} |
|||
if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { |
|||
continue; |
|||
} |
|||
$key = strtolower(trim($m[1])); |
|||
$val = trim($m[2]); |
|||
if (isset($this->headers[$key])) { |
|||
if (is_array($this->headers[$key])) { |
|||
$this->headers[$key][] = $val; |
|||
} else { |
|||
$this->headers[$key] = array($this->headers[$key], $val); |
|||
} |
|||
} else { |
|||
$this->headers[$key] = $val; |
|||
} |
|||
continue; |
|||
} |
|||
$this->content .= $line; |
|||
} |
|||
fclose($fp); |
|||
if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { |
|||
$this->debug('Content is gzip encoded, unzipping it'); |
|||
$this->content = substr($this->content, 10); |
|||
$this->content = gzinflate($this->content); |
|||
} |
|||
if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) { |
|||
$cookies = $this->headers['set-cookie']; |
|||
if (!is_array($cookies)) { |
|||
$cookies = array($cookies); |
|||
} |
|||
foreach ($cookies as $cookie) { |
|||
if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { |
|||
$this->cookies[$m[1]] = $m[2]; |
|||
} |
|||
} |
|||
$this->cookie_host = $this->host; |
|||
} |
|||
if ($this->persist_referers) { |
|||
$this->debug('Persisting referer: '.$this->getRequestURL()); |
|||
$this->referer = $this->getRequestURL(); |
|||
} |
|||
if ($this->handle_redirects) { |
|||
if (++$this->redirect_count >= $this->max_redirects) { |
|||
$this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')'; |
|||
$this->debug($this->errormsg); |
|||
$this->redirect_count = 0; |
|||
return false; |
|||
} |
|||
$location = isset($this->headers['location']) ? $this->headers['location'] : ''; |
|||
$uri = isset($this->headers['uri']) ? $this->headers['uri'] : ''; |
|||
if ($location || $uri) { |
|||
$url = parse_url($location.$uri); |
|||
return $this->get($url['path']); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
function buildRequest() { |
|||
$headers = array(); |
|||
$headers[] = "{$this->method} {$this->path} HTTP/1.0"; |
|||
$headers[] = "Host: {$this->host}"; |
|||
$headers[] = "User-Agent: {$this->user_agent}"; |
|||
$headers[] = "Accept: {$this->accept}"; |
|||
if ($this->use_gzip) { |
|||
$headers[] = "Accept-encoding: {$this->accept_encoding}"; |
|||
} |
|||
$headers[] = "Accept-language: {$this->accept_language}"; |
|||
if ($this->referer) { |
|||
$headers[] = "Referer: {$this->referer}"; |
|||
} |
|||
if ($this->cookies) { |
|||
$cookie = 'Cookie: '; |
|||
foreach ($this->cookies as $key => $value) { |
|||
$cookie .= "$key=$value; "; |
|||
} |
|||
$headers[] = $cookie; |
|||
} |
|||
if ($this->username && $this->password) { |
|||
$headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password); |
|||
} |
|||
if ($this->postdata) { |
|||
$headers[] = 'Content-Type: application/x-www-form-urlencoded'; |
|||
$headers[] = 'Content-Length: '.strlen($this->postdata); |
|||
} |
|||
$request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata; |
|||
return $request; |
|||
} |
|||
function getStatus() { |
|||
return $this->status; |
|||
} |
|||
function getContent() { |
|||
return $this->content; |
|||
} |
|||
function getHeaders() { |
|||
return $this->headers; |
|||
} |
|||
function getHeader($header) { |
|||
$header = strtolower($header); |
|||
if (isset($this->headers[$header])) { |
|||
return $this->headers[$header]; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
function getError() { |
|||
return $this->errormsg; |
|||
} |
|||
function getCookies() { |
|||
return $this->cookies; |
|||
} |
|||
function getRequestURL() { |
|||
$url = 'https://'.$this->host; |
|||
if ($this->port != 80) { |
|||
$url .= ':'.$this->port; |
|||
} |
|||
$url .= $this->path; |
|||
return $url; |
|||
} |
|||
function setUserAgent($string) { |
|||
$this->user_agent = $string; |
|||
} |
|||
function setAuthorization($username, $password) { |
|||
$this->username = $username; |
|||
$this->password = $password; |
|||
} |
|||
function setCookies($array) { |
|||
$this->cookies = $array; |
|||
} |
|||
function useGzip($boolean) { |
|||
$this->use_gzip = $boolean; |
|||
} |
|||
function setPersistCookies($boolean) { |
|||
$this->persist_cookies = $boolean; |
|||
} |
|||
function setPersistReferers($boolean) { |
|||
$this->persist_referers = $boolean; |
|||
} |
|||
function setHandleRedirects($boolean) { |
|||
$this->handle_redirects = $boolean; |
|||
} |
|||
function setMaxRedirects($num) { |
|||
$this->max_redirects = $num; |
|||
} |
|||
function setHeadersOnly($boolean) { |
|||
$this->headers_only = $boolean; |
|||
} |
|||
function setDebug($boolean) { |
|||
$this->debug = $boolean; |
|||
} |
|||
function quickGet($url) { |
|||
$bits = parse_url($url); |
|||
$host = $bits['host']; |
|||
$port = isset($bits['port']) ? $bits['port'] : 80; |
|||
$path = isset($bits['path']) ? $bits['path'] : '/'; |
|||
if (isset($bits['query'])) { |
|||
$path .= '?'.$bits['query']; |
|||
} |
|||
$client = new HttpClient($host, $port); |
|||
if (!$client->get($path)) { |
|||
return false; |
|||
} else { |
|||
return $client->getContent(); |
|||
} |
|||
} |
|||
function quickPost($url, $data) { |
|||
$bits = parse_url($url); |
|||
$host = $bits['host']; |
|||
$port = isset($bits['port']) ? $bits['port'] : 80; |
|||
$path = isset($bits['path']) ? $bits['path'] : '/'; |
|||
$client = new HttpClient($host, $port); |
|||
if (!$client->post($path, $data)) { |
|||
return false; |
|||
} else { |
|||
return $client->getContent(); |
|||
} |
|||
} |
|||
function debug($msg, $object = false) { |
|||
if ($this->debug) { |
|||
print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg; |
|||
if ($object) { |
|||
ob_start(); |
|||
print_r($object); |
|||
$content = htmlentities(ob_get_contents()); |
|||
ob_end_clean(); |
|||
print '<pre>'.$content.'</pre>'; |
|||
} |
|||
print '</div>'; |
|||
} |
|||
} |
|||
} |
|||
|
|||
?>
|
|||
@ -0,0 +1,46 @@ |
|||
一、添加打印机 |
|||
|
|||
方法名 printerContent($content) |
|||
|
|||
参数说明 $content 打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100台 |
|||
如:316500010 # abcdefgh # 快餐前台 # 13688889999 |
|||
316500011 # abcdefgh # 快餐厨房 # 13688889990 |
|||
二、删除打印机 |
|||
|
|||
方法名 printerDelList($snlist) |
|||
|
|||
参数说明 $snlist 打印机编号 多台用-连接 |
|||
如:316500010-316500011 |
|||
三、打印订单 |
|||
|
|||
方法名 printMsg($sn,$content,$times) |
|||
|
|||
参数说明 $sn 打印机编码 $content 打印内容 $times 打印张数 无值默认为1 |
|||
如: $sn = 550510805; |
|||
$content = '<CB>测试打印</CB><BR>'; |
|||
$content .= '名称 单价 数量 金额<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '饭 10.0 10 100.0<BR>'; |
|||
$content .= '炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '西红柿鸡蛋炒饭 10.0 10 100.0<BR>'; |
|||
$content .= '--------------------------------<BR>'; |
|||
$content .= '备注:加辣<BR>'; |
|||
$content .= '合计:xx.0元<BR>'; |
|||
$content .= '送货地点:广西南宁五象新区<BR>'; |
|||
$content .= '联系电话:13888888888888<BR>'; |
|||
$content .= '订餐时间:2014-08-08 08:08:08<BR>'; |
|||
$content .= '<QR>http://www.feieyun.com</QR>';//把二维码字符串用标签套上即可自动生成二维码 |
|||
//标签说明: |
|||
$content = "<DIRECTION>1</DIRECTION>";//设定打印时出纸和打印字体的方向,n 0 或 1,每次设备重启后都会初始化为 0 值设置,1:正向出纸,0:反向出纸, |
|||
$content .= "<TEXT x='9' y='10' font='12' w='1' h='2' r='0'>#001 五号桌 1/3</TEXT><TEXT x='80' y='80' font='12' w='2' h='2' r='0'>可乐鸡翅</TEXT><TEXT x='9' y='180' font='12' w='1' h='1' r='0'>张三先生 13800138000</TEXT>";//40mm宽度标签纸打印例子,打开注释调用标签打印接口打印 |
|||
|
|||
四、查询订单状态 |
|||
|
|||
方法名 queryOrderState($orderid) |
|||
|
|||
参数说明 $orderid 飞鹅订单号(发起打印请求成功时,从回调的参数中获取) |
|||
如:550510805_20200603103522_387054119 |
|||
@ -1,16 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class CouponSetting extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
// use SoftDeletes;
|
|||
|
|||
protected $table = 'ims_system_coupon_setting'; |
|||
|
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class EsDict extends Model |
|||
{ |
|||
protected $table = 'lanzu_es_dicts'; |
|||
protected $dateFormat = 'U'; |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Models; |
|||
|
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Feprint extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
protected $table = 'ims_cjdc_feprint'; |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
use Laravel\Scout\Searchable; |
|||
use Illuminate\Support\Str; |
|||
|
|||
class LanzuGoods extends Model |
|||
{ |
|||
use Searchable; |
|||
|
|||
protected $table = 'lanzu_goods'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
public function getCoverImgAttribute($v){ |
|||
if(Str::startsWith($v,"http")){ |
|||
return $v; |
|||
}else{ |
|||
return env('IMG_HOST') . $v; |
|||
} |
|||
} |
|||
|
|||
public function searchableAs() |
|||
{ |
|||
return 'lanzu-goods-test'; |
|||
} |
|||
|
|||
public function toSearchableArray() |
|||
{ |
|||
return [ |
|||
'name' => $this->name, |
|||
'market_id' => $this->market_id, |
|||
'store_id' => $this->store_id, |
|||
]; |
|||
} |
|||
|
|||
/** |
|||
* 指定 搜索索引中存储的唯一ID |
|||
* @return mixed |
|||
*/ |
|||
public function getScoutKey() |
|||
{ |
|||
return $this->id; |
|||
} |
|||
|
|||
/** |
|||
* 指定 搜索索引中存储的唯一ID的键名 |
|||
* @return string |
|||
*/ |
|||
public function getScoutKeyName() |
|||
{ |
|||
return 'id'; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class LanzuServiceHorseman extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_service_horseman'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
public static function getHorseman($marketId=null) |
|||
{ |
|||
if ($marketId){ |
|||
$rows = self::where('market_id',$marketId)->get(); |
|||
}else{ |
|||
$rows = self::get(); |
|||
} |
|||
$item = []; |
|||
foreach ($rows as $row) { |
|||
$item[$row->id] = $row->name; |
|||
} |
|||
return $item; |
|||
} |
|||
} |
|||
@ -1,15 +0,0 @@ |
|||
<?php |
|||
|
|||
namespace App\Models; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
|
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class storeUserReport extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
protected $table = 'ims_cjdc_store'; |
|||
public $timestamps = false; |
|||
|
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Banners extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_banners'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
protected $appends = [ |
|||
'cover_url', |
|||
'cover_type_text', |
|||
'path_type_text', |
|||
'type_text', |
|||
'status_text' |
|||
]; |
|||
protected $casts = [ |
|||
'market_ids'=>'array', |
|||
]; |
|||
|
|||
public static $_coverType = [1=>'图片', 2=>'视频']; |
|||
public static $_pathType = ['page'=>'page','webview'=>'webview','applet'=>'applet']; |
|||
public static $_type = [1=>'首页']; |
|||
public static $_status = ['禁用', '正常']; |
|||
|
|||
public function getCoverUrlAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->cover; |
|||
return $this->imageUrl($value); |
|||
} |
|||
|
|||
public function getCoverTypeTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->cover_type; |
|||
return isset(self::$_coverType[$value]) ? self::$_coverType[$value] : ''; |
|||
} |
|||
public function getPathTypeTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->path_type; |
|||
return isset(self::$_pathType[$value]) ? self::$_pathType[$value] : ''; |
|||
} |
|||
public function getTypeTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->type; |
|||
return isset(self::$_type[$value]) ? self::$_type[$value] : ''; |
|||
} |
|||
public function getStatusTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->stauts; |
|||
return isset(self::$_status[$value]) ? self::$_status[$value] : ''; |
|||
} |
|||
/** |
|||
* 处理旧图片 |
|||
* @param $value |
|||
* @return string |
|||
*/ |
|||
public function imageUrl($value) |
|||
{ |
|||
if(strripos($value,"http") === false){ |
|||
return env('OSS_IMG_HOST').'/'.$value; |
|||
}else{ |
|||
return $value; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,81 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Dcat\Admin\Traits\ModelTree; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class Category extends Model |
|||
{ |
|||
use ModelTree; |
|||
use SoftDeletes; |
|||
|
|||
protected $table = 'lanzu_category'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
// 父级ID字段名称,默认值为 parent_id
|
|||
// protected $parentColumn = 'pid';
|
|||
|
|||
// 排序字段名称,默认值为 order
|
|||
protected $orderColumn = 'sort'; |
|||
|
|||
// 标题字段名称,默认值为 title
|
|||
// protected $titleColumn = 'name';
|
|||
|
|||
protected $appends = [ |
|||
'cover_img_url', |
|||
]; |
|||
public function getCoverImgUrlAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->cover_img; |
|||
return $this->imageUrl($value); |
|||
} |
|||
|
|||
/** |
|||
* 获取单个信息 |
|||
* @param int $id |
|||
* @param string $field |
|||
* @return string |
|||
*/ |
|||
public static function getInfo($id,$field = '*') |
|||
{ |
|||
return self::select($field)->find($id); |
|||
} |
|||
|
|||
/** |
|||
* 获取二级分类数组 |
|||
* id为键,title为值 |
|||
* @return array |
|||
*/ |
|||
public static function getArray($where = [],$options = []) |
|||
{ |
|||
$model = self::where('status',1) |
|||
->whereNull('deleted_at'); |
|||
|
|||
if(count($where) > 0){ |
|||
$model->where($where); |
|||
} |
|||
$list = $model->pluck('title','id')->toArray(); |
|||
if(!empty($options)){ |
|||
return array_merge($options,$list); |
|||
}else{ |
|||
return $list; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 处理旧图片 |
|||
* @param $value |
|||
* @return string |
|||
*/ |
|||
public function imageUrl($value) |
|||
{ |
|||
if(strripos($value,"http") === false){ |
|||
return env('OSS_IMG_HOST').'/'.$value; |
|||
}else{ |
|||
return $value; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,158 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\SoftDeletes; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
use App\Models\v3\CouponSetting as SettingModel; |
|||
use App\Models\v3\CouponReceiveType as ReceiveTypeModel; |
|||
|
|||
class Coupon extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
use SoftDeletes; |
|||
|
|||
protected $dateFormat = 'U'; |
|||
|
|||
protected $table = 'lanzu_coupon'; |
|||
/* 查询记录数 limit */ |
|||
protected $perPage = 10; |
|||
|
|||
public static $_ACTIVITY_AVAILABLE = ['flash_sale'=>'秒杀','group_buy'=>'团购','new_product'=>'新品']; |
|||
public static $_CATEGORY = [1=>'订单']; |
|||
public static $_TYPE = [1=>'全平台',2=>'线上', 3=>'线下']; |
|||
public static $_ISNEWUSER = [1=>'是',2=>'否']; |
|||
public static $_DISCOUNTTYPE = [1=>'金额',2=>'打折(%)']; |
|||
public static $_ACTIVETYPE = [1=>'领取活动',2=>'转发活动',3=>'返券专用']; |
|||
public static $_STATUS = [ -1=> '已删除', 0=>'草稿', 1=>'正常',2=>'已领完',3=>'禁用']; |
|||
|
|||
/* 添加转换字段 */ |
|||
protected $appends = [ |
|||
'status_text', |
|||
'type_text', |
|||
'category_text', |
|||
'is_new_user_text', |
|||
'discount_type_text', |
|||
'active_type_text', |
|||
'start_time_text', |
|||
'end_time_text', |
|||
'usable_start_time_text', |
|||
'usable_end_time_text', |
|||
// 'receive_type_text',
|
|||
'created_at_text', |
|||
'updated_at_text', |
|||
'activity_available_text' |
|||
]; |
|||
protected $casts = [ |
|||
'market_ids'=>'array', |
|||
'category_ids'=>'array', |
|||
'tags'=>'array', |
|||
'activity_available'=>'array' |
|||
]; |
|||
|
|||
public function getStatusTextAttribute() |
|||
{ |
|||
$value = $this->status; |
|||
return isset(self::$_STATUS[$value])?self::$_STATUS[$value]:''; |
|||
} |
|||
public function getTypeTextAttribute() |
|||
{ |
|||
$value = $this->type; |
|||
return isset(self::$_TYPE[$value])?self::$_TYPE[$value]:''; |
|||
} |
|||
public function getCategoryTextAttribute() |
|||
{ |
|||
$value = $this->category; |
|||
return isset(self::$_CATEGORY[$value])?self::$_CATEGORY[$value]:''; |
|||
} |
|||
public function getIsNewUserTextAttribute() |
|||
{ |
|||
$value = $this->is_new_user; |
|||
return isset(self::$_ISNEWUSER[$value])?self::$_ISNEWUSER[$value]:''; |
|||
} |
|||
public function getDiscountTypeTextAttribute() |
|||
{ |
|||
$value = $this->discount_type; |
|||
return isset(self::$_DISCOUNTTYPE[$value])?self::$_DISCOUNTTYPE[$value]:''; |
|||
} |
|||
public function getActiveTypeTextAttribute() |
|||
{ |
|||
$value = $this->active_type; |
|||
return isset(self::$_ACTIVETYPE[$value])?self::$_ACTIVETYPE[$value]:''; |
|||
} |
|||
public function getActivityAvailableTextAttribute() |
|||
{ |
|||
$value = $this->activity_available; |
|||
// return isset(self::$_ACTIVITY_AVAILABLE[$value])?self::$_ACTIVITY_AVAILABLE[$value]:'';
|
|||
return ''; |
|||
} |
|||
public function getStartTimeTextAttribute() |
|||
{ |
|||
$value = $this->start_time; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
|
|||
public function getEndTimeTextAttribute() |
|||
{ |
|||
$value = $this->usable_start_time; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
public function getUsableStartTimeTextAttribute() |
|||
{ |
|||
$value = $this->start_time; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
public function getUsableEndTimeTextAttribute() |
|||
{ |
|||
$value = $this->usable_end_time; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
public function getCreatedAtTextAttribute() |
|||
{ |
|||
$value = $this->created_at; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
public function getUpdatedAtTextAttribute() |
|||
{ |
|||
$value = $this->updated_at; |
|||
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; |
|||
} |
|||
|
|||
public function getReceiveTypeTextAttribute() |
|||
{ |
|||
$id = $this->getKey(); |
|||
$receive = SettingModel::where('receive_type.system_coupon_user_id',$id) |
|||
->join('ims_system_coupon_user_receivetype as receive_type','receive_type.receive_type','ims_system_coupon_setting.id','inner') |
|||
->first('name'); |
|||
|
|||
return $receive ? $receive['name'] : ''; |
|||
} |
|||
|
|||
//关联领取方式表
|
|||
public function receiveType() |
|||
{ |
|||
return $this->hasOne(ReceiveTypeModel::class,'coupon_id','id'); |
|||
} |
|||
|
|||
// 设置
|
|||
protected function setStartTimeAttribute($value) |
|||
{ |
|||
$this->attributes['start_time'] = strtotime($value); |
|||
} |
|||
|
|||
protected function setEndTimeAttribute($value) |
|||
{ |
|||
$this->attributes['end_time'] = strtotime($value); |
|||
} |
|||
|
|||
protected function setUsableStarttimeAttribute($value) |
|||
{ |
|||
$this->attributes['usable_start_time'] = strtotime($value); |
|||
} |
|||
|
|||
protected function setUsableEndTimeAttribute($value) |
|||
{ |
|||
$this->attributes['usable_end_time'] = strtotime($value); |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use App\Models\v3\CouponSetting as SettingModel; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class CouponReceiveType extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
protected $table = 'lanzu_coupon_receive_type'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
public function setting(){ |
|||
return $this->belongsTo(SettingModel::class,'receive_type','id','inner'); |
|||
} |
|||
|
|||
/** |
|||
* 根据where获取单条数据 |
|||
*/ |
|||
public static function getReceiveTypeOne($where,$field = '*') |
|||
{ |
|||
return self::select($field)->where($where)->first(); |
|||
} |
|||
/** |
|||
* 根据id获取单条数据 |
|||
*/ |
|||
public static function getReceiveTypeInfo($id,$field = '*') |
|||
{ |
|||
return self::select($field)->find($id); |
|||
} |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
<?php |
|||
|
|||
namespace App\Models\v3; |
|||
|
|||
use Dcat\Admin\Traits\HasDateTimeFormatter; |
|||
use Illuminate\Database\Eloquent\Model; |
|||
|
|||
class CouponSetting extends Model |
|||
{ |
|||
use HasDateTimeFormatter; |
|||
protected $table = 'lanzu_coupon_setting'; |
|||
protected $dateFormat = 'U'; |
|||
|
|||
public static $_CATEGORY = [1=>'领取方式']; |
|||
public static $_STATUS = ['禁用','正常']; |
|||
|
|||
protected $appends = [ |
|||
'category_text', |
|||
'status_text' |
|||
]; |
|||
|
|||
public function getCategoryTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->category; |
|||
return isset(self::$_CATEGORY[$value]) ? self::$_CATEGORY[$value] : ''; |
|||
} |
|||
public function getStatusTextAttribute($value) |
|||
{ |
|||
$value = $value ? $value : $this->status; |
|||
return isset(self::$_STATUS[$value]) ? self::$_STATUS[$value] : ''; |
|||
} |
|||
|
|||
/** |
|||
* 获取数组 |
|||
*/ |
|||
public static function getSettingArray($where = [],$options = []) |
|||
{ |
|||
$model = self::where('status',1) |
|||
->whereNull('deleted_at'); |
|||
|
|||
if(!empty($where)){ |
|||
$model->where($where); |
|||
} |
|||
$list = $model->pluck('name','id')->toArray(); |
|||
if(!empty($options)){ |
|||
return array_merge($options,$list); |
|||
}else{ |
|||
return $list; |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 根据id获取单条数据 |
|||
*/ |
|||
public static function getSettingInfo($id,$field = '*') |
|||
{ |
|||
// return self::select($field)->find($id);
|
|||
return self::select($field)->where('id',$id)->first(); |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Write
Preview
Loading…
Cancel
Save
Reference in new issue