find(); if (!$user) { self::setError('用户不存在'); return false; } $milliseconds = substr(microtime(true) * 1000, -5, 3); $orderNo = '0' . date('YmdHis') . $milliseconds . rand(10, 99); UserPayOrder::create([ 'orderNo' => $orderNo, 'uid' => $params['uid'], 'productIdentifying' => $params['productIdentifying'], 'productDes' => $params['productDes'], 'commodityPrice' => $params['commodityPrice'], 'productType' => $params['productType'], 'status' => 3, 'msg' => '1.后台创建订单;', 'platform' => 'WEB', 'createTime' => date('Y-m-d H:i:s'), ]); Db::connect('game_sdk') ->table('app_order') ->insert([ 'AppId' => $appid, 'Uid' => $params['uid'], 'Price' => $params['commodityPrice'], 'CreateTime' => date('Y-m-d H:i:s'), 'DepTime' => date('Y-m-d H:i:s'), 'Currency' => 'usd', 'OrderId' => $orderNo, 'ProductId' => $params['productIdentifying'], 'Status' => 3, ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑 * @param array $params * @return bool * @author likeadmin * @date 2024/03/14 17:18 */ public static function edit(array $params): bool { Db::startTrans(); try { UserPayOrder::where('orderNo', $params['orderNo'])->update([ 'uid' => $params['uid'], 'status' => $params['status'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除 * @param array $params * @return bool * @author likeadmin * @date 2024/03/14 17:18 */ public static function delete(array $params): bool { $re = UserPayOrder::where('orderNo', $params['orderNo'])->delete(); if ($re) { Db::connect('game_sdk') ->table('app_order') ->where('OrderId', $params['orderNo']) ->delete(); } return $re; } /** * @notes 获取详情 * @param $params * @return array * @author likeadmin * @date 2024/03/14 17:18 */ public static function detail($params): array { return UserPayOrder::findOrEmpty($params['orderNo'])->toArray(); } }