public function postRecoverCapsule($recoverId) { $rules = array('num' => 'required|integer'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('branch/recover-capsule/' . $recoverId)->withErrors($validator)->withInput(); } $recover = BranchGoodItems::find($recoverId); $num = Input::get('num'); if ($num > $recover->sell - $recover->capsule) { return Redirect::to('branch/recover-capsule/' . $recoverId)->with('error', '回收数量不能大于销售数量!'); } $price = Input::get('price'); if ($price == 'z') { $custom_price = Input::get('custom_price'); if (empty($custom_price)) { return Redirect::to('branch/recover-capsule/' . $recoverId)->with('error', '请输入自定义价格!'); } $price = $custom_price; } $recover->capsule = $recover->capsule + $num; $recover->save(); $good_capsule = new GoodCapsule(); $good_capsule->good_id = $recover->good_id; $good_capsule->branch_id = $recover->branch_id; $good_capsule->capsule = $num; $good_capsule->price = $price; $good_capsule->money = $price * $num; $good_capsule->save(); return Redirect::to('branch/recover/' . $recoverId)->with('success', '回收成功!'); }
public function postDone($PickingID) { $rules = array('real_bn' => 'required|unique:delivery'); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::to('picking/done/' . $PickingID)->withErrors($validator)->withInput(); } $delivery = Delivery::find($PickingID); $delivery->status = '3'; $delivery->real_bn = Input::get('real_bn'); $delivery->pay_status = Input::get('pay_status'); $delivery->t_confirm = $this->__time(); $delivery->save(); // 增加销售记录 用于退换回收 2014.05.21 $delivery_items = DeliveryItems::where('delivery_id', $delivery->id)->get(); foreach ($delivery_items as $item) { $g = BranchGoodItems::where('good_id', $item->good_id)->where('branch_id', $item->branch_id)->first(); if ($g) { $i = BranchGoodItems::find($g->id); $i->sell = $i->sell + $item->number; $i->save(); } else { $i = new BranchGoodItems(); $i->good_id = $item->good_id; $i->branch_id = $item->branch_id; $i->sell = $item->number; $i->save(); } } return Redirect::to('picking')->with('success', '出货单(' . $delivery->bn . ')已完成!'); }