|
@@ -126,7 +126,8 @@ class PayTemplateController extends CatchController
|
|
|
*/
|
|
|
public function show($id)
|
|
|
{
|
|
|
- $uid = $this->getLoginUser()->id;
|
|
|
+ //$uid = $this->getLoginUser()->id;
|
|
|
+ $uid= 1;
|
|
|
if(UserService::userHasRole($uid,'administrator')){
|
|
|
$uid = 0;
|
|
|
}
|
|
@@ -262,6 +263,67 @@ class PayTemplateController extends CatchController
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * 编辑单条选项
|
|
|
+ *
|
|
|
+ * @param [type] $id
|
|
|
+ * @param Request $request
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function updatePayTemplateItem($id,Request $request){
|
|
|
+ $info = $this->payTemplateItem->find($id);
|
|
|
+ $price = $request->post('price');
|
|
|
+ $type = $request->post('type');
|
|
|
+ if(empty($price) || empty($type)){
|
|
|
+ ChannelBusinessException::throwError(Errors::PARAM_EMPTY);
|
|
|
+ }
|
|
|
+ $given = $request->post('given',0);
|
|
|
+ if($given > 3*$price*100){
|
|
|
+ ChannelBusinessException::throwError(Errors::PAY_TEMPLATE_GIVEN_TOO_MUCH);
|
|
|
+ }
|
|
|
+
|
|
|
+ $sequence = $request->post('sequence',0);
|
|
|
+ $is_default = $request->post('is_default',0);
|
|
|
+ $is_first_pay = 0;
|
|
|
+ if($type == 'FIRST_COIN'){
|
|
|
+ $type = 'COIN';
|
|
|
+ $is_first_pay = 1;
|
|
|
+ }
|
|
|
+ $product_info = $this->getPayProduct($price,$type,$given);
|
|
|
+ if($info->pay_product_id == $product_info->id){
|
|
|
+ $info->is_first_pay = $is_first_pay;
|
|
|
+ $info->is_default = $is_default;
|
|
|
+ $info->save();
|
|
|
+ }else{
|
|
|
+ $info->status = 0;
|
|
|
+ $info->save();
|
|
|
+ $data = [
|
|
|
+ 'pay_template_id'=>$info->pay_template_id,'pay_product_id'=>$product_info->id,
|
|
|
+ 'is_first_pay'=>$is_first_pay,'is_default'=>$is_default,
|
|
|
+ 'status'=>1,'sequence'=>$sequence,'created_at'=>Carbon::now(),'updated_at'=>Carbon::now()
|
|
|
+ ];
|
|
|
+ $this->payTemplateItem->insert($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除单条选项
|
|
|
+ *
|
|
|
+ * @param [type] $id
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function deleteOneItem($id){
|
|
|
+ $info = $this->payTemplateItem->find($id);
|
|
|
+ $info->status = 0;
|
|
|
+ $info->save();
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新模板状态
|
|
|
*
|
|
|
* @param int $id
|