diff --git a/application/api/controller/User.php b/application/api/controller/User.php index 6004c09..8c740a6 100755 --- a/application/api/controller/User.php +++ b/application/api/controller/User.php @@ -664,13 +664,18 @@ class User extends Api $user = $this->auth->getUserinfo(); $id = $this->request->post("id", 1); $pay_voucher = $this->request->post("pay_voucher", 10); + if (!$pay_voucher) { + $this->error("没有上传支付凭证"); + } $info = Db::name('income_expend')->where("id", $id)->find(); if (!$info) { $this->error("记录不存在"); } Db::name('income_expend')->where("id", $id)->update(["pay_voucher" => $pay_voucher, "updatetime" => time(),'status' => 2]); - //是否都提交了了支付凭证,更新我的买单为支付待确认 + //是否都提交了了支付凭证,更新我的买单为支付待确认,卖单为已完成 $is_all = Db::name('income_expend')->whereTime('createtime', 'today')->where("payer_id", $user['id'])->where('pay_voucher', '')->find(); + // var_dump($is_all); + // exit(); if (!$is_all) { Db::name('order') ->whereTime('createtime', 'today') @@ -678,6 +683,13 @@ class User extends Api ->where('user_id', $user['id']) ->where('order_type', 0) ->update(['status' => 1,"updatetime" => time()]); + + Db::name('order') + ->whereTime('createtime', 'today') + ->where('warehouse_id', $info['warehouse_id']) + ->where('user_id', $user['id']) + ->where('order_type', 1) + ->update(['status' => 6,"updatetime" => time()]); } $this->success("succ"); } @@ -697,9 +709,16 @@ class User extends Api $this->error("付款人还没支付,不能确认收款"); } Db::name('income_expend')->where("id", $id)->update(['status' => 3, "updatetime" => time()]); - //把今天自己的订单都改为已完成 + //把今天自己的卖单订单都改为已完成,买单更新为已支付 $is_all = Db::name('income_expend')->whereTime('createtime', 'today')->where("payee_id", $user['id'])->where('status','<>', 3)->find(); if (!$is_all) { + Db::name('order') + ->whereTime('createtime', 'today') + ->where('warehouse_id', $info['warehouse_id']) + ->where('user_id', $user['id']) + ->where('order_type', 0) + ->update(['status' => 1,"updatetime" => time()]); + Db::name('order') ->whereTime('createtime', 'today') ->where('warehouse_id', $info['warehouse_id']) diff --git a/application/common/service/OrderService.php b/application/common/service/OrderService.php index fb2005b..4ef66e9 100644 --- a/application/common/service/OrderService.php +++ b/application/common/service/OrderService.php @@ -44,14 +44,23 @@ class OrderService $buyer_order[] = $value; } } + // echo "
";
+		// print_r($buyer_order);
+		// print_r($seller_order);
+		//exit();
 		$pay_record = [];
-		foreach ($seller_order as $seller) {
+		foreach ($seller_order as $seq => &$seller) {
 			if ($seller['pay_amount'] <= 0) {
-                   continue;
+				unset($seller_order[$seq]);
+                continue;
             }
-            foreach ($buyer_order as $key => $buyer) {
+            foreach ($buyer_order as $key => &$buyer) {
+            	if ($buyer['pay_amount'] == 0) {
+            		unset($buyer_order[$key]);
+	                continue;
+	            }
             	if ($seller['pay_amount'] >= abs($buyer['pay_amount'])) {
-	               $pay_record[] = [
+	                $pay_record[] = [
 	                       'payer_id' => $buyer['user_id'],
 	                       'payee_id' => $seller['user_id'],
 	                       'amount' => abs($buyer['pay_amount']),
@@ -62,7 +71,7 @@ class OrderService
 	              	$seller['pay_amount'] = $seller['pay_amount'] + $buyer['pay_amount'];
 	                unset($buyer_order[$key]);
 	          	} else {
-	               $pay_record[] = [
+	                $pay_record[] = [
 	                      'payer_id' => $buyer['user_id'],
 	                       'payee_id' => $seller['user_id'],
 	                       'amount' => $seller['pay_amount'],
@@ -73,8 +82,14 @@ class OrderService
 	               $buyer['pay_amount'] = $buyer['pay_amount'] + $seller['pay_amount'];
 	               $seller['pay_amount'] = 0;
 	            }
+	            // echo "
";
+				// print_r($buyer);
             }
-			
+		}
+		foreach ($pay_record as $key => $value) {
+			if ($value['amount'] == 0) {
+				unset($pay_record[$key]);
+			}
 		}
 		// echo "
";
 		// print_r($pay_record);