Merge pull request 'dev' (#16) from dev into master

Reviewed-on: http://git.excellentkk.cn/mkm/shop-php/pulls/16
This commit is contained in:
mkm 2023-08-29 18:18:24 +08:00
commit 3433b476aa
11 changed files with 120 additions and 20 deletions

View File

@ -109,9 +109,17 @@ class CommunityRepository extends BaseRepository
$config = systemConfig("community_app_switch");
// if (!isset($where['is_type']) && $config) $where['is_type'] = is_array($config) ? implode(',', $config) : $config;
if (empty($where['is_type'])) $where['is_type'] = '1,2';
$uIdArray = [];
if ($where['is_type'] == 3) {
$categoryId = Db::name('merchant')->where('uid', $userInfo->uid)->where('status', 1)->value('category_id');
$uIdArray = Db::name('merchant')->where('category_id', $categoryId)->where('status', 1)->where('uid', '>', 0)->column('uid');
}
$where['is_del'] = 0;
$query = $this->dao->search($where)->when(in_array(self::COMMUNITY_TYPE_RESALE, explode(',', $where['is_type'])), function ($query) {
$query->where('is_sale', 0);
$query = $this->dao->search($where)->when(in_array(self::COMMUNITY_TYPE_RESALE, explode(',', $where['is_type'])), function ($query) use ($where, $uIdArray) {
$query->where('Community.is_sale', 0);
if (is_array($uIdArray) && count($uIdArray) > 0) {
$query->whereIn('Community.uid', $uIdArray);
}
})->order('start DESC,Community.create_time DESC,community_id DESC');
$query->with([
'author' => function($query) use($userInfo){
@ -138,7 +146,6 @@ class CommunityRepository extends BaseRepository
$list = $query->page($page, $limit)->setOption('field',[])
->field('community_id,title,image,resale_type,topic_id,Community.count_start,count_reply,start,Community.create_time,Community.uid,Community.status,is_show,content,video_link,is_type,refusal')
->select()->append(['time']);
if ($list) $list = $list->toArray();
foreach ($list as $k => $item) {
if ($item['is_type'] == self::COMMUNITY_TYPE_RESALE) {

View File

@ -114,7 +114,8 @@ class StoreGroupOrderRepository extends BaseRepository
*/
public function detail($uid, $id, $flag = true)
{
$where = $this->getAll ? ['uid' => $uid] : ['paid' => 0, 'uid' => $uid];
// 'paid' => 0
$where = $this->getAll ? ['uid' => $uid] : ['uid' => $uid];
$order = StoreGroupOrder::where($where)
->where('group_order_id', $id)
->where('is_del', 0)
@ -126,6 +127,9 @@ class StoreGroupOrderRepository extends BaseRepository
}, 'orderProduct', 'presellOrder']);
}, 'interest'])
->order('create_time DESC')->append(['cancel_time', 'cancel_unix'])->find();
if ($order['paid'] == 1 && $order['pay_type'] != 8) {
throw new DataNotFoundException('订单不存在或已取消');
}
if (empty($order)) {
throw new DataNotFoundException('订单不存在或已取消');
}

View File

@ -112,9 +112,9 @@ class StoreOrderCreateRepository extends StoreOrderRepository
if (count(array_unique($sourceIdArray)) > 1) {
throw new ValidateException('转售商品数据异常');
}
$community = Db::name('Community')->where('community_id', $communityIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find();
$community = Db::name('Community')->where('community_id', $sourceIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find();
if ($community) {
$deliverMethod = Db::name('resale')->where('community_id', $communityIdArray[0] ?? 0)->value('deliver_method');
$deliverMethod = Db::name('resale')->where('community_id', $sourceIdArray[0] ?? 0)->value('deliver_method');
$deliverMethodArray = explode(',', $deliverMethod);
}
}

View File

@ -1715,7 +1715,7 @@ class StoreOrderRepository extends BaseRepository
} else {
$query = $this->dao->search($where)->where($this->getOrderType($status))->where('StoreOrder.is_del', 0);
}
$count = $query->count();
$list = $query->with([
'orderProduct',
@ -1756,7 +1756,7 @@ class StoreOrderRepository extends BaseRepository
}
public function getOrderStatusV2($order) {
// 订单状态 1 未支付 2待发货 3待收货 4待评价 5交易完成 6已退款 7待核销
//订单状态 1 未支付 2待发货 3待收货 4待评价 5交易完成 6已退款 7待核销 8先货后款待结算
$order->order_status = 0;
if ($order->paid == 0) {
$order->order_status = 1;
@ -1779,6 +1779,10 @@ class StoreOrderRepository extends BaseRepository
if ($order->paid == 1 && $order->status == 0 && $order->order_type == 1) {
$order->order_status = 7;
}
//如果是先货后款信用购的状态处理
if ($order->paid == 1 && $order->status == 2 && $order->pay_type == 8) {
$order->order_status = 8;
}
return $order->order_status;
}
@ -2643,6 +2647,12 @@ class StoreOrderRepository extends BaseRepository
$order->interest->save();
}
} else {
if ($groupOrder->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY) {
//如果是先货后款并且选择到店核销、同意时生成核销码
if (!empty($order->order_type) && $order->order_type == 1) {
$order->verify_code = $this->verifyCode();
}
}
$order->status = StoreOrder::STATUS_WAIT_PAY;
$groupOrder->paid = 1;
$groupOrder->pay_time = date('Y-m-d H:i:s');

View File

@ -407,7 +407,7 @@ class StoreRefundOrderRepository extends BaseRepository
$orderId = $order->order_id;
//TODO 订单状态生成佣金
$product = app()->make(StoreOrderProductRepository::class)->userRefundProducts([$productId], $uid, $orderId);
if (!$product)
if ($product->isEmpty())
throw new ValidateException('请选择正确的退款商品');
$product = $product[0];
if ($product['refund_num'] < $num)

View File

@ -152,7 +152,7 @@ class RelevanceRepository extends BaseRepository
* @author Qinii
* @day 10/28/21
*/
public function getUserFans(int $uid, int $page, int $limit)
public function getUserFans(int $uid, int $page, int $limit, int $statistics = 0)
{
$query = $this->dao->getSearch([
'right_id' => $uid,
@ -163,6 +163,9 @@ class RelevanceRepository extends BaseRepository
}
]);
$count = $query->count();
if ($statistics == 1) {
return $count;
}
$list = $query->page($page, $limit)->select()->append(['is_start']);
return compact('count','list');
}
@ -174,7 +177,7 @@ class RelevanceRepository extends BaseRepository
* @author Qinii
* @day 10/28/21
*/
public function getUserFocus(int $uid, int $page, int $limit)
public function getUserFocus(int $uid, int $page, int $limit, int $statistics = 0)
{
$query = $this->dao->getSearch([
'left_id' => $uid,
@ -185,6 +188,9 @@ class RelevanceRepository extends BaseRepository
}
]);
$count = $query->count();
if ($statistics == 1) {
return $count;
}
$list = $query->page($page, $limit)->select()->append(['is_fans']);
return compact('count','list');
}

View File

@ -49,9 +49,18 @@ class MerchantTypeRepository extends BaseRepository
return compact('count', 'list');
}
public function getSelect($getAll = true)
public function getSelect($getAll = true, $siftStore = false)
{
$merTypeIds = $this->userApply ? Merchant::AllowApply : Merchant::AllowDisplay;
// 特殊处理市级云仓
// Merchant::TypeSupplyChain
if ($siftStore == true) {
foreach($merTypeIds as $k=>$v) {
if ($v == Merchant::TypeSupplyChain) {
unset($merTypeIds[$k]);
}
}
}
$query = MerchantType::getDB()->when(!$getAll, function ($query) use ($merTypeIds) {
$query->whereIn('mer_type_id', $merTypeIds);
})->field('mer_type_id,type_name');

View File

@ -17,10 +17,12 @@ namespace app\controller\api;
use app\common\repositories\store\order\StoreOrderRepository;
use app\common\repositories\store\order\StoreRefundOrderRepository;
use app\common\repositories\system\notice\SystemNoticeConfigRepository;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\user\UserRepository;
use app\common\repositories\user\UserSignRepository;
use app\common\repositories\wechat\RoutineQrcodeRepository;
use app\common\repositories\wechat\WechatUserRepository;
use app\common\repositories\system\RelevanceRepository;
use app\validate\api\ChangePasswordValidate;
use app\validate\api\UserAuthValidate;
use crmeb\basic\BaseController;
@ -213,6 +215,9 @@ class Auth extends BaseController
}
$data['mer_info'] = $mer_arr;
}
$data['fan_num'] = app()->make(RelevanceRepository::class)->getUserFans($user->uid, 1, 1, 1);
$data['focus_num'] = app()->make(RelevanceRepository::class)->getUserFocus($user->uid, 1, 1, 1);
$data['community_num'] = Db::name('community')->where('uid', $user->uid)->whereIn('is_type', '1,2')->count();
return app('json')->success($data);
}
@ -886,6 +891,22 @@ class Auth extends BaseController
}
}
//获取商户分类类别和店铺类型类别
public function merchantCate()
{
$cateList = Db::name('MerchantCategory')->field(['merchant_category_id', 'category_name'])->select();
$typeList = [
['merchant_category_id' => Merchant::TypeStore ?? 0, 'category_name' => Merchant::TypeMap[Merchant::TypeStore] ?? ''],
['merchant_category_id' => Merchant::TypeTownSupplyChain ?? 0, 'category_name' => Merchant::TypeMap[Merchant::TypeTownSupplyChain] ?? ''],
['merchant_category_id' => Merchant::TypeSupplyChain ?? 0, 'category_name' => Merchant::TypeMap[Merchant::TypeSupplyChain] ?? '']
];
$data = [
'category' => $cateList,
'type' => $typeList
];
return app('json')->success($data);
}
//根据地址信息查询汇总信息
public function orderStatistics()
{
@ -894,9 +915,21 @@ class Auth extends BaseController
$streetCode = $this->request->param('street_code', '');
$villageCode = $this->request->param('village_code', '');
$brigadeId = $this->request->param('brigade_id', 0);
$categoryId = $this->request->param('category_id', 0);
$typeId = $this->request->param('type_id', 0);
$startDate = $this->request->param('start_date', '');
$endDate = $this->request->param('end_date', '');
$queryBuilder = Db::name('ProductOrderLog')->where('status', 1);
//根据商户分类店铺类型筛选商户
$queryMerBuilder = Db::name('Merchant');
if ($categoryId) {
$queryMerBuilder = $queryMerBuilder->where('category_id', $categoryId);
}
if ($typeId) {
$queryMerBuilder = $queryMerBuilder->where('type_id', $typeId);
}
$merIdArray = $queryMerBuilder->fetchSql(false)->column('mer_id');
$queryBuilder = $queryBuilder->whereIn('mer_id', $merIdArray);
if ($cityCode) {
$queryBuilder = $queryBuilder->where('city_code', $cityCode);
}
@ -918,7 +951,7 @@ class Auth extends BaseController
if ($endDate) {
$queryBuilder = $queryBuilder->whereTime('create_time', '<=', trim($endDate) . ' 23:59:59');
}
$orderNum = $queryBuilder->count();
$orderNum = $queryBuilder->fetchSql(false)->count();
$productNum = $queryBuilder->sum('product_num');
$totalPrice = $queryBuilder->sum('total_price');
$data = [
@ -939,9 +972,21 @@ class Auth extends BaseController
$streetCode = $this->request->param('street_code', '');
$villageCode = $this->request->param('village_code', '');
$brigadeId = $this->request->param('brigade_id', 0);
$categoryId = $this->request->param('category_id', 0);
$typeId = $this->request->param('type_id', 0);
$startDate = $this->request->param('start_date', '');
$endDate = $this->request->param('end_date', '');
$queryBuilder = Db::name('ProductOrderLog')->where('status', 1);
//根据商户分类店铺类型筛选商户
$queryMerBuilder = Db::name('Merchant');
if ($categoryId) {
$queryMerBuilder = $queryMerBuilder->where('category_id', $categoryId);
}
if ($typeId) {
$queryMerBuilder = $queryMerBuilder->where('type_id', $typeId);
}
$merIdArray = $queryMerBuilder->fetchSql(false)->column('mer_id');
$queryBuilder = $queryBuilder->whereIn('mer_id', $merIdArray);
if ($cityCode) {
$queryBuilder = $queryBuilder->where('city_code', $cityCode);
}
@ -963,7 +1008,7 @@ class Auth extends BaseController
if ($endDate) {
$queryBuilder = $queryBuilder->whereTime('create_time', '<=', trim($endDate) . ' 23:59:59');
}
$count = $queryBuilder->count();
$count = $queryBuilder->fetchSql(false)->count();
$list = $queryBuilder->setOption('field', [])->field(['id', 'order_id', 'product_num', 'product_price', 'total_price', 'city_code', 'district_code', 'street_code', 'village_code', 'brigade_id', 'create_time'])->order('id', 'desc')->page($page, $limit)->fetchSql(false)->select();
$orderIdList = [];
if ($list) {
@ -985,11 +1030,18 @@ class Auth extends BaseController
$districtCode = $this->request->param('district_code', '');
$streetCode = $this->request->param('street_code', '');
$villageCode = $this->request->param('village_code', '');
$categoryId = $this->request->param('category_id', 0);
$typeId = $this->request->param('type_id', 0);
$startDate = $this->request->param('start_date', '');
$endDate = $this->request->param('end_date', '');
$villageId = Db::name('GeoVillage')->where('village_code', $villageCode)->fetchSql(false)->value('village_id', 0);
$queryBuilder = Db::name('Merchant')->where('status', 1);
$queryBuilder = Db::name('Merchant');
if ($categoryId) {
$queryBuilder = $queryBuilder->where('category_id', $categoryId);
}
if ($typeId) {
$queryBuilder = $queryBuilder->where('type_id', $typeId);
}
if ($districtCode) {
$queryBuilder = $queryBuilder->where('area_id', $districtCode);
}
@ -1019,10 +1071,18 @@ class Auth extends BaseController
$districtCode = $this->request->param('district_code', '');
$streetCode = $this->request->param('street_code', '');
$villageCode = $this->request->param('village_code', '');
$categoryId = $this->request->param('category_id', 0);
$typeId = $this->request->param('type_id', 0);
$startDate = $this->request->param('start_date', '');
$endDate = $this->request->param('end_date', '');
$villageId = Db::name('GeoVillage')->where('village_code', $villageCode)->fetchSql(false)->value('village_id', 0);
$queryBuilder = Db::name('Merchant')->where('status', 1);
$queryBuilder = Db::name('Merchant');
if ($categoryId) {
$queryBuilder = $queryBuilder->where('category_id', $categoryId);
}
if ($typeId) {
$queryBuilder = $queryBuilder->where('type_id', $typeId);
}
if ($districtCode) {
$queryBuilder = $queryBuilder->where('area_id', $districtCode);
}
@ -1045,7 +1105,7 @@ class Auth extends BaseController
'where' => $this->request->param(),
'goods_num' => $goodsNum
];
return app('json')->success($data);
return app('json')->success($data);
}
}

