Browse Source

Merge branch 'hotfix-phoenix' into develop

master
liangyuyan 5 years ago
parent
commit
ca5eb96983
  1. 6
      app/Admin/Common/Images.php
  2. 69
      app/Admin/Common/StoreQrCode.php
  3. 15
      app/Admin/Controllers/HomeController.php
  4. 13
      app/Admin/Controllers/ImsCjdcOrderMainController.php
  5. 2
      app/Admin/Controllers/v3/GoodsActivityController.php
  6. 9
      app/Admin/Controllers/v3/StoreController.php
  7. 80
      app/Console/Commands/MigrateOrderGoods.php
  8. 96
      app/Console/Commands/MigrateOrderMain.php
  9. 22
      app/Console/Commands/MigrateStoreWithdrawal.php
  10. 66
      app/Console/Commands/OnlineOrderStatis.php
  11. 2
      app/Models/LanzuStore.php
  12. 16
      config/wechat.php

6
app/Admin/Common/Images.php

@ -20,7 +20,7 @@ class Images extends AdminController
$appid= config('wechat.mini_program.default')['app_id'];
$secret=config('wechat.mini_program.default')['secret'];
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
$url = config('wechat.defaults.token').$appid."&secret=".$secret;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
@ -43,7 +43,7 @@ class Images extends AdminController
"width"=>100
);
$data = json_encode($data);
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$access_token."";
$url = config('wechat.QR_code.default.mini_code_url').$access_token."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
@ -68,7 +68,7 @@ class Images extends AdminController
"width"=>280
);
$data = json_encode($data);
$url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=".$access_token."";
$url = config('wechat.QR_code.default.wx_code_url').$access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);

69
app/Admin/Common/StoreQrCode.php

@ -35,7 +35,7 @@ class StoreQrCode extends AdminController
public function SetStoreWeChatCode($id)
{
$codeStore = $this->images->createQrCode($id,'zh_cjdianc/pages/takeout/takeoutindex');
$storeImgPath = 'QR_code/code_store_img/wx_store_'.$id.'.jpg';
$storeImgPath = 'QR_code/code_store_img/wx_store_'.$id.'_'.md5(time()).'.jpg';
$res = $this->images->uploadOss($codeStore,$storeImgPath);
if($res){
return ['status' => true ,'path' => $storeImgPath];
@ -48,19 +48,13 @@ class StoreQrCode extends AdminController
*/
public function SetPayWeChatCode($id)
{
// $isCREATE = env('IS_CREATE_WECHAT_MINI_QR_CODE',1);
// if($isCREATE == 0){
if(config('wechat.QR_code.default.is_wx_code') == 1){
$codeStore = $this->images->createWeChatQrCode('?scene='.$id,'zh_cjdianc/pages/seller/fukuan');
$storeImgPath = 'QR_code/code_pay_img/wx_pay_'.$id.'_'.md5(time()).'.jpg';
}else{
$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);
$storeImgPath = 'QR_code/code_minipay_img/wx_minipay_'.$id.'_'.md5(time()).'.jpg';
}
$res = $this->images->uploadOss($codeStore,$storeImgPath);
if($res){
@ -70,53 +64,4 @@ class StoreQrCode extends AdminController
}
}
/**
* 店铺收银码裁剪
*/
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);
}
}
}

15
app/Admin/Controllers/HomeController.php

