Commit eb09e88e by lizhilin

更新

parent 060c5f0f
...@@ -21,7 +21,8 @@ public function getList(Request $request) ...@@ -21,7 +21,8 @@ public function getList(Request $request)
if (!in_array($type, [1, 2,])) { if (!in_array($type, [1, 2,])) {
return $this->JsonResponse('', '参数错误', 201); return $this->JsonResponse('', '参数错误', 201);
} }
$sql = Income::where(['um_id' => $request->user()->id, 'user_type' => $type, 'deleted_at' => null]); $um_id = ($type == 2) ? $request->user()->merchant_id : $request->user()->id;
$sql = Income::where(['um_id' => $um_id, 'user_type' => $type, 'deleted_at' => null]);
$total = $sql->count(); $total = $sql->count();
$data = [ $data = [
......
...@@ -79,6 +79,9 @@ public function login(Request $request) ...@@ -79,6 +79,9 @@ public function login(Request $request)
$encryptedData = $request->encryptedData ?? ''; $encryptedData = $request->encryptedData ?? '';
$result = $this->codeToSession($code); $result = $this->codeToSession($code);
if (isset($result['errcode'])) {
return $this->JsonResponse('', $result['errmsg'], 201);
}
$openId = $result['openid']; $openId = $result['openid'];
$session_key = $result['session_key']; $session_key = $result['session_key'];
...@@ -160,7 +163,7 @@ private function codeToSession($code) ...@@ -160,7 +163,7 @@ private function codeToSession($code)
$wx_data = json_decode(file_get_contents($url), true); $wx_data = json_decode(file_get_contents($url), true);
if (isset($wx_data['errcode'])) { if (isset($wx_data['errcode'])) {
Log::add('请求微信接口异常', $wx_data); Log::add('请求微信接口异常', $wx_data);
return $this->JsonResponse('', '请求微信接口异常', 201); //return $this->JsonResponse('', '请求微信接口异常', 201);
} }
return $wx_data; return $wx_data;
} }
......
...@@ -45,7 +45,7 @@ public function getUserList(Request $request) ...@@ -45,7 +45,7 @@ public function getUserList(Request $request)
'uid' => $uid, 'uid' => $uid,
'name' => $item->name, 'name' => $item->name,
'divide_price' => (float)$divide_price, 'divide_price' => (float)$divide_price,
'avatar' => (isset($item->avatar) ? env('IMAGE_URL') . $item->avatar : env('NO_AVATAR_IMAGE_URL')), 'avatar' => $item->avatar ? env('IMAGE_URL') . $item->avatar : env('NO_AVATAR_IMAGE_URL'),
'created_at' => date('Y-m-d H:i:s', strtotime($item->created_at)), 'created_at' => date('Y-m-d H:i:s', strtotime($item->created_at)),
]; ];
} }
......
...@@ -497,6 +497,7 @@ public function scanCodeDetail(Request $request) ...@@ -497,6 +497,7 @@ public function scanCodeDetail(Request $request)
$code = $request->code ?? ''; $code = $request->code ?? '';
$orderObj = OrderInfoModel::where('verification_code', $code)->first(); $orderObj = OrderInfoModel::where('verification_code', $code)->first();
if (!$orderObj) { if (!$orderObj) {
Log::add('核销码', $code);
return $this->JsonResponse('', '参数错误', 201); return $this->JsonResponse('', '参数错误', 201);
} }
$order_id = $orderObj->id; $order_id = $orderObj->id;
...@@ -672,7 +673,8 @@ public function orderCollect(Request $request) ...@@ -672,7 +673,8 @@ public function orderCollect(Request $request)
$lastMonth['pickedCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereIn('order_status', [3, 4])->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count(); $lastMonth['pickedCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->whereIn('order_status', [3, 4])->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
$lastMonth['waitCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->where("order_status", 2)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count(); $lastMonth['waitCount'] = OrderInfoModel::where($where)->where('pay_status', 1)->where("order_status", 2)->whereBetween('created_at', [$firstDayOfLastMonth, $ninthDayOfLastMonth])->count();
//本月订单商品销量 //本月订单商品销量
$goods_number = OrderGoods::where('merchant_id', $merchant_id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number'); $goods_number = OrderGoods::where(['merchant_id' => $merchant_id, 'is_pay' => 1])
->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number');
$lastMonth['stockCount'] = $goods_number + $currentStock; $lastMonth['stockCount'] = $goods_number + $currentStock;
return $this->JsonResponse(['current' => $currentMonth ? $currentMonth : new \stdClass(), 'last' => $lastMonth ? $lastMonth : new \stdClass()]); return $this->JsonResponse(['current' => $currentMonth ? $currentMonth : new \stdClass(), 'last' => $lastMonth ? $lastMonth : new \stdClass()]);
......
...@@ -71,10 +71,10 @@ function haversineDistance($lat1, $lng1, $lat2, $lng2) ...@@ -71,10 +71,10 @@ function haversineDistance($lat1, $lng1, $lat2, $lng2)
$radius = 6371; $radius = 6371;
// 将角度转为弧度 // 将角度转为弧度
$lat1 = deg2rad($lat1); $lat1 = deg2rad((float)$lat1);
$lng1 = deg2rad($lng1); $lng1 = deg2rad((float)$lng1);
$lat2 = deg2rad($lat2); $lat2 = deg2rad((float)$lat2);
$lng2 = deg2rad($lng2); $lng2 = deg2rad((float)$lng2);
// 计算经纬度差值 // 计算经纬度差值
$latDiff = $lat2 - $lat1; $latDiff = $lat2 - $lat1;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace App\Models; namespace App\Models;
use App\Command\Log;
use Dcat\Admin\Traits\HasDateTimeFormatter; use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
...@@ -44,6 +45,7 @@ public function merchant() ...@@ -44,6 +45,7 @@ public function merchant()
*/ */
public static function getNumData($started = '', $ended = '', $status = [], $merchant_id = 0) public static function getNumData($started = '', $ended = '', $status = [], $merchant_id = 0)
{ {
DB::enableQueryLog();
$where = ['pay_status' => 1]; $where = ['pay_status' => 1];
$sqlObj = new self(); $sqlObj = new self();
if ($merchant_id) { if ($merchant_id) {
...@@ -58,7 +60,8 @@ public static function getNumData($started = '', $ended = '', $status = [], $mer ...@@ -58,7 +60,8 @@ public static function getNumData($started = '', $ended = '', $status = [], $mer
$sqlObj = $sqlObj->whereBetween('created_at', [$startTime, $endTime]); $sqlObj = $sqlObj->whereBetween('created_at', [$startTime, $endTime]);
} }
$count = $sqlObj->where($where)->count(); $count = $sqlObj->where($where)->count();
//$queries = DB::getQueryLog();
//Log::add("待收货统计日志", $queries);
return $count; return $count;
} }
//指定天数 //指定天数
...@@ -141,66 +144,4 @@ public static function getYearData() ...@@ -141,66 +144,4 @@ public static function getYearData()
} }
return $data; return $data;
} }
public static function CreateImportData($item): array
{
// [0] => 北海道香格里拉
// [1] => 江户川区
// [2] => 新左近川亲水公园
// [3] => 3室2厅2卫
// [4] => 21-100
// [5] => 121.23917
// [6] => 31.19145
// [7] => 精装修|有车位
// [8] => 8000-20000
// [9] => Array
// (
// [0] => /housing/20240305/d3f238df7cfe166d878b141e9562e1d0.png
// )
// [10] => 交通配套周边直
$result = $item;
// echo "<pre>";
// print_r($result);
// die;
$tags = $result[7];
if ($tags) {
$tagsArr = explode("|", $tags);
$tmp = [];
foreach ($tagsArr as $key => $val) {
//去除无标签
$exist = DB::table('tag')->where("title", $val)->first();
if ($exist) {
array_push($tmp, $val);
}
}
$tags = json_encode($tmp, JSON_UNESCAPED_UNICODE);
}
$imgs = '';
if ($item[9]) {
$imgs = json_encode($item[9], JSON_UNESCAPED_UNICODE);
}
$name = $result[0];
if ($result[0]) {
$exist = self::where("name", $result[0])->first();
$name = !$exist ? $name : '';
}
$data = [
'name' => $name,
//'area_id' => AreaModel::getIdByName($result[1]),
'position' => $result[2],
'layout_house' => $result[3],
'extent' => $result[4],
'lng' => $result[5],
'lat' => $result[6],
'tags' => $tags,
'rent' => $result[8],
'imgs' => $imgs,
'describe' => $result[10],
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
];
return $data;
}
} }
...@@ -80,10 +80,14 @@ public static function payNotify($fields = []) ...@@ -80,10 +80,14 @@ public static function payNotify($fields = [])
//更新商品销量、库存 //更新商品销量、库存
$goodsList = OrderGoods::where("order_id", $orderObj->id)->get(); $goodsList = OrderGoods::where("order_id", $orderObj->id)->get();
foreach ($goodsList as $item) { foreach ($goodsList as $item) {
//Log::add('--订单商品对象--', $item);
$gid = $item->goods_id; $gid = $item->goods_id;
$attr_id = $item->attr_id; $attr_id = $item->attr_id;
$mer_id = $item->merchant_id; $mer_id = $item->merchant_id;
$goods_number = $item->goods_number; $goods_number = $item->goods_number;
//更新此商品支付状态
$item->is_pay = 1;
$item->save();
$goodsObj = GoodModel::find($gid); $goodsObj = GoodModel::find($gid);
//更新商品规格库存 //更新商品规格库存
...@@ -128,6 +132,7 @@ public static function payNotify($fields = []) ...@@ -128,6 +132,7 @@ public static function payNotify($fields = [])
//return true; //return true;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::add('付款回调失败', $e); Log::add('付款回调失败', $e);
DB::rollBack();
return false; return false;
} }
} }
......
...@@ -44,11 +44,12 @@ public function handle(Request $request) ...@@ -44,11 +44,12 @@ public function handle(Request $request)
case '7': case '7':
default: default:
$mer_id = Admin::user()->merchant_id; $mer_id = Admin::user()->merchant_id;
$firstDayOfMonth = date('Y-m-01 00:00:00', strtotime('-1 month', time())); $firstDayOfMonth = date('Y-m-01 00:00:00'); // 00:00:00
$lastDayOfMonth = date('Y-m-t 23:59:59', strtotime('-1 month', time())); $lastDayOfMonth = date("Y-m-t 23:59:59", time());
$currentStock = MerchantGoodSku::where("merchant_id", $mer_id)->sum('stock'); $currentStock = MerchantGoodSku::where("merchant_id", $mer_id)->sum('stock');
//本月订单商品销量 //本月订单商品销量
$goods_number = OrderGoods::where('merchant_id', $mer_id)->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number'); $goods_number = OrderGoods::where(['merchant_id' => $mer_id, 'is_pay' => 1])
->whereBetween('created_at', [$firstDayOfMonth, $lastDayOfMonth])->sum('goods_number');
$total = $goods_number + $currentStock; $total = $goods_number + $currentStock;
// 卡片内容 // 卡片内容
$this->withContent($total); $this->withContent($total);
......
...@@ -44,7 +44,7 @@ public function handle(Request $request) ...@@ -44,7 +44,7 @@ public function handle(Request $request)
$started = date('Y-m-01', strtotime('last month')); $started = date('Y-m-01', strtotime('last month'));
$ended = date('Y-m-t', strtotime('last month')); $ended = date('Y-m-t', strtotime('last month'));
$order_status = [2]; $order_status = [2];
$count = OrderInfoModel::getNumData($started, $ended, $order_status, Admin::user()->id); $count = OrderInfoModel::getNumData($started, $ended, $order_status, Admin::user()->merchant_id);
// 卡片内容 // 卡片内容
$this->withContent($count); $this->withContent($count);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment