This commit is contained in:
mkm 2023-12-27 09:52:55 +08:00
parent d684d0ac8e
commit ac02f0247f
6 changed files with 495 additions and 43 deletions

View File

@ -0,0 +1,101 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\dao\store\order;
use app\common\dao\BaseDao;
use app\common\model\store\order\StoreGroupOrderOther;
use app\common\model\store\order\StoreOrderOther;
/**
* Class StoreGroupOrderOtherDao
* @package app\common\dao\store\order
* @author xaboy
* @day 2020/6/9
*/
class StoreGroupOrderOtherDao extends BaseDao
{
/**
* @return string
* @author xaboy
* @day 2020/6/9
*/
protected function getModel(): string
{
return StoreGroupOrderOther::class;
}
/**
* @param null $uid
* @return int
* @author xaboy
* @day 2020/6/11
*/
public function orderNumber($uid = null, $productType = 0)
{
$storeOrderWhere = StoreOrderOther::where('activity_type', $productType);
return StoreGroupOrderOther::hasWhere('orderList', $storeOrderWhere)->when($uid, function ($query, $uid) {
$query->where('StoreGroupOrder.uid', $uid);
})->where('StoreGroupOrder.is_del', 0)->whereRaw("(StoreGroupOrder.paid=0 and status!=12) or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8 and StoreOrder.status=2)")->count();
}
/**
* @param array $where
* @return \think\db\BaseQuery
* @author xaboy
* @day 2020/6/9
*/
public function search(array $where)
{
return StoreGroupOrderOther::getDB()->alias('StoreGroupOrder')->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
if ($where['paid'] == 0) {
$query->whereRaw("StoreGroupOrder.paid=0 or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8)");
} else {
$query->where('StoreGroupOrder.paid', $where['paid']);
}
})->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
$query->where('StoreGroupOrder.uid', $where['uid']);
})->order('create_time DESC')->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
$query->where('StoreGroupOrder.is_del', $where['is_del']);
}, function ($query) {
$query->where('StoreGroupOrder.is_del', 0);
});
}
/**
* @param $time
* @param bool $is_remind
* @return array
* @author xaboy
* @day 2020/6/9
*/
public function getTimeOutIds($time, $is_remind = false)
{
return StoreGroupOrderOther::getDB()->where('is_del', 0)->where('paid', 0)
->when($is_remind, function ($query) {
$query->where('is_remind', 0);
})->where('create_time', '<=', $time)->column('group_order_id');
}
public function isRemind($id)
{
return StoreGroupOrderOther::getDB()->where('group_order_id', $id)->update(['is_remind' => 1]);
}
public function totalNowMoney($uid)
{
return StoreGroupOrderOther::getDB()->where('pay_type', 0)->where('uid', $uid)->sum('pay_price') ?: 0;
}
}

View File