View File

@ -160,9 +160,10 @@ class MerchantIntention extends BaseController
public function typeLst()
{
/** @var MerchantTypeRepository $repo */
$siftStore = $this->request->param('sift_store', 0);
$repo = app()->make(MerchantTypeRepository::class);
$repo->userApply = true;
$lst = $repo->getSelect(false);
$lst = $repo->getSelect(false, $siftStore);
return app('json')->success($lst);
}
}

View File

@ -130,7 +130,9 @@ class StoreRefundOrder extends BaseController
if (!$order->refund_status)
return app('json')->fail('订单已过退款/退货期限');
if ($order->status < 0) return app('json')->fail('订单已退款');
if ($order->status == 1) return app('json')->fail('订单已发货不支持退款');
if ($order->activity_type == 0) {
if ($order->status == 1) return app('json')->fail('订单已发货不支持退款');
}
if ($order->status == 10) return app('json')->fail('订单不支持退款');
if($order->is_virtual && $data['refund_type'] == 2) return app('json')->fail('订单不支持退款退货');
if ($type == 1) {

View File

@ -23,6 +23,7 @@ Route::group('api/', function () {
Route::any('test', 'api.Auth/test');
Route::any('dotest', 'api.Auth/dotest');
Route::post('goods/take/:id', 'api.Auth/deliveryGoods');
Route::get('merchant/cate', 'api.Auth/merchantCate');
Route::get('order/statistics', 'api.Auth/orderStatistics');
Route::get('region/order', 'api.Auth/orderList');
Route::get('region/merchant', 'api.Auth/merStatistics');