修改预订单创建
This commit is contained in:
parent
444b011d0f
commit
a034ae5ec1
@ -52,7 +52,8 @@ class StoreProductPriceLists extends BaseAdminDataLists implements ListsSearchIn
|
|||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function($item){
|
->select()->each(function($item){
|
||||||
$find = StoreProduct::where('id', $item['product_id'])->field('image,store_name,store_info')->find();
|
$find = StoreProduct::with('unitName')->where('id', $item['product_id'])->field('image,store_name,store_info,unit')->find();
|
||||||
|
$item['unit_name']=$find['unitName']['name'];
|
||||||
$item['store_name']=$find['store_name'];
|
$item['store_name']=$find['store_name'];
|
||||||
$item['store_info']=$find['store_info'];
|
$item['store_info']=$find['store_info'];
|
||||||
$item['image']=$find['image'];
|
$item['image']=$find['image'];
|
||||||
|
@ -70,6 +70,13 @@ class BeforehandOrderLogic extends BaseLogic
|
|||||||
$total_num = 0;
|
$total_num = 0;
|
||||||
$total_price = 0;
|
$total_price = 0;
|
||||||
$uid = $params['uid'] ?? 0;
|
$uid = $params['uid'] ?? 0;
|
||||||
|
if (!empty($uid) && empty($params['other_data']['nickname'])) {
|
||||||
|
$user = User::where('id', $uid)->field('nickname,mobile')->find();
|
||||||
|
$userAddress = UserAddress::getDefaultAddress($uid);
|
||||||
|
$params['other_data']['nickname'] = $user['nickname'];
|
||||||
|
$params['other_data']['phone'] = $user['mobile'];
|
||||||
|
$params['other_data']['address'] = !empty($userAddress) ? $userAddress['area']['area_name'] . $userAddress['street']['street_name'] . $userAddress['village']['village_name'] . $userAddress['brigade']['brigade_name'] . $userAddress['detail'] : '';
|
||||||
|
}
|
||||||
foreach ($params['product_arr'] as $k => $v) {
|
foreach ($params['product_arr'] as $k => $v) {
|
||||||
if ($v['product_id'] <= 0) {
|
if ($v['product_id'] <= 0) {
|
||||||
unset($params['product_arr'][$k]);
|
unset($params['product_arr'][$k]);
|
||||||
|
16
app/common/model/geo/GeoArea.php
Normal file
16
app/common/model/geo/GeoArea.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoArea
|
||||||
|
* @package app\common\model\geo\GeoArea
|
||||||
|
*/
|
||||||
|
class GeoArea extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_area';
|
||||||
|
|
||||||
|
}
|
16
app/common/model/geo/GeoBrigade.php
Normal file
16
app/common/model/geo/GeoBrigade.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoBrigade
|
||||||
|
* @package app\common\model\geo\GeoBrigade
|
||||||
|
*/
|
||||||
|
class GeoBrigade extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_brigade';
|
||||||
|
|
||||||
|
}
|
16
app/common/model/geo/GeoCity.php
Normal file
16
app/common/model/geo/GeoCity.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoCity
|
||||||
|
* @package app\common\model\geo\GeoCity
|
||||||
|
*/
|
||||||
|
class GeoCity extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_city';
|
||||||
|
|
||||||
|
}
|
16
app/common/model/geo/GeoProvince.php
Normal file
16
app/common/model/geo/GeoProvince.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoProvince
|
||||||
|
* @package app\common\model\geo\GeoProvince
|
||||||
|
*/
|
||||||
|
class GeoProvince extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_province';
|
||||||
|
|
||||||
|
}
|
16
app/common/model/geo/GeoStreet.php
Normal file
16
app/common/model/geo/GeoStreet.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoStreet
|
||||||
|
* @package app\common\model\geo\GeoStreet
|
||||||
|
*/
|
||||||
|
class GeoStreet extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_street';
|
||||||
|
|
||||||
|
}
|
16
app/common/model/geo/GeoVillage.php
Normal file
16
app/common/model/geo/GeoVillage.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\common\model\geo;
|
||||||
|
|
||||||
|
use app\common\model\BaseModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class GeoVillage
|
||||||
|
* @package app\common\model\geo\GeoVillage
|
||||||
|
*/
|
||||||
|
class GeoVillage extends BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $name = 'geo_village';
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,10 @@ namespace app\common\model\user;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\model\BaseModel;
|
use app\common\model\BaseModel;
|
||||||
|
use app\common\model\geo\GeoArea;
|
||||||
|
use app\common\model\geo\GeoBrigade;
|
||||||
|
use app\common\model\geo\GeoStreet;
|
||||||
|
use app\common\model\geo\GeoVillage;
|
||||||
use think\model\concern\SoftDelete;
|
use think\model\concern\SoftDelete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,4 +23,33 @@ class UserAddress extends BaseModel
|
|||||||
|
|
||||||
protected $deleteTime = 'delete_time';
|
protected $deleteTime = 'delete_time';
|
||||||
|
|
||||||
|
public static function getDefaultAddress($uid)
|
||||||
|
{
|
||||||
|
$address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid, 'is_default' => 1])->find();
|
||||||
|
if (empty($address)) {
|
||||||
|
$address = self::with(['area', 'street', 'village', 'brigade'])->where(['uid' => $uid])->find();
|
||||||
|
}
|
||||||
|
return empty($address) ? [] : $address->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function area()
|
||||||
|
{
|
||||||
|
return $this->hasOne(GeoArea::class, 'area_code', 'area')->field('area_code,area_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function street()
|
||||||
|
{
|
||||||
|
return $this->hasOne(GeoStreet::class, 'street_code', 'street')->field('street_code,street_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function village()
|
||||||
|
{
|
||||||
|
return $this->hasOne(GeoVillage::class, 'village_code', 'village')->field('village_code,village_name');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function brigade()
|
||||||
|
{
|
||||||
|
return $this->hasOne(GeoBrigade::class, 'id', 'brigade')->field('id,brigade_name');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user