@ -2,6 +2,7 @@
namespace App\Admin\Controllers;
use App\Admin\Common\Auth;
use App\Admin\Common\Type;
use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
@ -131,15 +132,19 @@ class HomeController extends Controller
protected function market_service(Content $content)
{
$marketId = Auth::getMarket();
return $content->header('控制面板')
->description('欢迎回到懒族后台')
->body(function (Row $row) {
$row->column(4, function (Column $column) {
$column->row(new Examples\Order\OrderData('number','订单数'));
->body(function (Row $row)use ($marketId) {
$row->column(4, function (Column $column)use ($marketId) {
$column->row(new Examples\ServiceCard\TotalStore($marketId,'商户数'));
});
$row->column(4, function (Column $column)use ($marketId) {
$column->row(new Examples\Order\OrderData('number',$marketId,'订单数'));
});
$row->column(4, function (Column $column) {
$column->row(new Examples\Order\OrderData('amount','订单金额'));
$row->column(4, function (Column $column)use ($marketId) {
$column->row(new Examples\Order\OrderData('amount',$marketId,'订单金额(元)'));
});
});
}

13
app/Admin/Controllers/ImsCjdcOrderMainController.php

@ -11,6 +11,8 @@ use App\Admin\Extensions\OrderPrint;
use App\Admin\Extensions\OrderRefund;
use App\Admin\Extensions\OrderStateHandle;
use App\Admin\Repositories\ImsCjdcOrderMain;
use App\Models\ImsCjdcMarket;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
@ -37,10 +39,16 @@ class ImsCjdcOrderMainController extends AdminController
$grid->paginate(10);//每页展示数据10条
//$grid->id;
//$grid->user_id('用户信息');
$marketId = Auth::getMarket();
if (!(Admin::user()->isRole('market_service'))){
$marketId = \Request::get('market_id');
if ($marketId){
$grid->model()->where('market_id',$marketId);
}
}else{
$marketId =Auth::getMarket();
$grid->model()->where('market_id',$marketId);
}
$grid->column('nick_name', '用户信息');
$grid->order_num;
@ -76,6 +84,9 @@ class ImsCjdcOrderMainController extends AdminController
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('order_num');
if (!(Admin::user()->isRole('market_service'))){
$filter->equal('market_id','所属市场')->select(ImsCjdcMarket::getMarket());
}
});
$grid->disableViewButton();

2
app/Admin/Controllers/v3/GoodsActivityController.php

@ -8,7 +8,7 @@ use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;
use App\Models\v3\Market as MarketModel;
use App\Models\v3\StoreNew as StoreModel;
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;

9
app/Admin/Controllers/v3/StoreController.php

@ -41,13 +41,11 @@ class StoreController extends AdminController
// 查询一级分类
// $categoryList = CategoryModel::getArray([['parent_id','=',0]]);
$grid->model()->orderBy('id','desc');
$grid->id->sortable();
$grid->logo_url->image('',50);
$grid->name;
$grid->market_id->display(function ($marketId) use($marketList){
// $market = MarketModel::getMarketInfo($marketId,'name');
return isset($marketList[$marketId]) ? $marketList[$marketId] : '';
});
$grid->mm_user_id->display(function ($mmUserId){
@ -84,12 +82,11 @@ class StoreController extends AdminController
$filter->like('name');
$filter->equal('market_id')->select($marketList);
});
$grid->model()->orderBy('id','desc');
// 每页10条
$grid->paginate(10);
$grid->disableDeleteButton();
// $grid->disableDeleteButton();
});
}
@ -282,7 +279,7 @@ class StoreController extends AdminController
// 生成小程序码 店铺
$sRes = $qrCode->SetStoreWeChatCode($id);
// 生产小程序码 收银
// 生成二维码 收银
$pRes = $qrCode->SetPayWeChatCode($id);
// 保存图片

80
app/Console/Commands/MigrateOrderGoods.php

@ -1,80 +0,0 @@
<?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;
}
}

96
app/Console/Commands/MigrateOrderMain.php

@ -1,96 +0,0 @@
<?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;
}
}

22
app/Console/Commands/MigrateStoreWithdrawal.php

@ -58,7 +58,7 @@ class MigrateStoreWithdrawal extends Command
$startTime = time();
$error = [];
foreach ($oldData as $key => $value){
$withdrawalId = $value->id;
$withdrawalId = $value->id ?? 0;
// 判断是否存在
$exist = DB::table($newTableName)->where('id',$withdrawalId)->exists();
if($exist){
@ -66,21 +66,21 @@ class MigrateStoreWithdrawal extends Command
}
$newData =[
'id'=>$withdrawalId,
'store_id'=>$value->store_id,
'store_id'=>$value->store_id ?? 0,
'name'=> ($value->name == 'undefined') ? '': $value->name,
'tel'=>$value->tel,
'name'=> (empty($value->name) || $value->name == 'undefined') ? '': $value->name,
'tel'=>$value->tel ?? 0,
'type'=> isset($typeData[$value->type])?$typeData[$value->type]:0,
'check_time'=>strtotime($value->sh_time),
'state'=>$value->state,
'state'=>$value->state ?? 0,
'apply_cash'=>$value->tx_cost,
'real_cash'=>$value->sj_cost,
'bank_card'=>$value->yhk_num,
'bank_info'=>$value->yh_info,
'apply_cash'=>$value->tx_cost ?? 0,
'real_cash'=>$value->sj_cost ?? 0,
'bank_card'=>$value->yhk_num ?? 0,
'bank_info'=>$value->yh_info ?? 0,
'created_at' => strtotime($value->time),
'updated_at' => strtotime($value->sh_time),
'created_at' => $value->time ? strtotime($value->time) :0,
'updated_at' => $value->sh_time ? strtotime($value->sh_time) :0,
];
$res = DB::table($newTableName)->insert($newData);

66
app/Console/Commands/OnlineOrderStatis.php

@ -1,66 +0,0 @@
<?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;
}
}

2
app/Models/LanzuStore.php

@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Model;
class LanzuStore extends Model
{
use HasDateTimeFormatter;
protected $table = 'lanzu_store_new';
protected $table = 'lanzu_store';
protected $dateFormat = 'U';
public $timestamps = false;

16
config/wechat.php

@ -35,6 +35,11 @@ return [
'level' => env('WECHAT_LOG_LEVEL', 'debug'),
'file' => env('WECHAT_LOG_FILE', storage_path('logs/wechat.log')),
],
/**
* 获取token请求地址
*/
'token' => 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=',
],
/*
@ -129,4 +134,15 @@ return [
// //...
// ],
// ],
/*
* 生成二维码
*/
'QR_code' => [
'default' => [
'mini_code_url' => 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=',/* 小程序码 */
'wx_code_url' => 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=',/* 二维码 */
'is_wx_code' => env('WECHAT_WX_CODE_IS_OPEN', 0),/* 是否开启生成二维码 1开启,0关闭*/
],
],
];
Loading…
Cancel
Save