dao->save($add); } /** * @param array $where * @return array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getOne(array $where) { if (!$where) throw new ValidateException('条件缺失'); return $this->dao->getOne($where); } /** * 汇总付费会员节省金额 * @param $uid * @return float * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function sumEconomizeMoney($uid) { $economizeMoney = 0.00; if (!$uid) return $economizeMoney; $list = $this->dao->getList(['uid' => $uid]); if ($list) { foreach ($list as $k => $v) { $economizeMoney += $v['postage_price']; $economizeMoney += $v['member_price']; $economizeMoney += $v['offline_price']; $economizeMoney += $v['coupon_price']; } } return (float)sprintf("%.2f", $economizeMoney); } }