@ -0,0 +1,151 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreGroupOrderDao;
use app\common\model\store\order\StoreGroupOrderOther;
use app\common\model\store\order\StoreOrderOther;
use app\common\repositories\BaseRepository;
use think\db\exception\DataNotFoundException;
use think\model\Relation;
/**
* Class StoreGroupOrderOtherRepository
* @package app\common\repositories\store\order
* @author xaboy
* @day 2020/6/8
* @mixin StoreGroupOrderDao
*/
class StoreGroupOrderOtherRepository extends BaseRepository
{
public $getAll = false;
/**
* StoreGroupOrderRepository constructor.
* @param StoreGroupOrderDao $dao
*/
public function __construct(StoreGroupOrderDao $dao)
{
$this->dao = $dao;
}
/**
* @param array $where
* @param $page
* @param $limit
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author xaboy
* @day 2020/6/10
*/
public function getList(array $where, $page, $limit)
{
$query = StoreGroupOrderOther::getDB()->alias('StoreGroupOrder');
if (isset($where['product_type'])) {
$storeOrderWhere = StoreOrderOther::where('activity_type', $where['product_type']);
$query->hasWhere('orderList', $storeOrderWhere);
}
$query->when(isset($where['paid']) && $where['paid'] !== '', function ($query) use ($where) {
if ($where['paid'] == 0) {
$query->whereRaw("(StoreGroupOrder.paid=0 and status!=12) or (StoreGroupOrder.paid=1 and StoreGroupOrder.pay_type=8 and StoreOrder.status=2)");
} else {
$query->where('StoreGroupOrder.paid', $where['paid']);
}
})->when(isset($where['uid']) && $where['uid'] !== '', function ($query) use ($where) {
$query->where('StoreGroupOrder.uid', $where['uid']);
})->order('create_time DESC')->when(isset($where['is_del']) && $where['is_del'] !== '', function ($query) use ($where) {
$query->where('StoreGroupOrder.is_del', $where['is_del']);
}, function ($query) {
$query->where('StoreGroupOrder.is_del', 0);
});
$count = $query->count();
$groupList = $query->with(['orderList' => function (Relation $query) {
$query->field('order_id,group_order_id,activity_type,pay_price,status,mer_id')->with(['merchant' => function ($query) {
$query->field('mer_id,mer_name,settle_cycle,interest_rate');
}, 'orderProduct','presellOrder']);
}, 'interest'])->page($page, $limit)->order('create_time DESC')->select();
$list = [];
foreach ($groupList as $k => $item) {
$current = $item->toArray();
if (!empty($item->interest)) {
$interest = $item->interest->calculateInterest();
$current['interest']['total_amount'] = bcadd($item->interest->total_price, $interest, 2);
} else {
$current['interest']['total_amount'] = $item['total_price'];
}
$list[] = $current;
}
return compact('count', 'list');
}
/**
* @param $uid
* @param $id
* @return array|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author xaboy
* @day 2020/6/10
*/
public function detail($id, $flag = true)
{
// 'paid' => 0
$order = StoreGroupOrderOther::where('group_order_id', $id)
->where('is_del', 0)
->with(['orderList' => function (Relation $query) use ($flag) {
$query->when($flag, function ($query) {
$query->field('order_id,group_order_id,mer_id,order_sn,activity_type,pay_price,order_extend,order_type,is_virtual');
})->with(['merchant' => function ($query) use ($flag) {
$flag && $query->field('mer_id,mer_name,settle_cycle,interest_rate');
}, '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('订单不存在或已取消');
}
if (!empty($order->interest)) {
$interest = $order->interest->calculateInterest();
$order->interest->interest = $interest;
$order->interest->total_amount = bcadd($order->interest->total_price, $interest, 2);
}
return $order;
}
public function status($uid, $id)
{
return $this->search(['uid' => $uid])->where('group_order_id', $id)->append(['give_coupon'])->find();
}
/**
* @param $id
* @return array|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author xaboy
* @day 2020/6/10
*/
public function getCancelDetail($id)
{
return $this->search(['paid' => 0, 'is_del' => 1])->where('group_order_id', $id)->with(['orderList.orderProduct'])->find();
}
}

View File

@ -2,33 +2,19 @@
namespace app\common\repositories\store\order; namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreCartDao;
use app\common\model\store\order\StoreGroupOrder;
use app\common\model\store\order\StoreOrder;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\community\CommunityRepository;
use app\common\repositories\store\coupon\StoreCouponRepository;
use app\common\repositories\store\coupon\StoreCouponUserRepository; use app\common\repositories\store\coupon\StoreCouponUserRepository;
use app\common\repositories\store\product\ProductAssistSkuRepository;
use app\common\repositories\store\product\ProductAttrValueRepository; use app\common\repositories\store\product\ProductAttrValueRepository;
use app\common\repositories\store\product\ProductGroupSkuRepository;
use app\common\repositories\store\product\ProductPresellSkuRepository;
use app\common\repositories\store\product\ProductRepository; use app\common\repositories\store\product\ProductRepository;
use app\common\repositories\store\product\StoreDiscountRepository;
use app\common\repositories\store\StoreCategoryRepository;
use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\system\merchant\MerchantRepository;
use app\common\repositories\user\MemberinterestsRepository; use app\common\repositories\user\MemberinterestsRepository;
use app\common\repositories\user\UserAddressRepository; use app\common\repositories\user\UserAddressRepository;
use app\common\repositories\user\UserBillRepository;
use app\common\repositories\user\UserMerchantRepository; use app\common\repositories\user\UserMerchantRepository;
use app\common\repositories\user\UserRepository; use app\common\repositories\user\UserRepository;
use app\validate\api\OrderVirtualFieldValidate; use app\validate\api\OrderVirtualFieldValidate;
use app\validate\api\UserAddressValidate; use app\validate\api\UserAddressValidate;
use crmeb\jobs\SendSmsJob;
use crmeb\services\SwooleTaskService;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Db; use think\facade\Db;
use think\facade\Queue;
class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository
{ {
@ -588,8 +574,6 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository
'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2), 'coupon_price' => bcadd($merchantCart['order']['coupon_price'], $merchantCart['order']['platform_coupon_price'], 2),
'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'], 'platform_coupon_price' => $merchantCart['order']['platform_coupon_price'],
'pay_type' => $pay_type, 'pay_type' => $pay_type,
'paid'=>1,
'pay_time'=>date('Y-m-d H:i:s',time()),
]; ];
$allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']); $allUseCoupon = array_merge($allUseCoupon, $merchantCart['order']['useCouponIds']);
$orderList[] = $_order; $orderList[] = $_order;
@ -729,6 +713,6 @@ class StoreOtherOrderCreateRepository extends StoreOtherOrderRepository
Db::name('store_order_product_other')->insertAll($orderProduct); Db::name('store_order_product_other')->insertAll($orderProduct);
return $groupOrder; return $groupOrder;
}); });
return $this->paySuccess($group); return $group;
} }
} }

