|  | @@ -375,15 +375,15 @@ class Buy
 | 
											
												
													
														|  |          $msg = $send['pay_msg'];
 |  |          $msg = $send['pay_msg'];
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          $order = Dever::db('shop/buy_order')->one(array('id' => $product_id, 'time' => time()));
 |  |          $order = Dever::db('shop/buy_order')->one(array('id' => $product_id, 'time' => time()));
 | 
											
												
													
														|  | -        if ($order && $order['status'] == 1) {
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -            if ($status == 2) {
 |  | 
 | 
											
												
													
														|  | -                
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if ($order && $order['status'] == 1 && $status == 2) {
 | 
											
												
													
														|  |              $update['status'] = 2;
 |  |              $update['status'] = 2;
 | 
											
												
													
														|  |              $update['where_id'] = $order['id'];
 |  |              $update['where_id'] = $order['id'];
 | 
											
												
													
														|  |              Dever::db('shop/buy_order')->update($update);
 |  |              Dever::db('shop/buy_order')->update($update);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            # 生成结算单
 | 
											
												
													
														|  | 
 |  | +            if ($order['type'] == 1) {
 | 
											
												
													
														|  | 
 |  | +                Dever::load('cash/lib/shop')->up($order, 1, 1, 1, 1);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          return 'ok';
 |  |          return 'ok';
 | 
											
										
											
												
													
														|  | @@ -435,6 +435,11 @@ class Buy
 | 
											
												
													
														|  |                  if ($goods) {
 |  |                  if ($goods) {
 | 
											
												
													
														|  |                      Dever::load('shop/lib/goods')->oper($data, 1, 1, $goods);
 |  |                      Dever::load('shop/lib/goods')->oper($data, 1, 1, $goods);
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                # 生成结算单
 | 
											
												
													
														|  | 
 |  | +                if ($data['type'] == 1) {
 | 
											
												
													
														|  | 
 |  | +                    Dever::load('cash/lib/shop')->up($data, 1, 2, 2, 1);
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              return 'ok';
 |  |              return 'ok';
 | 
											
										
											
												
													
														|  | @@ -449,6 +454,10 @@ class Buy
 | 
											
												
													
														|  |          $data = $this->getView($id, $order_id, false);
 |  |          $data = $this->getView($id, $order_id, false);
 | 
											
												
													
														|  |          if ($data['status'] == 1) {
 |  |          if ($data['status'] == 1) {
 | 
											
												
													
														|  |              $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => 7, 'operdate' => time()));
 |  |              $state = Dever::db('shop/buy_order')->update(array('where_id' => $data['id'], 'status' => 7, 'operdate' => time()));
 | 
											
												
													
														|  | 
 |  | +            # 生成结算单
 | 
											
												
													
														|  | 
 |  | +            if ($state && $data['type'] == 1) {
 | 
											
												
													
														|  | 
 |  | +                Dever::load('cash/lib/shop')->up($data, 1, 1, 3, 1);
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  |              return 'ok';
 |  |              return 'ok';
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  |              Dever::alert('当前订单状态不允许取消');
 |  |              Dever::alert('当前订单状态不允许取消');
 | 
											
										
											
												
													
														|  | @@ -985,6 +994,10 @@ class Buy
 | 
											
												
													
														|  |                      $num = $order['num'] - $num;
 |  |                      $num = $order['num'] - $num;
 | 
											
												
													
														|  |                      Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'price' => $price, 'num' => $num));
 |  |                      Dever::db('shop/buy_order')->update(array('where_id' => $order['id'], 'price' => $price, 'num' => $num));
 | 
											
												
													
														|  |                      Dever::load('shop/lib/refund')->set('buy')->apply(1, $shop['id'], $order_id, false, 3, 0, '供货商库存不足');
 |  |                      Dever::load('shop/lib/refund')->set('buy')->apply(1, $shop['id'], $order_id, false, 3, 0, '供货商库存不足');
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                    if ($order['type'] == 1) {
 | 
											
												
													
														|  | 
 |  | +                        Dever::load('cash/lib/shop')->up($order, 2, 1, 1, 2);
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
										
											
												
													
														|  | @@ -995,6 +1008,13 @@ class Buy
 | 
											
												
													
														|  |          if ($this->order_id) {
 |  |          if ($this->order_id) {
 | 
											
												
													
														|  |              foreach ($this->order_id as $k => $v) {
 |  |              foreach ($this->order_id as $k => $v) {
 | 
											
												
													
														|  |                  $this->sendMsg($v[0], $v[1], $k);
 |  |                  $this->sendMsg($v[0], $v[1], $k);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +                if ($k != $order['id']) {
 | 
											
												
													
														|  | 
 |  | +                    $order_info = Dever::db('shop/buy_order')->find($k);
 | 
											
												
													
														|  | 
 |  | +                    if ($order_info['type'] == 1) {
 | 
											
												
													
														|  | 
 |  | +                        Dever::load('cash/lib/shop')->up($order_info, 1, 1, 1, 1);
 | 
											
												
													
														|  | 
 |  | +                    }
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 |