|
|
@@ -17,7 +17,7 @@ namespace app\api\logic;
|
|
|
use app\common\cache\WebScanLoginCache;
|
|
|
use app\common\logic\BaseLogic;
|
|
|
use app\api\service\{UserTokenService, WechatUserService};
|
|
|
-use app\common\enum\{LoginEnum, user\UserTerminalEnum, YesNoEnum};
|
|
|
+use app\common\enum\{LoginEnum, PayEnum, user\UserTerminalEnum, YesNoEnum};
|
|
|
use app\common\service\{
|
|
|
ConfigService,
|
|
|
FileService,
|
|
|
@@ -27,6 +27,8 @@ use app\common\service\{
|
|
|
wechat\WeChatRequestService
|
|
|
};
|
|
|
use app\common\model\agricultural_machinery\UserService;
|
|
|
+use app\common\model\ServiceCharge;
|
|
|
+use app\common\model\recharge\RechargeOrder;
|
|
|
use app\common\model\user\{User, UserAuth};
|
|
|
use think\facade\{Db, Config};
|
|
|
|
|
|
@@ -54,7 +56,7 @@ class ServiceLogic extends BaseLogic
|
|
|
// $password = create_password($params['password'], $passwordSalt);
|
|
|
// $avatar = ConfigService::get('default_image', 'user_avatar');
|
|
|
|
|
|
- UserService::create([
|
|
|
+ $result = UserService::create([
|
|
|
'user_id' => $params['user_id'],
|
|
|
'type' => $params['type'] ?? 1,
|
|
|
'name' => $params['name'],
|
|
|
@@ -65,12 +67,42 @@ class ServiceLogic extends BaseLogic
|
|
|
'area_id' => $params['area_id'],
|
|
|
'money' => $params['money'],
|
|
|
]);
|
|
|
+ if($result){
|
|
|
+ $service_fee = ServiceCharge::find(1);
|
|
|
+ $order_money = 0;
|
|
|
+ switch ($params['type']){
|
|
|
+ case 1 :
|
|
|
+ $order_money =$service_fee['agricultural_machinery_service_fee'];
|
|
|
+ break;
|
|
|
+ case 1 :
|
|
|
+ $order_money =$service_fee['bake_service_fee'];
|
|
|
+ break;
|
|
|
+ case 1 :
|
|
|
+ $order_money =$service_fee['air_control_service_fee'];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'sn' => generate_sn(RechargeOrder::class, 'sn'),
|
|
|
+ 'user_id' => $params['user_id'],
|
|
|
+ 'service_id'=>$result['id'],
|
|
|
+ 'pay_status' => PayEnum::UNPAID,
|
|
|
+ 'order_amount' => $order_money,
|
|
|
+ ];
|
|
|
+ $order = RechargeOrder::create($data);
|
|
|
+
|
|
|
+ $order_info = [
|
|
|
+ 'order_id' => (int)$order['id'],
|
|
|
+ 'order_sn' => $order['sn'],
|
|
|
+ 'from' => 'service'
|
|
|
+ ];
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
- return true;
|
|
|
+ return ['code'=>1,'data'=>$order_info];
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollback();
|
|
|
self::setError($e->getMessage());
|
|
|
- return false;
|
|
|
+ return ['code'=>0,'data'=>[]];
|
|
|
}
|
|
|
}
|
|
|
|