View File

@ -11,51 +11,29 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
namespace app\common\repositories\store\order; namespace app\common\repositories\store\order;
use app\common\dao\store\order\StoreCartDao;
use app\common\dao\store\order\StoreOrderOtherDao; use app\common\dao\store\order\StoreOrderOtherDao;
use app\common\model\store\order\StoreGroupOrderOther; use app\common\model\store\order\StoreGroupOrderOther;
use app\common\model\store\order\StoreOtherOrder;
use app\common\model\store\order\StoreOrderInterestOther; use app\common\model\store\order\StoreOrderInterestOther;
use app\common\model\store\order\StoreOrderOther; use app\common\model\store\order\StoreOrderOther;
use app\common\model\store\order\StoreOtherOrderInterest;
use app\common\model\store\order\StoreRefundOrder; use app\common\model\store\order\StoreRefundOrder;
use app\common\model\store\product\PurchaseRecord;
use app\common\model\user\User; use app\common\model\user\User;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\BaseRepository; use app\common\repositories\BaseRepository;
use app\common\repositories\delivery\DeliveryOrderRepository;
use app\common\repositories\store\coupon\StoreCouponRepository;
use app\common\repositories\store\coupon\StoreCouponUserRepository;
use app\common\repositories\store\product\ProductAssistSetRepository;
use app\common\repositories\store\product\ProductCopyRepository;
use app\common\repositories\store\product\ProductGroupBuyingRepository;
use app\common\repositories\store\product\ProductPresellSkuRepository;
use app\common\repositories\store\product\ProductRepository; use app\common\repositories\store\product\ProductRepository;
use app\common\repositories\store\product\StoreDiscountRepository;
use app\common\repositories\store\shipping\ExpressRepository; use app\common\repositories\store\shipping\ExpressRepository;
use app\common\repositories\store\StorePrinterRepository; use app\common\repositories\store\StorePrinterRepository;
use app\common\repositories\store\StoreSeckillActiveRepository;
use app\common\repositories\system\attachment\AttachmentRepository; use app\common\repositories\system\attachment\AttachmentRepository;
use app\common\repositories\system\merchant\FinancialRecordRepository; use app\common\repositories\system\merchant\FinancialRecordRepository;
use app\common\repositories\system\merchant\MerchantRepository; use app\common\repositories\system\merchant\MerchantRepository;
use app\common\repositories\system\serve\ServeDumpRepository;
use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserBillRepository;
use app\common\repositories\user\UserBrokerageRepository;
use app\common\repositories\user\UserMerchantRepository; use app\common\repositories\user\UserMerchantRepository;
use app\common\repositories\user\UserRepository; use app\common\repositories\user\UserRepository;
use crmeb\jobs\PayGiveCouponJob;
use crmeb\jobs\ProductImportJob;
use crmeb\jobs\SendSmsJob; use crmeb\jobs\SendSmsJob;
use crmeb\jobs\SendGoodsCodeJob;
use crmeb\jobs\UserBrokerageLevelJob;
use crmeb\services\CombinePayService; use crmeb\services\CombinePayService;
use crmeb\services\CrmebServeServices;
use crmeb\services\ExpressService; use crmeb\services\ExpressService;
use crmeb\services\PayService; use crmeb\services\PayService;
use crmeb\services\payTool\PayTool; use crmeb\services\payTool\PayTool;
use crmeb\services\printer\Printer; use crmeb\services\printer\Printer;
use crmeb\services\QrcodeService; use crmeb\services\QrcodeService;
use crmeb\services\SpreadsheetExcelService;
use crmeb\services\SwooleTaskService; use crmeb\services\SwooleTaskService;
use Exception; use Exception;
use FormBuilder\Factory\Elm; use FormBuilder\Factory\Elm;
@ -69,7 +47,6 @@ use think\facade\Log;
use think\facade\Queue; use think\facade\Queue;
use think\facade\Route; use think\facade\Route;
use think\Model; use think\Model;
use app\controller\admin\ProductLibrary;
/**其他订单 /**其他订单
@ -191,7 +168,7 @@ class StoreOtherOrderRepository extends BaseRepository
$i = 1; $i = 1;
$isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder); $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder);
//订单记录 //订单记录
$storeOrderStatusRepository = app()->make(StoreOtherOrderRepository::class); $storeOrderStatusRepository = app()->make(StoreOrderStatusOtherRepository::class);
$svipDiscount = 0; $svipDiscount = 0;
foreach ($groupOrder->orderList as $_k => $order) { foreach ($groupOrder->orderList as $_k => $order) {
$order->paid = 1; $order->paid = 1;
@ -340,8 +317,9 @@ class StoreOtherOrderRepository extends BaseRepository
} }
$financialRecordRepository->insertAll($finance); $financialRecordRepository->insertAll($finance);
$storeOrderStatusRepository->batchCreateLog($orderStatus); $storeOrderStatusRepository->batchCreateLog($orderStatus);
$groupOrder->save(); $groupOrder->save();
}); });
return true;
} }

View File

@ -0,0 +1,192 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\order;
use crmeb\basic\BaseController;
use app\common\repositories\store\ExcelRepository;
use app\common\repositories\system\merchant\MerchantRepository;
use app\common\repositories\store\order\StoreOtherOrderRepository as repository;
use app\common\repositories\store\order\StoreGroupOrderOtherRepository;
use crmeb\services\ExcelService;
use think\App;
class OrderOther extends BaseController
{
protected $repository;
public function __construct(App $app, repository $repository)
{
parent::__construct($app);
$this->repository = $repository;
}
public function lst($id)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['date','order_sn','order_type','keywords','username','activity_type','group_order_sn','store_name']);
$where['reconciliation_type'] = $this->request->param('status', 1);
$where['mer_id'] = $id;
return app('json')->success($this->repository->adminMerGetList($where, $page, $limit));
}
public function markForm($id)
{
if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
return app('json')->fail('数据不存在');
return app('json')->success(formToData($this->repository->adminMarkForm($id)));
}
public function mark($id)
{
if (!$this->repository->getWhereCount([$this->repository->getPk() => $id]))
return app('json')->fail('数据不存在');
$data = $this->request->params(['admin_mark']);
$this->repository->update($id, $data);
return app('json')->success('备注成功');
}
public function title()
{
$where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type']);
return app('json')->success($this->repository->getStat($where, $where['status']));
}
/**
* TODO
* @return mixed
* @author Qinii
* @day 2020-06-25
*/
public function getAllList()
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','is_trader','activity_type','group_order_sn','store_name']);
$data = $this->repository->adminGetList($where, $page, $limit);
return app('json')->success($data);
}
public function takeTitle()
{
$where = $this->request->params(['date','order_sn','keywords','username','is_trader']);
$where['take_order'] = 1;
$where['status'] = '';
$where['verify_date'] = $where['date'];
unset($where['date']);
return app('json')->success($this->repository->getStat($where, ''));
}
/**
* TODO
* @return mixed
* @author Qinii
* @day 2020-08-17
*/
public function chart()
{
return app('json')->success($this->repository->OrderTitleNumber(null,null));
}
/**
* TODO 自提订单头部统计
* @return mixed
* @author Qinii
* @day 2020-08-17
*/
public function takeChart()
{
return app('json')->success($this->repository->OrderTitleNumber(null,1));
}
/**
* TODO 订单类型
* @return mixed
* @author Qinii
* @day 2020-08-15
*/
public function orderType()
{
return app('json')->success($this->repository->orderType([]));
}
public function detail($id)
{
$data = $this->repository->getOne($id, null);
if (!$data)
return app('json')->fail('数据不存在');
return app('json')->success($data);
}
public function status($id)
{
[$page, $limit] = $this->getPage();
$where = $this->request->params(['date','user_type']);
$where['id'] = $id;
return app('json')->success($this->repository->getOrderStatus($where, $page, $limit));
}
public function reList($id)
{
[$page, $limit] = $this->getPage();
$where = ['reconciliation_id' => $id, 'type' => 0];
return app('json')->success($this->repository->reconList($where, $page, $limit));
}
/**
* TODO 导出文件
* @author Qinii
* @day 2020-07-30
*/
public function excel()
{
$where = $this->request->params(['type', 'date', 'mer_id','keywords','status','username','order_sn','take_order']);
if($where['take_order']){
$where['verify_date'] = $where['date'];
unset($where['date']);
}
[$page, $limit] = $this->getPage();
$data = app()->make(ExcelService::class)->order($where, $page, $limit);
return app('json')->success($data);
}
/**
* TODO
* @param $id
* @return \think\response\Json
* @author Qinii
* @day 2023/2/22
*/
public function childrenList($id)
{
$data = $this->repository->childrenList($id, 0);
return app('json')->success($data);
}
/**
* 财务更新订单
*/
public function payOrder($id,$images,StoreGroupOrderOtherRepository $groupOrderRepository){
$groupOrder = $groupOrderRepository->detail((int)$id, false);
if(!$images){
return app('json')->fail('请上传凭证');
}
$groupOrder->order_extend=json_encode(['corporate_voucher'=>$images],true);
$res=$this->repository->paySuccess($groupOrder);
if($res){
return app('json')->success('操作成功');
}else{
return app('json')->fail('操作失败');
}
}
}

