new files
This commit is contained in:
121
pro_v3.5.1/app/controller/out/Coupon.php
Normal file
121
pro_v3.5.1/app/controller/out/Coupon.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace app\controller\out;
|
||||
|
||||
use app\Request;
|
||||
use app\services\activity\coupon\StoreCouponIssueServices;
|
||||
use app\services\product\product\StoreProductCouponServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
class Coupon
|
||||
{
|
||||
/**
|
||||
* 优惠券services
|
||||
* @var StoreCouponIssueServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreCouponIssueServices $issueServices;
|
||||
|
||||
/**
|
||||
* 优惠券列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function couponList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['status', 1],
|
||||
['coupon_title', ''],
|
||||
['receive_type', ''],
|
||||
['coupon_type', ''],
|
||||
['type', '', '', 'receive'],
|
||||
]);
|
||||
$list = $this->issueServices->getCouponIssueList($where);
|
||||
$list['pages_url'] = '/pages/activity/coupon/index';
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增优惠券
|
||||
* @param Request $request
|
||||
* @return void
|
||||
*/
|
||||
public function couponSave(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['coupon_title', ''],
|
||||
['coupon_price', 0.00],
|
||||
['use_min_price', 0.00],
|
||||
['coupon_time', 0],
|
||||
['start_use_time', 0],
|
||||
['end_use_time', 0],
|
||||
['start_time', 0],
|
||||
['end_time', 0],
|
||||
['receive_type', 0],
|
||||
['is_permanent', 0],
|
||||
['total_count', 0],
|
||||
['product_id', ''],
|
||||
['category_id', []],
|
||||
['type', 0],
|
||||
['sort', 0],
|
||||
['status', 0],
|
||||
['coupon_type', 1],
|
||||
]);
|
||||
if ($data['category_id']) {
|
||||
$data['category_id'] = end($data['category_id']);
|
||||
}
|
||||
if ($data['start_time'] && $data['start_use_time']) {
|
||||
if ($data['start_use_time'] < $data['start_time']) {
|
||||
return app('json')->fail('使用开始时间不能小于领取开始时间');
|
||||
}
|
||||
}
|
||||
if ($data['end_time'] && $data['end_use_time']) {
|
||||
if ($data['end_use_time'] < $data['end_time']) {
|
||||
return app('json')->fail('使用结束时间不能小于领取结束时间');
|
||||
}
|
||||
}
|
||||
//赠送券 、新人券不限量
|
||||
if (in_array($data['receive_type'], [2, 3])) {
|
||||
$data['is_permanent'] = 1;
|
||||
$data['total_count'] = 0;
|
||||
}
|
||||
if (!$data['coupon_price']) {
|
||||
return app('json')->fail($data['coupon_type'] == 1 ? '请输入优惠券金额' : '请输入优惠券折扣');
|
||||
}
|
||||
if ($data['coupon_type'] == 2 && ($data['coupon_price'] < 0 || $data['coupon_price'] > 100)) {
|
||||
return app('json')->fail('优惠券折扣为0~100数字');
|
||||
}
|
||||
$res = $this->issueServices->saveCoupon($data);
|
||||
if ($res) return app('json')->success('添加成功!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改优惠券状态
|
||||
* @param $id
|
||||
* @param $status
|
||||
* @return mixed
|
||||
*/
|
||||
public function setStatus($id, $status)
|
||||
{
|
||||
$this->issueServices->update($id, ['status' => $status]);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除优惠券
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function couponDel($id)
|
||||
{
|
||||
$this->issueServices->update($id, ['is_del' => 1]);
|
||||
/** @var StoreProductCouponServices $storeProductService */
|
||||
$storeProductService = app()->make(StoreProductCouponServices::class);
|
||||
//删除商品关联这个优惠券
|
||||
$storeProductService->delete(['issue_coupon_id' => $id]);
|
||||
return app('json')->success('删除成功!');
|
||||
}
|
||||
}
|
||||
504
pro_v3.5.1/app/controller/out/Order.php
Normal file
504
pro_v3.5.1/app/controller/out/Order.php
Normal file
@@ -0,0 +1,504 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\out;
|
||||
|
||||
use app\Request;
|
||||
use app\services\order\StoreOrderCartInfoServices;
|
||||
use app\services\order\StoreOrderDeliveryServices;
|
||||
use app\services\order\StoreOrderInvoiceServices;
|
||||
use app\services\order\StoreOrderRefundServices;
|
||||
use app\services\order\StoreOrderTakeServices;
|
||||
use app\services\other\ExpressServices;
|
||||
use app\services\out\OutStoreOrderRefundServices;
|
||||
use app\services\out\OutStoreOrderServices;
|
||||
use app\services\order\StoreOrderServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class Order
|
||||
* @package app\kefuapi\controller
|
||||
*/
|
||||
class Order
|
||||
{
|
||||
/**
|
||||
* 订单services
|
||||
* @var StoreOrderServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderServices $orderServices;
|
||||
|
||||
/**
|
||||
* 退款订单services
|
||||
* @var StoreOrderRefundServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreOrderRefundServices $refundServices;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* @param Request $request
|
||||
* @param OutStoreOrderServices $outStoreOrderServices
|
||||
* @return \think\Response
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderList(Request $request, OutStoreOrderServices $outStoreOrderServices)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['status', ''],
|
||||
['real_name', ''],
|
||||
['is_del', ''],
|
||||
['data', '', '', 'time'],
|
||||
['type', ''],
|
||||
['pay_type', ''],
|
||||
['order', ''],
|
||||
['field_key', ''],
|
||||
['supplier_id', ''],
|
||||
['paid', '']
|
||||
]);
|
||||
$where['type'] = trim($where['type']);
|
||||
$where['is_system_del'] = 0;
|
||||
|
||||
$where['store_id'] = 0;
|
||||
$where['type'] = trim($where['type'], ' ');
|
||||
return app('json')->success($outStoreOrderServices->getOrderList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单详情
|
||||
* @param OutStoreOrderServices $outStoreOrderServices
|
||||
* @param $order_id
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function orderInfo(OutStoreOrderServices $outStoreOrderServices, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('参数错误');
|
||||
return app('json')->success($outStoreOrderServices->getInfo($order_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单备注
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderRemark(Request $request, $order_id)
|
||||
{
|
||||
$data = $request->postMore([['remark', '']]);
|
||||
if (!$data['remark'])
|
||||
return app('json')->fail('请输入要备注的内容');
|
||||
if (!$order_id)
|
||||
return app('json')->fail('缺少参数');
|
||||
|
||||
if (!$order = $this->orderServices->get(['order_id' => $order_id])) {
|
||||
return app('json')->fail('修改的订单不存在!');
|
||||
}
|
||||
$order->remark = $data['remark'];
|
||||
if ($order->save()) {
|
||||
return app('json')->success('备注成功');
|
||||
} else
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单收货
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderReceive($order_id)
|
||||
{
|
||||
/** @var StoreOrderTakeServices $takeOrderServices */
|
||||
$takeOrderServices = app()->make(StoreOrderTakeServices::class);
|
||||
$uid = $this->orderServices->value(['order_id' => $order_id], 'uid');
|
||||
$takeOrderServices->takeOrder($order_id, $uid);
|
||||
return app('json')->success('收货成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询物流公司
|
||||
* @param ExpressServices $services
|
||||
* @return mixed
|
||||
*/
|
||||
public function orderExpressList(ExpressServices $services)
|
||||
{
|
||||
$data['is_show'] = 1;
|
||||
|
||||
return app('json')->success($services->express($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单发货
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderDelivery(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('参数错误');
|
||||
$data = $request->postMore([
|
||||
['delivery_name', ''],//快递公司名称
|
||||
['delivery_id', ''],//快递单号
|
||||
['delivery_code', ''],//快递公司编码
|
||||
]);
|
||||
$data['express_record_type'] = 1;
|
||||
$data['type'] = 1;
|
||||
/** @var StoreOrderDeliveryServices $deliveryServices */
|
||||
$deliveryServices = app()->make(StoreOrderDeliveryServices::class);
|
||||
$id = $this->orderServices->value(['order_id' => $order_id], 'id');
|
||||
$deliveryServices->delivery($id, $data);
|
||||
return app('json')->success('发货成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改配送信息
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function updateDistribution(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('参数错误');
|
||||
$data = $request->postMore([
|
||||
['delivery_name', ''],
|
||||
['delivery_code', ''],
|
||||
['delivery_id', '']
|
||||
]);
|
||||
/** @var StoreOrderDeliveryServices $deliveryServices */
|
||||
$deliveryServices = app()->make(StoreOrderDeliveryServices::class);
|
||||
$id = $this->orderServices->value(['order_id' => $order_id], 'id');
|
||||
$deliveryServices->updateDistribution($id, $data);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单可拆分商品列表
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function SplitCartInfo($order_id)
|
||||
{
|
||||
if (!$order_id) {
|
||||
return app('json')->fail('缺少发货ID');
|
||||
}
|
||||
$id = $this->orderServices->value(['order_id' => $order_id], 'id');
|
||||
/** @var StoreOrderCartInfoServices $orderCartServices */
|
||||
$orderCartServices = app()->make(StoreOrderCartInfoServices::class);
|
||||
return app('json')->success($orderCartServices->getSplitCartList((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 拆单发货
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function orderSplitDelivery(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('参数错误');
|
||||
$data = $request->postMore([
|
||||
['delivery_name', ''],//快递公司名称
|
||||
['delivery_id', ''],//快递单号
|
||||
['delivery_code', ''],//快递公司编码
|
||||
['fictitious_content', ''],//虚拟发货内容
|
||||
['cart_ids', []]
|
||||
]);
|
||||
|
||||
if (!$data['cart_ids']) {
|
||||
return app('json')->fail('参数错误');
|
||||
}
|
||||
foreach ($data['cart_ids'] as &$cart) {
|
||||
if (!isset($cart['cart_id']) || !$cart['cart_id'] || !isset($cart['cart_num']) || !$cart['cart_num']) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
$cart['cart_id'] = (int)$cart['cart_id'];
|
||||
$cart['cart_num'] = (int)$cart['cart_num'];
|
||||
}
|
||||
$data['express_record_type'] = 1;
|
||||
$data['type'] = 1;
|
||||
/** @var StoreOrderDeliveryServices $deliveryServices */
|
||||
$deliveryServices = app()->make(StoreOrderDeliveryServices::class);
|
||||
$id = $this->orderServices->value(['order_id' => $order_id], 'id');
|
||||
$deliveryServices->splitDelivery($id, $data);
|
||||
return app('json')->success('发货成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单开票信息
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function setInvoice(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail(100100);
|
||||
$data = $request->postMore([
|
||||
[['header_type', 'd'], 1],
|
||||
[['type', 'd'], 1],
|
||||
['drawer_phone', ''],
|
||||
['email', ''],
|
||||
['name', ''],
|
||||
['duty_number', ''],
|
||||
['tell', ''],
|
||||
['address', ''],
|
||||
['bank', ''],
|
||||
['card_number', ''],
|
||||
]);
|
||||
|
||||
if (!$data['drawer_phone']) return app('json')->fail('请填写开票手机号');
|
||||
if (!check_phone($data['drawer_phone'])) return app('json')->fail('手机号格式不正确');
|
||||
if (!$data['name']) return app('json')->fail('请填写发票抬头(开具发票企业名称)');
|
||||
if (!in_array($data['header_type'], [1, 2])) {
|
||||
$data['header_type'] = empty($data['duty_number']) ? 1 : 2;
|
||||
}
|
||||
if ($data['header_type'] == 1 && !preg_match('/^[\x80-\xff]{2,60}$/', $data['name'])) {
|
||||
return app('json')->fail('请填写发票抬头(开具发票企业名称)');
|
||||
}
|
||||
if ($data['header_type'] == 2 && !preg_match('/^[0-9a-zA-Z&\(\)\(\)\x80-\xff]{2,150}$/', $data['name'])) {
|
||||
return app('json')->fail('请填写发票抬头(开具发票企业名称)');
|
||||
}
|
||||
if ($data['header_type'] == 2 && !$data['duty_number']) {
|
||||
return app('json')->fail('请填写发票税号');
|
||||
}
|
||||
if ($data['header_type'] == 2 && !preg_match('/^[A-Z0-9]{15}$|^[A-Z0-9]{17}$|^[A-Z0-9]{18}$|^[A-Z0-9]{20}$/', $data['duty_number'])) {
|
||||
return app('json')->fail('请填写正确的发票税号');
|
||||
}
|
||||
if ($data['card_number'] && !preg_match('/^[1-9]\d{11,19}$/', $data['card_number'])) {
|
||||
return app('json')->fail('请填写正确的银行卡号');
|
||||
}
|
||||
$orderInfo = $this->orderServices->get(['order_id' => $order_id], ['id'], ['invoice']);
|
||||
if (!$orderInfo) return app('json')->fail('订单不存在');
|
||||
if (!$orderInfo->invoice || !$invoiceId = $orderInfo->invoice->id) {
|
||||
return app('json')->fail('订单未提交开票申请');
|
||||
}
|
||||
/** @var StoreOrderInvoiceServices $invoiceServices */
|
||||
$invoiceServices = app()->make(StoreOrderInvoiceServices::class);
|
||||
if ($invoiceServices->setInvoice($invoiceId, $data)) {
|
||||
return app('json')->success('修改成功');
|
||||
} else {
|
||||
return app('json')->fail('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置订单发票状态
|
||||
* @param Request $request
|
||||
* @param string $order_id 订单ID
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function setInvoiceStatus(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail(100100);
|
||||
$data = $request->postMore([
|
||||
['is_invoice', 0],
|
||||
['invoice_number', 0],
|
||||
['remark', '']
|
||||
]);
|
||||
|
||||
if ($data['is_invoice'] == 1 && !$data['invoice_number']) {
|
||||
return app('json')->fail('请填写开票号');
|
||||
}
|
||||
if ($data['invoice_number'] && !preg_match('/^\d{8,20}$/', $data['invoice_number'])) {
|
||||
return app('json')->fail('请填写正确的开票号');
|
||||
}
|
||||
$orderInfo = $this->orderServices->get(['order_id' => $order_id], ['id'], ['invoice']);
|
||||
if (!$orderInfo) return app('json')->fail('订单不存在');
|
||||
if (!$orderInfo->invoice || !$invoiceId = $orderInfo->invoice->id) {
|
||||
return app('json')->fail('订单未提交开票申请');
|
||||
}
|
||||
/** @var StoreOrderInvoiceServices $invoiceServices */
|
||||
$invoiceServices = app()->make(StoreOrderInvoiceServices::class);
|
||||
$invoiceServices->setInvoice($invoiceId, $data);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后单列表
|
||||
* @param Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function refundList(Request $request, OutStoreOrderRefundServices $outStoreOrderRefundServices)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['order_id', ''],
|
||||
['time', ''],
|
||||
['refund_type', '']
|
||||
]);
|
||||
$where['is_cancel'] = 0;
|
||||
return app('json')->success($outStoreOrderRefundServices->refundList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款单详情
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function refundInfo(OutStoreOrderRefundServices $outStoreOrderRefundServices, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('缺少参数');
|
||||
$data = $outStoreOrderRefundServices->getInfo($order_id);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款单备注
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function refundRemark(Request $request, $order_id)
|
||||
{
|
||||
$data = $request->postMore([['remark', '']]);
|
||||
if (!$data['remark']) return app('json')->fail('请输入要备注的内容');
|
||||
if (!$order_id) return app('json')->fail('缺少参数');
|
||||
if (!$order = $this->refundServices->get(['order_id' => $order_id])) {
|
||||
return app('json')->fail('修改的订单不存在!');
|
||||
}
|
||||
$order->remark = $data['remark'];
|
||||
if ($order->save()) {
|
||||
return app('json')->success('备注成功');
|
||||
} else
|
||||
return app('json')->fail('备注失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款单退款
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function refundPrice(Request $request, $order_id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['refund_price', 0],
|
||||
['type', 1],
|
||||
['refuse_reason', '']
|
||||
]);
|
||||
if (!$order_id) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
$orderRefund = $this->refundServices->get(['order_id' => $order_id]);
|
||||
if (!$orderRefund) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
if ($orderRefund['is_cancel'] == 1) {
|
||||
return app('json')->fail('用户已取消申请');
|
||||
}
|
||||
$order = $this->orderServices->get((int)$orderRefund['store_order_id']);
|
||||
if (!$order) {
|
||||
return app('json')->fail('数据不存在');
|
||||
}
|
||||
if (!in_array($orderRefund['refund_type'], [0, 1, 2, 5]) && !($orderRefund['refund_type'] == 4 && $orderRefund['apply_type'] == 3)) {
|
||||
return app('json')->fail('售后订单状态不支持该操作');
|
||||
}
|
||||
if ($data['type'] == 1) {
|
||||
$data['refund_type'] = 6;
|
||||
} else if ($data['type'] == 2) {
|
||||
$data['refund_type'] = 3;
|
||||
}
|
||||
$data['refunded_time'] = time();
|
||||
$type = $data['type'];
|
||||
//拒绝退款
|
||||
if ($type == 2) {
|
||||
$this->refundServices->refuseRefund((int)$orderRefund['id'], $data, $orderRefund);
|
||||
return app('json')->successful('修改退款状态成功!');
|
||||
} else {
|
||||
//0元退款
|
||||
if ($orderRefund['refund_price'] == 0) {
|
||||
$refund_price = 0;
|
||||
} else {
|
||||
if (!$data['refund_price']) {
|
||||
return app('json')->fail('请输入退款金额');
|
||||
}
|
||||
if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
|
||||
return app('json')->fail('已退完支付金额!不能再退款了');
|
||||
}
|
||||
$refund_price = $data['refund_price'];
|
||||
$data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
|
||||
$bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
|
||||
if ($bj < 0) {
|
||||
return app('json')->fail('退款金额大于支付金额,请修改退款金额');
|
||||
}
|
||||
}
|
||||
|
||||
unset($data['type']);
|
||||
$refund_data['pay_price'] = $order['pay_price'];
|
||||
$refund_data['refund_price'] = $refund_price;
|
||||
if ($order['refund_price'] > 0) {
|
||||
mt_srand();
|
||||
$refund_data['refund_id'] = $order['order_id'] . rand(100, 999);
|
||||
}
|
||||
//修改订单退款状态
|
||||
unset($data['refund_price']);
|
||||
if ($this->refundServices->agreeRefund($orderRefund['id'], $refund_data)) {
|
||||
$this->refundServices->update($orderRefund['id'], $data);
|
||||
return app('json')->success('退款成功');
|
||||
}
|
||||
// else {
|
||||
// $this->refundServices->storeProductOrderRefundYFasle((int)$orderRefund['id'], $refund_price);
|
||||
// return app('json')->fail('退款失败');
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意退货
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function agreeRefund($order_id)
|
||||
{
|
||||
$this->refundServices->agreeRefundProdcut((int)$order_id);
|
||||
return app('json')->success('操作成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝退款
|
||||
* @param Request $request
|
||||
* @param $order_id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function refuseRefund(Request $request, $order_id)
|
||||
{
|
||||
if (!$order_id) return app('json')->fail('订单不存在');
|
||||
if (!$orderRefundInfo = $this->refundServices->get(['order_id' => $order_id])) return app('json')->fail('订单不存在');
|
||||
[$refund_reason] = $request->postMore([['refund_reason', '']], true);
|
||||
if (!$refund_reason) {
|
||||
return app('json')->fail('请输入不退款原因');
|
||||
}
|
||||
$refundData = [
|
||||
'refuse_reason' => $refund_reason,
|
||||
'refund_type' => 3,
|
||||
'refunded_time' => time()
|
||||
];
|
||||
//拒绝退款处理
|
||||
$this->refundServices->refuseRefund((int)$orderRefundInfo['id'], $refundData, $orderRefundInfo);
|
||||
|
||||
return app('json')->success('Modified success');
|
||||
}
|
||||
|
||||
}
|
||||
68
pro_v3.5.1/app/controller/out/OutAccount.php
Normal file
68
pro_v3.5.1/app/controller/out/OutAccount.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\controller\out;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\out\OutAccountServices;
|
||||
use crmeb\basic\BaseController;
|
||||
use app\validate\out\LoginValidate;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* Class Login
|
||||
* @package app\kefu\controller
|
||||
*/
|
||||
class OutAccount extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @var OutAccountServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected OutAccountServices $services;
|
||||
|
||||
/**
|
||||
* 客服登录
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function getToken(Request $request)
|
||||
{
|
||||
[$appid, $appsecret] = $request->postMore([
|
||||
['appid', ''],
|
||||
['appsecret', ''],
|
||||
], true);
|
||||
$this->validate(['appid' => $appid, 'appsecret' => $appsecret], LoginValidate::class);
|
||||
|
||||
$token = $this->services->authLogin($appid, $appsecret);
|
||||
|
||||
return $this->success('获取成功', $token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新token
|
||||
* @return void
|
||||
*/
|
||||
public function refreshToken(Request $request)
|
||||
{
|
||||
[$token] = $request->postMore([
|
||||
['access_token', ''],
|
||||
], true);
|
||||
$token = $this->services->refresh($token);
|
||||
return app('json')->success('操作成功', $token);
|
||||
}
|
||||
|
||||
}
|
||||
299
pro_v3.5.1/app/controller/out/Product.php
Normal file
299
pro_v3.5.1/app/controller/out/Product.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\out;
|
||||
|
||||
use app\Request;
|
||||
use app\services\product\category\StoreProductCategoryServices;
|
||||
use app\services\product\product\StoreProductServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 商品类
|
||||
* Class StoreProductController
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
/**
|
||||
* 商品services
|
||||
* @var StoreProductServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductServices $productServices;
|
||||
|
||||
/**
|
||||
* 分类services
|
||||
* @var StoreProductCategoryServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected StoreProductCategoryServices $categoryServices;
|
||||
|
||||
/**
|
||||
* 分类列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function categoryList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['is_show', ''],
|
||||
['pid', ''],
|
||||
['cate_name', ''],
|
||||
]);
|
||||
$where['pid'] = -2;
|
||||
$data = $this->categoryServices->getCategoryList($where);
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function categoryInfo($id)
|
||||
{
|
||||
$info = $this->categoryServices->getInfo((int)$id);
|
||||
return app('json')->success($info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建分类
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryCreate(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['pid', 0],
|
||||
['cate_name', ''],
|
||||
['pic', ''],
|
||||
['big_pic', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
$cateId = $this->categoryServices->createData($data)->id;
|
||||
return app('json')->success('添加成功', ['id' => $cateId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类
|
||||
* @param Request $request
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryUpdate(Request $request, $id)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['pid', 0],
|
||||
['cate_name', ''],
|
||||
['pic', ''],
|
||||
['big_pic', ''],
|
||||
['sort', 0],
|
||||
['is_show', 0]
|
||||
]);
|
||||
$this->categoryServices->editData($id, $data);
|
||||
return app('json')->success('修改成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除分类
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function categoryDelete($id)
|
||||
{
|
||||
$this->categoryServices->del((int)$id);
|
||||
return app('json')->success('删除成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改分类状态
|
||||
* @param $id
|
||||
* @param $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function categorySetShow($id, $is_show)
|
||||
{
|
||||
$this->categoryServices->setShow($id, $is_show);
|
||||
return app('json')->success('设置成功');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 商品列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function productList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['cate_id', ''],
|
||||
['store_name', ''],
|
||||
['type', 1, '', 'status'],
|
||||
['is_live', 0],
|
||||
['is_new', ''],
|
||||
['is_vip_product', ''],
|
||||
['is_presale_product', ''],
|
||||
['store_label_id', '']
|
||||
]);
|
||||
$where['is_show'] = 1;
|
||||
$where['is_del'] = 0;
|
||||
if ($where['cate_id'] !== '') {
|
||||
if ($this->categoryServices->value(['id' => $where['cate_id']], 'pid')) {
|
||||
$where['sid'] = $where['cate_id'];
|
||||
} else {
|
||||
$where['cid'] = $where['cate_id'];
|
||||
}
|
||||
}
|
||||
unset($where['cate_id']);
|
||||
if ($where['store_name']) {//搜索
|
||||
$where['pid'] = 0;
|
||||
}
|
||||
$list = $this->productServices->searchList($where);
|
||||
foreach ($list['list'] as &$item) {
|
||||
$item['pages_url'] = '/pages/goods_details/index?id=' . $item['id'];
|
||||
}
|
||||
$list['pages_url'] = '/pages/goods/goods_list/index';
|
||||
return app('json')->success($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增商品
|
||||
* @param Request $request
|
||||
* @param int $id
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function productSave(Request $request, int $id = 0)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['product_type', 0],//商品类型
|
||||
['supplier_id', 0],//供应商ID
|
||||
['cate_id', []],
|
||||
['store_name', ''],
|
||||
['store_info', ''],
|
||||
['keyword', ''],
|
||||
['unit_name', '件'],
|
||||
['recommend_image', ''],
|
||||
['slider_image', []],
|
||||
['is_sub', []],//佣金是单独还是默认
|
||||
['sort', 0],
|
||||
['sales', 0],
|
||||
['ficti', 100],
|
||||
['give_integral', 0],
|
||||
['is_show', 0],
|
||||
['is_hot', 0],
|
||||
['is_benefit', 0],
|
||||
['is_best', 0],
|
||||
['is_new', 0],
|
||||
['mer_use', 0],
|
||||
['is_postage', 0],
|
||||
['is_good', 0],
|
||||
['description', ''],
|
||||
['spec_type', 0],
|
||||
['video_open', 0],
|
||||
['video_link', ''],
|
||||
['items', []],
|
||||
['attrs', []],
|
||||
['recommend', []],//商品推荐
|
||||
['activity', []],
|
||||
['coupon_ids', []],
|
||||
['label_id', []],
|
||||
['command_word', ''],
|
||||
['tao_words', ''],
|
||||
['type', 0, '', 'is_copy'],
|
||||
['delivery_type', []],//物流设置
|
||||
['freight', 1],//运费设置
|
||||
['postage', 0],//邮费
|
||||
['temp_id', 0],//运费模版
|
||||
['recommend_list', []],
|
||||
['brand_id', []],
|
||||
['soure_link', ''],
|
||||
['bar_code', ''],
|
||||
['code', ''],
|
||||
['is_support_refund', 1],//是否支持退款
|
||||
['is_presale_product', 0],//预售商品开关
|
||||
['presale_time', []],//预售时间
|
||||
['presale_day', 0],//预售发货日
|
||||
['is_vip_product', 0],//是否付费会员商品
|
||||
['product_clear', ['is_general_product']],//商品用户可见,普通,采购商,付费会员可见
|
||||
['auto_on_time', 0],//自动上架时间
|
||||
['auto_off_time', 0],//自动下架时间
|
||||
['custom_form', []],//自定义表单
|
||||
['store_label_id', []],//商品标签
|
||||
['ensure_id', []],//商品保障服务区
|
||||
['specs', []],//商品参数
|
||||
['specs_id', 0],//商品参数ID
|
||||
['is_limit', 0],//是否限购
|
||||
['limit_type', 0],//限购类型
|
||||
['limit_num', 0],//限购数量
|
||||
['share_content', ''],//分享文案
|
||||
['min_qty', 1],//起购数量
|
||||
['presale_status', 0],//预售结束后状态
|
||||
['is_send_gift', 0],//商品是否支持送礼
|
||||
['send_gift_price', 0],//商品送礼附加费用
|
||||
]);
|
||||
$this->productServices->saveData($id, $data);
|
||||
return app('json')->success(!$id ? '保存商品信息成功' : '修改商品信息成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @param $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function productInfo($id)
|
||||
{
|
||||
return app('json')->success($this->productServices->getInfo((int)$id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置商品状态
|
||||
* @param $id
|
||||
* @param $is_show
|
||||
* @return mixed
|
||||
*/
|
||||
public function productSetShow($id, $is_show)
|
||||
{
|
||||
$this->productServices->setShow([$id], $is_show);
|
||||
return app('json')->success('设置成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步库存
|
||||
* @return void
|
||||
*/
|
||||
public function uploadStock(Request $request)
|
||||
{
|
||||
[$items] = $request->postMore([['items', []]], true);
|
||||
|
||||
foreach ($items as $item) {
|
||||
if (!isset($item['bar_code']) || !isset($item['qty'])) {
|
||||
return app('json')->fail('请检查属性编码或库存数量');
|
||||
}
|
||||
}
|
||||
|
||||
if (count($items) > 100) {
|
||||
return app('json')->fail('同步条数不能超过100');
|
||||
}
|
||||
|
||||
$this->productServices->syncStock($items);
|
||||
return app('json')->success('操作成功');
|
||||
}
|
||||
}
|
||||
279
pro_v3.5.1/app/controller/out/User.php
Normal file
279
pro_v3.5.1/app/controller/out/User.php
Normal file
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: CRMEB Team <admin@crmeb.com>
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\controller\out;
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\UserServices;
|
||||
use app\services\user\level\UserLevelServices;
|
||||
use think\annotation\Inject;
|
||||
|
||||
/**
|
||||
* 用户类
|
||||
* Class StoreProductController
|
||||
* @package app\api\controller\store
|
||||
*/
|
||||
class User
|
||||
{
|
||||
/**
|
||||
* 用户services
|
||||
* @var UserServices
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserServices $services;
|
||||
|
||||
/**
|
||||
* 用户等级列表
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
*/
|
||||
public function levelList(Request $request)
|
||||
{
|
||||
$where = $request->getMore([
|
||||
['page', 0],
|
||||
['limit', 10],
|
||||
['title', ''],
|
||||
['is_show', ''],
|
||||
]);
|
||||
/** @var UserLevelServices $levelServices */
|
||||
$levelServices = app()->make(UserLevelServices::class);
|
||||
return app('json')->success($levelServices->getSytemList($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户列表
|
||||
* @return mixed
|
||||
*/
|
||||
public function userList(Request $request)
|
||||
{
|
||||
$where = $request->postMore([
|
||||
['uid', 0],
|
||||
]);
|
||||
if ($where['uid']) {
|
||||
$where['uid'] = is_string($where['uid']) ? stringToIntArray($where['uid']) : $where['uid'];
|
||||
} else {
|
||||
$where['uid'] = [];
|
||||
}
|
||||
return app('json')->success($this->services->index($where));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加用户
|
||||
* @param Request $request
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function userSave(Request $request)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['is_promoter', 0],
|
||||
['real_name', ''],
|
||||
['card_id', ''],
|
||||
['birthday', ''],
|
||||
['mark', ''],
|
||||
['status', 0],
|
||||
['level', 0],
|
||||
['phone', 0],
|
||||
['addres', ''],
|
||||
['label_id', []],
|
||||
['group_id', 0],
|
||||
['pwd', ''],
|
||||
['true_pwd', ''],
|
||||
['spread_open', 1],
|
||||
['sex', 0],
|
||||
['provincials', ''],
|
||||
['province', 0],
|
||||
['city', 0],
|
||||
['area', 0],
|
||||
['street', 0],
|
||||
['extend_info', []],
|
||||
['adminId', 0],
|
||||
]);
|
||||
if ($data['phone']) {
|
||||
if (!check_phone($data['phone'])) {
|
||||
return app('json')->fail('手机号码格式不正确');
|
||||
}
|
||||
if ($this->services->count(['phone' => $data['phone']])) {
|
||||
return app('json')->fail('手机号已经存在不能添加相同的手机号用户');
|
||||
}
|
||||
$data['nickname'] = substr_replace($data['phone'], '****', 3, 4);
|
||||
}
|
||||
if ($data['card_id']) {
|
||||
try {
|
||||
if (!check_card($data['card_id'])) return $this->fail('请输入正确的身份证');
|
||||
} catch (\Throwable $e) {
|
||||
// return $this->fail('请输入正确的身份证');
|
||||
}
|
||||
}
|
||||
if ($data['birthday']) {
|
||||
if (strtotime($data['birthday']) > time()) return app('json')->fail('生日请选择今天之前日期');
|
||||
}
|
||||
if ($data['pwd']) {
|
||||
if (strlen($data['pwd']) < 6) {
|
||||
return app('json')->fail('密码长度最小6位');
|
||||
}
|
||||
if ($data['pwd'] == '123456') {
|
||||
return app('json')->fail('您设置的密码太过简单');
|
||||
}
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
}
|
||||
unset($data['true_pwd']);
|
||||
$data['avatar'] = sys_config('h5_avatar');
|
||||
$data['user_type'] = 'h5';
|
||||
$labels = $data['label_id'];
|
||||
unset($data['label_id']);
|
||||
foreach ($labels as $k => $v) {
|
||||
if (!$v) {
|
||||
unset($labels[$k]);
|
||||
}
|
||||
}
|
||||
$data['add_time'] = time();
|
||||
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
|
||||
$this->services->transaction(function () use ($data, $labels) {
|
||||
$res = true;
|
||||
$userInfo = $this->services->save($data);
|
||||
if ($labels) {
|
||||
$res = $this->services->saveSetLabel([$userInfo->uid], $labels);
|
||||
}
|
||||
if ($data['level']) {
|
||||
$res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
|
||||
}
|
||||
if (!$res) {
|
||||
return app('json')->fail('保存添加用户失败');
|
||||
}
|
||||
event('user.register', [$this->services->get((int)$userInfo->uid), true, 0]);
|
||||
});
|
||||
event('user.create', $data);
|
||||
return app('json')->success('添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param Request $request
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function userUpdate(Request $request, $uid)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['money_status', 0],
|
||||
['is_promoter', 0],
|
||||
['real_name', ''],
|
||||
['card_id', ''],
|
||||
['birthday', ''],
|
||||
['mark', ''],
|
||||
['money', 0],
|
||||
['integration_status', 0],
|
||||
['integration', 0],
|
||||
['status', 0],
|
||||
['level', 0],
|
||||
['phone', 0],
|
||||
['addres', ''],
|
||||
['label_id', []],
|
||||
['group_id', 0],
|
||||
['pwd', ''],
|
||||
['true_pwd'],
|
||||
['spread_open', 1],
|
||||
['sex', 0],
|
||||
['provincials', ''],
|
||||
['province', 0],
|
||||
['city', 0],
|
||||
['area', 0],
|
||||
['street', 0],
|
||||
['spread_uid', -1],
|
||||
['extend_info', []],
|
||||
['adminId', 0],
|
||||
]);
|
||||
if ($data['phone']) {
|
||||
if (!check_phone($data['phone'])) return app('json')->fail('手机号码格式不正确');
|
||||
}
|
||||
if ($data['card_id']) {
|
||||
try {
|
||||
if (!check_card($data['card_id'])) return app('json')->fail('请输入正确的身份证');
|
||||
} catch (\Throwable $e) {
|
||||
// return app('json')->fail('请输入正确的身份证');
|
||||
}
|
||||
}
|
||||
if ($data['birthday']) {
|
||||
if (strtotime($data['birthday']) > time()) return app('json')->fail('生日请选择今天之前日期');
|
||||
}
|
||||
if ($data['pwd']) {
|
||||
$data['pwd'] = md5($data['pwd']);
|
||||
} else {
|
||||
unset($data['pwd']);
|
||||
}
|
||||
$userInfo = $this->services->get($uid);
|
||||
if (!$userInfo) {
|
||||
return app('json')->fail('用户不存在');
|
||||
}
|
||||
if (!in_array($data['spread_uid'], [0, -1])) {
|
||||
$spreadUid = $data['spread_uid'];
|
||||
if ($uid == $spreadUid) {
|
||||
return app('json')->fail('上级推广人不能为自己');
|
||||
}
|
||||
if (!$this->services->count(['uid' => $spreadUid])) {
|
||||
return app('json')->fail('上级用户不存在');
|
||||
}
|
||||
$spreadInfo = $this->services->get($spreadUid);
|
||||
if ($spreadInfo->spread_uid == $uid) {
|
||||
return app('json')->fail('上级推广人不能为自己下级');
|
||||
}
|
||||
}
|
||||
unset($data['true_pwd']);
|
||||
if (!$uid) return app('json')->fail('数据不存在');
|
||||
$data['money'] = (string)$data['money'];
|
||||
$data['integration'] = (string)$data['integration'];
|
||||
$data['extend_info'] = $this->services->handelExtendInfo($data['extend_info']);
|
||||
return app('json')->success($this->services->updateInfo((int)$uid, $data) ? '修改成功' : '修改失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户余额和积分
|
||||
* @param Request $request
|
||||
* @param $uid
|
||||
* @return mixed
|
||||
*/
|
||||
public function userGive(Request $request, $uid)
|
||||
{
|
||||
$data = $request->postMore([
|
||||
['money_status', 0],
|
||||
['money', 0],
|
||||
['integration_status', 0],
|
||||
['integration', 0],
|
||||
]);
|
||||
if (!$uid) return app('json')->fail('数据不存在');
|
||||
$data['money'] = (string)$data['money'];
|
||||
$data['integration'] = (string)$data['integration'];
|
||||
$data['is_other'] = true;
|
||||
return app('json')->success($this->services->updateInfo($uid, $data) ? '修改成功' : '修改失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户详情
|
||||
* @param $uid
|
||||
* @return \think\Response
|
||||
* @author 吴汐
|
||||
* @email 442384644@qq.com
|
||||
* @date 2023/06/20
|
||||
*/
|
||||
public function info($uid)
|
||||
{
|
||||
if (!$uid) return app('json')->fail('参数错误');
|
||||
$data = $this->services->userInfo($uid);
|
||||
return app('json')->success(compact('data'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user