<?php /*编辑或者添加商品信息*/ require_once ykfile("source/commodity_service.php"); $id = intval($_GET['comm_id']); $comm_ser = new CommodityService(); $commodity = $comm_ser->get_by_id($id); $page_title = ""; if ($commodity) { $page_title = "商品信息编辑"; } else { $page_title = "添加商品信息"; } require_once ykfile("pages/admin/edit_commodity.php");
public function exchange_commodity($com_id, $mobile, $address, $name) { $comsrv = new CommodityService(); $com = $comsrv->get_by_id($com_id); if ($com->count <= 0) { return GOOD_IS_ZERO; } $user_info = $this->get_by_uuid($this->user->uuid); if ($com->price > $user_info->scores) { return USER_ERR_SCORE_NOT_ENOUGH; } // 插入兑换记录 $result = $comsrv->add_exch_record($com_id, $this->user->uuid, $mobile, $address, $name); if ($result) { $umod = new UserModule($this->user->uuid); $score = 0 - $com->price; $rs = $umod->sub_score($this->user->uuid, $score); $comsrv->dec_com($com_id); } return $result; }