You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Retail.php

176 lines
6.4 KiB

5 months ago
<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\api\controller;
use think\response\Json;
use app\api\model\Retail as RetailModel;
5 months ago
use app\api\model\RetailOrder as RetailOrderModel;
5 months ago
use app\api\model\Agreement as AgreementModel;
4 months ago
use app\common\model\RetailDescribe as RetailDescribeModel;
5 months ago
use app\api\service\order\Checkout as CheckoutService;
4 months ago
use app\api\service\Retail as RetailService;
4 months ago
use app\api\service\User as UserService;
4 months ago
use app\common\enum\RetailDescribeEnum;
5 months ago
class Retail extends Controller
{
/**
* 获取零售批发会员列表
* @param int $retailType
* @return Json
*/
public function list(int $retailType): Json
{
4 months ago
$list = RetailModel::withoutGlobalScope()->where('retail_type',$retailType)->where('retail_status',10)
->order(['sort' => 'asc','create_time' => 'asc'])->select();;
5 months ago
return $this->renderSuccess(compact('list'));
}
/**
* 获取软件付费协议
* @return Json
*/
public function getSoftAgreement(): Json
{
$params = $this->request->param();
if (empty($params['type'])) {
return $this->renderSuccess("参数错误");
}
$detail = AgreementModel::detail(['type' => $params['type']]);
if (!empty($detail->content)) {
$detail->content = str_ireplace('nowrap', 'inherit', $detail->content);
}
return $this->renderSuccess(compact('detail'));
}
/**
5 months ago
* 获取零售批发会员列表
* @param int $retailType
5 months ago
* @return Json
*/
5 months ago
public function retailPayList(): Json
{
$client = $this->request->post();
if (!$client['client']) {
return $this->renderError('客户端不能为空');
5 months ago
}
4 months ago
$model =new \app\api\service\Retail();
5 months ago
$list = $model->userCenter($client);
4 months ago
$list['retail'] = '<p>
1-客户直接在商城查看价格,快速比价、下单
4 months ago
</p>
4 months ago
<p>
2-所有会员、分销数字化管理
4 months ago
</p>
4 months ago
<p>
3-所有订单,调货记录,物流状态实时查询
4 months ago
</p>
4 months ago
<p>
4-供应链资源快速对接
4 months ago
</p>
4 months ago
<p>
5-商品数据快速上架,商城之间数据实时传输
4 months ago
</p>
4 months ago
<p>
6-商品市场价实时自动更新
4 months ago
</p>
4 months ago
<p>
7-货款到账时间支持当天或隔天,支付费率低&nbsp; &nbsp;&nbsp;
4 months ago
</p>
4 months ago
<p>
4 months ago
&nbsp; &nbsp;至千分之2.x
</p>
4 months ago
<p>
8-支持到店自提、同城闪送
4 months ago
</p>
4 months ago
<p>
9-促进清洗、安装、维修、回收、租赁服务与产品销售一体化
4 months ago
</p>
4 months ago
<p>
10-促进本地商家联盟数字化平台化发展
4 months ago
</p>';
4 months ago
$list['wholesale'] = '<div style="text-align: left;">
<p>1-采购代发商家实名注册认证,在线直接下单</p>
<p>2-认证商家、服务商数字化管理</p>
<p>3-所有订单,发货记录,物流状态实时查询</p>
<p>4-所有调货记录在线实时查看</p>
<p>5-审单实时做电话、地址校验比对,避免平台单</p>
<p>6-供应链资源快速对接</p>
<p>7-商品数据快速上架,商城之间商品数据实时传输</p>
<p>8-商品市场价实时自动更新</p>
<p>9-货款到账时间支持当天或隔天,支付费率低 至千分之 2.x</p>
<p>10-供应商、服务商入驻,销售和推广效益提升</p>
</div>';
5 months ago
return $this->renderSuccess(compact('list'));
5 months ago
}
5 months ago
public function submit(): Json
{
$method = $this->request->post('method');
if (!$method) {
return $this->renderError('支付方式不能为空');
}
$client = $this->request->post('client');
if (!$client) {
return $this->renderError('客户端不能为空');
}
$retailPriceId = intval($this->request->post('retail_price_id'));
if (!$retailPriceId) {
return $this->renderError('缺少必要参数');
}
$service = new \app\api\service\Retail();
$data = $service->setMethod($method)
->setClient($client)
->orderPay($retailPriceId);
return $this->renderSuccess($data, $service->getMessage() ?: '下单成功');
}
5 months ago
4 months ago
/**
* 商厂权限
*/
public function describe()
4 months ago
{
$type = $this->request->get('type')??10;
4 months ago
$list = RetailDescribeModel::withoutGlobalScope()->where(['description_status' =>10,'type' => $type])->select();
4 months ago
$group = [];
foreach($list as $item){
$group[$item['plate_id']]['list'][] = $item;
$group[$item['plate_id']]['name'] = RetailDescribeEnum::$version[$item['plate_id']] ?? "" ;
}
return $this->renderSuccess(compact('group'));
4 months ago
}
4 months ago
/**
* 交易查询
* @param string $outTradeNo 商户订单号
* @param string $method 支付方式
* @param string $client 指定的客户端
* @return Json
* @throws \cores\exception\BaseException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function tradeQuery(string $outTradeNo, string $method, string $client): Json
{
$RechargeService = new RetailService;
$result = $RechargeService->setMethod($method)->setClient($client)->tradeQuery($outTradeNo);
$message = $result ? '恭喜您,余额充值成功' : ($RechargeService->getError() ?: '很抱歉,订单未支付,请重新发起');
return $this->renderSuccess(['isPay' => $result], $message);
}
4 months ago
5 months ago
}