| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- /**
- * 支付宝支付
- */
- namespace app\api\services;
- use AlibabaCloud\SDK\OSS\OSS\GetObjectRequest\header;
- use app\common\model\ShopOrderModel as Order;
- use Rsa\RsaClient;
- use Symfony\Component\Translation\Dumper\IniFileDumper;
- use think\facade\Db;
- class BalancePayServices extends BasePayServices
- {
- public function balanceToOrder($uid, $order_id){
- $order_info = Db::name('shop_order')->where('order_sn', $order_id)->where('user_id', $uid)->find();
- if ($order_info['status'] != 0){
- sr_throw('订单已支付,不能再次支付');
- }
- $user = Db::name('user')->where('id', $uid)->find();
- if (!$order_info){
- sr_throw('订单号错误');
- }
- if ($user['money']<$order_info['payment']){
- sr_throw('当前用户余额不足');
- }
- // Db::name('shop_order')->where('order_sn', $order_id)->save([
- // 'status'=>1,
- // 'updated_time'=>sr_getcurtime(time()),
- // 'pay_type'=>3
- // ]);
- edit_user_money(11, $uid, $order_info['payment']);
- addUserMessage($uid, 3, '余额购买商品成功', '恭喜你已经兑换到心仪的商品,请等待发货,如有疑问请联系客服');
- $out_trade_no = 'BA'.$order_id.mt_rand(1, 10000);
- $insert = [
- 'total_fee' => $order_info['payment'],
- 'trade_type' => 'app',
- 'body' => '购买商品',
- 'state' => 6,
- 'out_trade_no' => $out_trade_no,
- 'pay_way' => 3,
- 'remarks' => $order_id,
- 'order_type' => 4,
- 'pay_at'=>sr_getcurtime(time()),
- 'uid' => $uid,
- 'voucher_img' => '',
- 'out_trade_no1'=>''
- ];
- // 添加支付订单表
- Db::name('payment')->insert($insert);
- $ser = new ThirdPayServices();
- $ser->payBalanceDown($order_id, 3, '');
- }
- }
|