zxhxx 4 years ago
parent
commit
6bf07c709b

+ 6 - 1
application/api/controller/Project.php

@@ -1,6 +1,7 @@
 <?php
 namespace app\api\controller;
 use app\common\controller\Api;
+use app\common\model\Category;
 use app\common\model\project\ProjectDonation;
 use app\common\model\project\ProjectDonationOrder;
 use app\common\model\project\ProjectDonationRocord;
@@ -115,7 +116,7 @@ class Project extends Api
         $where['cid'] = $this->cid;
         $order = ProjectDonationOrder::create_order($where);
         if ($order === false) return $this->error(ProjectDonationOrder::getErrorInfo('订单生成失败'));
-        return app('json')->successful($order);
+        $this->success('创建成功',$order);
     }
 
     /**
@@ -182,4 +183,8 @@ class Project extends Api
         $where['uid'] = $this->auth->getUserinfo()['id'];
         return  $this->success('获取成功',ProjectDonationUser::where($where)->select());
     }
+    public  function Donation_info()
+    {
+        $this->success('获取成功',Category::getCategoryArray('project'));
+    }
 }

+ 9 - 1
application/common/model/project/ProjectDonation.php

@@ -2,6 +2,7 @@
 
 namespace app\common\model\project;
 
+use app\common\model\Category;
 use liuniu\BaseModel;
 use think\Model;
 
@@ -111,11 +112,18 @@ class ProjectDonation extends BaseModel
     {
         $info = self::find($id);
         if($info) {
-            $info['project_donation_info'] = ProjectDonationInfo::where('pro_id', $id)->select();
+            $rs =  ProjectDonationInfo::where('pro_id', $id)->select();
+
+            foreach ($rs as &$v)
+            {
+                $v['ify_tile'] = Category::where('id',$v['project_donation_id'])->value('name');
+            }
+            $info['project_donation_info'] =$rs;
             $sum = ProjectDonationInfo::where('pro_id', $id)->group('pro_id')->field('sum(project_donation_num) as project_donation_num ,sum(received) as received')->find();
             $info['project_progress'] = bcdiv($sum['received'],$sum['project_donation_num'],0);
         }
         return $info;
     }
 
+
 }

+ 8 - 4
application/common/model/project/ProjectDonationOrder.php

@@ -205,7 +205,7 @@ class ProjectDonationOrder extends BaseModel
         list($msec, $sec) = explode(' ', microtime());
         $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
         $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
-        if (self::be(['order_sn' => $orderId])) $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
+        if (self::where(['order_sn' => $orderId])->find()) $orderId = 'wx' . $msectime . mt_rand(10000, 99999);
         return $orderId;
     }
 
@@ -228,7 +228,11 @@ class ProjectDonationOrder extends BaseModel
             }
             $where['order_sn'] = self::getNewOrderId();
             $where['add_time'] = time();
-            $rs = self::create($where);
+            $where1 = $where;
+            unset($where1['item']);
+            unset($where1['item']);
+            unset($where1['item']);
+            $rs = self::create($where1);
             if($rs)
             {
                 $data['project_id'] = $where['project_id'];
@@ -254,8 +258,8 @@ class ProjectDonationOrder extends BaseModel
             return self::setErrorInfo('订单创建失败');
         }catch (Exception $e)
         {
-            self::rollbackTrans();
-            return self::setErrorInfo('生成订单时系统错误错误原因:' .$e->getLine());
+
+            return self::setErrorInfo('生成订单时系统错误错误原因:' .$e->getFile().$e->getLine().$e->getMessage(),true);
         }
 
     }

+ 0 - 1
application/route.php

@@ -93,7 +93,6 @@ Route::group('api', function () {
         Route::post('create_user', 'api/project/create_user');//创建用户
         Route::get('user_list', 'api/project/user_list');//我的所有用户
         Route::get('Donation_info', 'api/project/Donation_info');//系统所有物资
-        Route::get('logistics', 'api/project/logistics');//获取物流方式
         Route::post('bill', 'api/project/bill');//所有状态记录
         Route::get('order_info', 'api/project/order_info');//订单详情
     });