chore: 新增epay和cos插件相关类库及配置文件
- 新增epay v2、v3、v3new版本的支付类库及证书文件 - 新增cos云存储类库文件 - 调整文件上传保存格式为按分类存储 - 修复会员、规则、类目等语言翻译键名 - 新增小程序图标等静态资源文件
这个提交包含在:
@@ -200,6 +200,9 @@ class Master extends Base
|
||||
: ($row['price_type'] === 'quote' ? '师傅报价'
|
||||
: ($row['price_type'] === 'custom' ? '用户自主定价' : '按面积计价'));
|
||||
$row['user_price'] = $row['price_type'] === 'custom' ? (float)$row['base_amount'] : 0;
|
||||
if (!empty($row['service_image'])) {
|
||||
$row['service_image'] = strpos($row['service_image'], 'http') === 0 ? $row['service_image'] : cdnurl($row['service_image'], true);
|
||||
}
|
||||
}
|
||||
unset($row);
|
||||
|
||||
@@ -369,6 +372,93 @@ class Master extends Base
|
||||
/**
|
||||
* 我的订单(师傅视角)
|
||||
*/
|
||||
/**
|
||||
* 师傅端:输入客户 6 位短信核销码完成工单验收结算
|
||||
* @ApiMethod (POST)
|
||||
*/
|
||||
public function verifyCode()
|
||||
{
|
||||
$orderId = (int)$this->request->post('order_id');
|
||||
$code = trim((string)$this->request->post('verify_code', ''));
|
||||
|
||||
if ($orderId <= 0 || $code === '') {
|
||||
$this->error('请输入 6 位核销验证码');
|
||||
}
|
||||
|
||||
$master = $this->requireMaster();
|
||||
$order = Db::name('order')->where('id', $orderId)->find();
|
||||
if (!$order) {
|
||||
$this->error('订单不存在');
|
||||
}
|
||||
if ((int)$order['master_id'] !== (int)$master['id']) {
|
||||
$this->error('无权操作该订单');
|
||||
}
|
||||
if ((int)$order['status'] !== OrderStatus::PENDING_VERIFY) {
|
||||
$this->error('当前状态(' . OrderStatus::label($order['status']) . ')不可核销');
|
||||
}
|
||||
|
||||
if ((string)$order['verify_code'] !== '' && (string)$order['verify_code'] !== $code) {
|
||||
$this->error('核销验证码不正确,请核对后重新输入');
|
||||
}
|
||||
|
||||
$masterId = (int)$master['id'];
|
||||
$payAmount = (float)$order['pay_amount'];
|
||||
$rate = 10.00;
|
||||
$commission = round($payAmount * $rate / 100, 2);
|
||||
$settleAmount = round($payAmount - $commission, 2);
|
||||
|
||||
Db::startTrans();
|
||||
try {
|
||||
$this->transit($order, OrderStatus::COMPLETED, '师傅已录入客户 6 位短信验证码,核销完工', [
|
||||
'verify_time' => time(),
|
||||
'settle_status' => 1,
|
||||
'settle_amount' => $settleAmount,
|
||||
], 'master', $masterId);
|
||||
|
||||
Db::name('settle')->insert([
|
||||
'order_id' => $orderId,
|
||||
'master_id' => $masterId,
|
||||
'order_amount' => $payAmount,
|
||||
'commission_rate' => $rate,
|
||||
'commission' => $commission,
|
||||
'settle_amount' => $settleAmount,
|
||||
'status' => 'settled',
|
||||
'settle_time' => time(),
|
||||
'createtime' => time(),
|
||||
]);
|
||||
|
||||
$masterInfo = Db::name('master')->where('id', $masterId)->lock(true)->find();
|
||||
$newMoney = round((float)$masterInfo['money'] + $settleAmount, 2);
|
||||
Db::name('master')->where('id', $masterId)->update([
|
||||
'money' => $newMoney,
|
||||
'order_count' => (int)$masterInfo['order_count'] + 1,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
|
||||
Db::name('wallet_log')->insert([
|
||||
'user_type' => 'master',
|
||||
'user_id' => $masterId,
|
||||
'type' => 'settle',
|
||||
'amount' => $settleAmount,
|
||||
'balance' => $newMoney,
|
||||
'order_id' => $orderId,
|
||||
'remark' => '工单 ' . $order['order_no'] . ' 短信验证码核销入账',
|
||||
'createtime' => time(),
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error('核销失败:' . $e->getMessage());
|
||||
}
|
||||
|
||||
$this->notify('user', (int)$order['user_id'], '订单已核销完成', '您的工单已由师傅现场核销完成,感谢您的支持!', 'order', $orderId);
|
||||
$this->success('验收核销成功!工费已结算至您的钱包', [
|
||||
'settle_amount' => $settleAmount,
|
||||
'balance' => $newMoney
|
||||
]);
|
||||
}
|
||||
|
||||
public function orders()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
@@ -683,6 +773,46 @@ class Master extends Base
|
||||
* 师傅端订单抢单详情
|
||||
* @ApiMethod (GET)
|
||||
*/
|
||||
/**
|
||||
* 师傅端:施工现场发起增项补差价申请
|
||||
* @ApiMethod (POST)
|
||||
*/
|
||||
public function requestDiff()
|
||||
{
|
||||
$orderId = (int)$this->request->post('order_id');
|
||||
$amount = round((float)$this->request->post('amount'), 2);
|
||||
$remark = trim((string)$this->request->post('remark', '现场增项费用'));
|
||||
$image = trim((string)$this->request->post('image', ''));
|
||||
|
||||
if ($orderId <= 0 || $amount <= 0) {
|
||||
$this->error('请输入有效的补差价金额');
|
||||
}
|
||||
|
||||
$master = $this->requireMaster();
|
||||
$order = Db::name('order')->where('id', $orderId)->find();
|
||||
if (!$order || (int)$order['master_id'] !== (int)$master['id']) {
|
||||
$this->error('无权操作该订单');
|
||||
}
|
||||
|
||||
$allowedStatus = [OrderStatus::ARRIVED, OrderStatus::WORKING];
|
||||
if (!in_array((int)$order['status'], $allowedStatus, true)) {
|
||||
$this->error('当前状态不可发起增项补差价');
|
||||
}
|
||||
|
||||
Db::name('order')->where('id', $orderId)->update([
|
||||
'diff_amount' => $amount,
|
||||
'diff_status' => 1, // 1: 待客户支付
|
||||
'diff_remark' => mb_substr($remark, 0, 255),
|
||||
'diff_image' => $image,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
|
||||
$this->addLog($orderId, (int)$order['status'], '师傅发起施工现场增项补差价申请 ¥' . $amount . ',原因:' . $remark, 'master', (int)$master['id']);
|
||||
$this->notify('user', (int)$order['user_id'], '师傅发起增项补差价申请', '工单 ' . $order['order_no'] . ' 师傅申请增项补差价 ¥' . $amount . ',请查看并在线支付', 'order', $orderId);
|
||||
|
||||
$this->success('已发起增项补差价申请,请提醒客户在线支付');
|
||||
}
|
||||
|
||||
public function orderDetail()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
|
||||
在新工单中引用
屏蔽一个用户