View File

@ -103,6 +103,52 @@ Route::group(function () {
] ]
]); ]);
Route::group('order_other', function () {
Route::get('lst', 'OrderOther/getAllList')->option([
'_alias' => '列表',
]);
Route::post('pay_order', 'OrderOther/payOrder')->option([
'_alias' => '财务提交订单',
]);
Route::get('title', 'OrderOther/title')->option([
'_alias' => '金额统计',
]);
Route::get('express/:id', 'OrderOther/express')->option([
'_alias' => '快递查询',
]);
Route::get('chart', 'OrderOther/chart')->option([
'_alias' => '头部统计',
]);
Route::get('detail/:id', 'OrderOther/detail')->option([
'_alias' => '详情',
]);
Route::get('excel', 'OrderOther/Excel')->option([
'_alias' => '导出',
]);
Route::get('status/:id', 'OrderOther/status')->option([
'_alias' => '记录',
]);
Route::get('children/:id', 'OrderOther/childrenList')->option([
'_alias' => '关联订单',
]);
})->prefix('admin.order.')->option([
'_path' => '/order/list',
'_auth' => true,
'_append'=> [
[
'_name' =>'systemStoreExcelLst',
'_path' =>'/order/list',
'_alias' => '导出列表',
'_auth' => true,
],
[
'_name' =>'systemStoreExcelDownload',
'_path' =>'/order/list',
'_alias' => '导出列表',
'_auth' => true,
],
]
]);
})->middleware(AllowOriginMiddleware::class) })->middleware(AllowOriginMiddleware::class)
->middleware(AdminTokenMiddleware::class, true) ->middleware(AdminTokenMiddleware::class, true)